Skip to content

Commit 32f6984

Browse files
Merge pull request #67 from objectbox/65-test-null-properties
Test null values for entity properties
2 parents b571130 + 6b89922 commit 32f6984

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

test/box_test.dart

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,31 @@ void main() {
9898
final List<TestEntity> items = [int64Min, int64Max].map((n) => TestEntity.initInteger(n)).toList();
9999
expect("${items[0].number}", equals("$int64Min"));
100100
expect("${items[1].number}", equals("$int64Max"));
101-
final List<int> ids = box.putMany(items);
102-
final List<TestEntity> fetchedItems = box.getMany([ids[0], ids[1]]);
101+
final List<TestEntity> fetchedItems = box.getMany(box.putMany(items));
103102
expect(fetchedItems[0].number, equals(int64Min));
104103
expect(fetchedItems[1].number, equals(int64Max));
105104
});
106105

106+
test("null properties are handled correctly", () {
107+
final List<TestEntity> items = [TestEntity(), TestEntity.initInteger(10), TestEntity.initText("Hello")];
108+
final List<TestEntity> fetchedItems = box.getMany(box.putMany(items));
109+
expect(fetchedItems[0].id, isNot(equals(null)));
110+
expect(fetchedItems[0].number, equals(null));
111+
expect(fetchedItems[0].text, equals(null));
112+
expect(fetchedItems[0].b, equals(null));
113+
expect(fetchedItems[0].d, equals(null));
114+
expect(fetchedItems[1].id, isNot(equals(null)));
115+
expect(fetchedItems[1].number, isNot(equals(null)));
116+
expect(fetchedItems[1].text, equals(null));
117+
expect(fetchedItems[1].b, equals(null));
118+
expect(fetchedItems[1].d, equals(null));
119+
expect(fetchedItems[2].id, isNot(equals(null)));
120+
expect(fetchedItems[2].number, equals(null));
121+
expect(fetchedItems[2].text, isNot(equals(null)));
122+
expect(fetchedItems[2].b, equals(null));
123+
expect(fetchedItems[2].d, equals(null));
124+
});
125+
107126
test(".count() works", () {
108127
expect(box.count(), equals(0));
109128
List<int> ids = box.putMany(simpleItems);

0 commit comments

Comments
 (0)