|
| 1 | +import 'dart:io'; |
| 2 | +import 'lib/lib.dart'; |
| 3 | +import 'lib/objectbox.g.dart'; |
| 4 | +import 'package:test/test.dart'; |
| 5 | +import '../test_env.dart'; |
| 6 | +import '../common.dart'; |
| 7 | + |
| 8 | +void main() { |
| 9 | + TestEnv<A> env; |
| 10 | + final jsonModel = readModelJson('lib'); |
| 11 | + final defs = getObjectBoxModel(); |
| 12 | + final model = defs.model; |
| 13 | + |
| 14 | + setUp(() { |
| 15 | + env = TestEnv<A>(defs); |
| 16 | + }); |
| 17 | + |
| 18 | + tearDown(() { |
| 19 | + env.close(); |
| 20 | + }); |
| 21 | + |
| 22 | + commonModelTests(defs, jsonModel); |
| 23 | + |
| 24 | + test('project must be generated properly', () { |
| 25 | + expect(TestEnv.dir.existsSync(), true); |
| 26 | + expect(File('lib/objectbox.g.dart').existsSync(), true); |
| 27 | + expect(File('lib/objectbox-model.json').existsSync(), true); |
| 28 | + }); |
| 29 | + |
| 30 | + test('sync annotation', () { |
| 31 | + expect(entity(model, 'A').flags, equals(0)); |
| 32 | + expect(entity(jsonModel, 'A').flags, equals(0)); |
| 33 | + |
| 34 | + expect(entity(model, 'D').flags, equals(OBXEntityFlags.SYNC_ENABLED)); |
| 35 | + expect(entity(jsonModel, 'D').flags, equals(OBXEntityFlags.SYNC_ENABLED)); |
| 36 | + }); |
| 37 | + |
| 38 | + test('types', () { |
| 39 | + expect(property(model, 'T.tBool').type, OBXPropertyType.Bool); |
| 40 | + expect(property(model, 'T.tByte').type, OBXPropertyType.Byte); |
| 41 | + expect(property(model, 'T.tShort').type, OBXPropertyType.Short); |
| 42 | + expect(property(model, 'T.tChar').type, OBXPropertyType.Char); |
| 43 | + expect(property(model, 'T.tInt').type, OBXPropertyType.Int); |
| 44 | + expect(property(model, 'T.tLong').type, OBXPropertyType.Long); |
| 45 | + expect(property(model, 'T.tFloat').type, OBXPropertyType.Float); |
| 46 | + expect(property(model, 'T.tDouble').type, OBXPropertyType.Double); |
| 47 | + expect(property(model, 'T.tString').type, OBXPropertyType.String); |
| 48 | + expect(property(model, 'T.tDate').type, OBXPropertyType.Date); |
| 49 | + expect(property(model, 'T.tDateNano').type, OBXPropertyType.DateNano); |
| 50 | + expect(property(model, 'T.tListInt').type, OBXPropertyType.ByteVector); |
| 51 | + expect(property(model, 'T.tInt8List').type, OBXPropertyType.ByteVector); |
| 52 | + expect(property(model, 'T.tUint8List').type, OBXPropertyType.ByteVector); |
| 53 | + expect(property(model, 'T.tListString').type, OBXPropertyType.StringVector); |
| 54 | + |
| 55 | + expect(property(model, 'T.id').isSigned, isTrue); |
| 56 | + expect(property(model, 'T.tByte').isSigned, isTrue); |
| 57 | + expect(property(model, 'T.tShort').isSigned, isTrue); |
| 58 | + expect(property(model, 'T.tChar').isSigned, isTrue); |
| 59 | + expect(property(model, 'T.tInt').isSigned, isTrue); |
| 60 | + expect(property(model, 'T.tLong').isSigned, isTrue); |
| 61 | + |
| 62 | + expect(property(model, 'Unsigned.id').isSigned, isTrue); |
| 63 | + expect(property(model, 'Unsigned.tByte').isSigned, isFalse); |
| 64 | + expect(property(model, 'Unsigned.tShort').isSigned, isFalse); |
| 65 | + expect(property(model, 'Unsigned.tChar').isSigned, isFalse); |
| 66 | + expect(property(model, 'Unsigned.tInt').isSigned, isFalse); |
| 67 | + expect(property(model, 'Unsigned.tLong').isSigned, isFalse); |
| 68 | + }); |
| 69 | +} |
0 commit comments