forked from vandadnp/flutter-tips-and-tricks
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexpectation-extensions-in-flutter.dart
More file actions
30 lines (25 loc) · 979 Bytes
/
expectation-extensions-in-flutter.dart
File metadata and controls
30 lines (25 loc) · 979 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// 🐦 Twitter https://twitter.com/vandadnp
// 🔵 LinkedIn https://linkedin.com/in/vandadnp
// 🎥 YouTube https://youtube.com/c/vandadnp
// 💙 Free Flutter Course https://linktr.ee/vandadnp
// 📦 11+ Hours Bloc Course https://youtu.be/Mn254cnduOY
// 🤝 Want to support my work? https://buymeacoffee.com/vandad
import 'package:flutter_test/flutter_test.dart';
extension NullExpectations on Object? {
void expectNull() => expect(this, isNull);
void expectNotNull() => expect(this, isNotNull);
}
extension BoolExpectations on bool {
void expectTrue() => expect(this, true);
void expectFalse() => expect(this, false);
}
bool boolFunction() => true;
bool otherBoolFunction() => false;
String? stringFunction() => null;
int? intFunction() => 1;
void testIt() {
boolFunction().expectTrue();
otherBoolFunction().expectFalse();
stringFunction().expectNull();
intFunction().expectNotNull();
}