-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip #377
- Loading branch information
Showing
4 changed files
with
156 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:mem/databases/table_definitions/base.dart'; | ||
import 'package:mem/framework/repository/database_tuple_entity.dart'; | ||
|
||
import 'entity_test.dart'; | ||
|
||
const _name = 'DatabaseTupleEntity test'; | ||
|
||
class _TestObjectDatabaseTupleEntity extends TestObjectEntity | ||
with DatabaseTupleEntity<int> { | ||
_TestObjectDatabaseTupleEntity(super.a); | ||
|
||
_TestObjectDatabaseTupleEntity.fromMap(Map<String, dynamic> map) | ||
: super.fromMap(map) { | ||
withMap(map); | ||
} | ||
} | ||
|
||
void main() => group( | ||
_name, | ||
() { | ||
test( | ||
'#new', | ||
() { | ||
const a = false; | ||
|
||
final testObject = _TestObjectDatabaseTupleEntity(a); | ||
|
||
expect(testObject.a, equals(a)); | ||
}, | ||
); | ||
|
||
test( | ||
'#fromMap', | ||
() { | ||
final map = { | ||
TestObjectEntity.fieldNames[0]: false, | ||
defPkId.name: 1, | ||
defColCreatedAt.name: DateTime.now(), | ||
defColUpdatedAt.name: DateTime.now(), | ||
defColArchivedAt.name: null | ||
}; | ||
|
||
final testObject = _TestObjectDatabaseTupleEntity.fromMap(map); | ||
|
||
expect(testObject.a, map[TestObjectEntity.fieldNames[0]]); | ||
}, | ||
); | ||
|
||
test( | ||
'#toMap', | ||
() { | ||
final map = { | ||
TestObjectEntity.fieldNames[0]: false, | ||
defPkId.name: 1, | ||
defColCreatedAt.name: DateTime.now(), | ||
defColUpdatedAt.name: DateTime.now(), | ||
defColArchivedAt.name: null | ||
}; | ||
|
||
final testObject = _TestObjectDatabaseTupleEntity.fromMap(map); | ||
|
||
expect(testObject.toMap, map); | ||
}, | ||
); | ||
}, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import 'package:flutter_test/flutter_test.dart'; | ||
import 'package:mem/framework/repository/entity.dart'; | ||
|
||
const _name = 'Entity test'; | ||
|
||
class _TestObject { | ||
final bool a; | ||
|
||
_TestObject(this.a); | ||
} | ||
|
||
class TestObjectEntity extends _TestObject with Entity { | ||
static List<String> fieldNames = ['a']; | ||
|
||
TestObjectEntity(super.a); | ||
|
||
TestObjectEntity.fromMap(Map<String, dynamic> map) | ||
: super(map[TestObjectEntity.fieldNames[0]]); | ||
|
||
@override | ||
Map<String, dynamic> get toMap => {fieldNames[0]: a}; | ||
} | ||
|
||
void main() => group( | ||
_name, | ||
() { | ||
test( | ||
'#new', | ||
() { | ||
const a = false; | ||
|
||
final testObject = TestObjectEntity(a); | ||
|
||
expect(testObject.a, equals(a)); | ||
}, | ||
); | ||
|
||
test( | ||
'#fromMap', | ||
() { | ||
final map = {TestObjectEntity.fieldNames[0]: false}; | ||
|
||
final testObject = TestObjectEntity.fromMap(map); | ||
|
||
expect(testObject.a, equals(map[TestObjectEntity.fieldNames[0]])); | ||
}, | ||
); | ||
|
||
test( | ||
'#toMap', | ||
() { | ||
const a = false; | ||
|
||
final testObject = TestObjectEntity(a); | ||
|
||
expect( | ||
testObject.toMap, equals({TestObjectEntity.fieldNames[0]: a})); | ||
}, | ||
); | ||
}, | ||
); |