-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed issue with backed models and added tests for initializationComp…
…leted propagation
- Loading branch information
1 parent
32ed674
commit 9e3015b
Showing
2 changed files
with
51 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
import 'package:kiota_abstractions/kiota_abstractions.dart'; | ||
import 'package:mockito/annotations.dart'; | ||
import 'package:mockito/mockito.dart'; | ||
import 'package:test/test.dart'; | ||
|
||
import 'in_memory_backing_store_test.mocks.dart'; | ||
|
||
@GenerateMocks([BackedModel]) | ||
void main() { | ||
group('InMemoryBackingStore', () { | ||
|
@@ -69,5 +72,51 @@ void main() { | |
expect(store.iterate(), hasLength(1)); | ||
expect(store.get<String>('key'), 'value2'); | ||
}); | ||
|
||
test('propagates initialization completed to backed models', () { | ||
final aModel = MockBackedModel(); | ||
final aStore = InMemoryBackingStore(); | ||
|
||
when(aModel.backingStore).thenReturn(aStore); | ||
|
||
final bStore = InMemoryBackingStore(); | ||
|
||
expect(aStore.initializationCompleted, isTrue); | ||
expect(bStore.initializationCompleted, isTrue); | ||
|
||
bStore | ||
..set('aModel', aModel) | ||
..initializationCompleted = false; | ||
|
||
expect(aStore.initializationCompleted, isFalse); | ||
expect(bStore.initializationCompleted, isFalse); | ||
|
||
bStore.initializationCompleted = true; | ||
|
||
expect(aStore.initializationCompleted, isTrue); | ||
expect(bStore.initializationCompleted, isTrue); | ||
|
||
final cModel = MockBackedModel(); | ||
final cStore = InMemoryBackingStore(); | ||
when(cModel.backingStore).thenReturn(cStore); | ||
|
||
bStore.set('cModel', cModel); | ||
}); | ||
|
||
test('returns only changed values', () | ||
{ | ||
final store = InMemoryBackingStore() | ||
..set('name', 'Peter') | ||
..set('email', '[email protected]') | ||
..returnOnlyChangedValues = true; | ||
|
||
final changedEntries = store.iterate().toList(); | ||
expect(changedEntries, hasLength(0)); | ||
|
||
store.set('name', 'Wendy'); | ||
|
||
final changedEntries2 = store.iterate().toList(); | ||
expect(changedEntries2, hasLength(1)); | ||
}); | ||
}); | ||
} |