コード例 #1
0
            public async Task Should_Call_Table()
            {
                // Given
                BaseStore <TestObjects> fixture = new BaseStoreFixture <TestObjects>();

                // When
                await fixture.GetItemsAsync(true);

                // Then
                fixture.Table.Received();
            }
コード例 #2
0
            public async Task Should_Call_Insert_Async()
            {
                // Given
                var table = Substitute.For <IMobileServiceSyncTable <TestObjects> >();
                BaseStore <TestObjects> fixture = new BaseStoreFixture <TestObjects>().WithSyncTable(table);

                // When
                await fixture.InsertAsync(new TestObjects());

                // Then
                await table.Received().InsertAsync(Arg.Any <TestObjects>());
            }
コード例 #3
0
            public async Task Should_Push_Sync_Context()
            {
                // Given
                var storageService = Substitute.For <IStoreService>();
                BaseStore <TestObjects> fixture = new BaseStoreFixture <TestObjects>().WithStorageService(storageService);

                // When
                await fixture.RemoveOnlineAsync(new TestObjects());

                // Then
                await storageService.SyncContext.Received().PushAsync(CancellationToken.None);
            }
コード例 #4
0
            public async Task Should_Call_Delete_Async()
            {
                // Given
                var table = Substitute.For <IMobileServiceTable <TestObjects> >();
                BaseStore <TestObjects> fixture = new BaseStoreFixture <TestObjects>().WithTable(table);

                // When
                await fixture.RemoveOnlineAsync(new TestObjects());

                // Then
                await table.Received().DeleteAsync(Arg.Any <TestObjects>());
            }
コード例 #5
0
            public async Task Should_Call_Initialize()
            {
                // Given
                var storageService = Substitute.For <IStoreService>();
                BaseStore <TestObjects> fixture = new BaseStoreFixture <TestObjects>().WithStorageService(storageService);

                // When
                await fixture.InitializeStore();

                // Then
                await storageService.Received().InitializeAsync();
            }
コード例 #6
0
            public async Task Should_Call_Get_Sync_Table()
            {
                // Given
                var storeService = Substitute.For <IStoreService>();
                BaseStore <TestObjects> fixture = new BaseStoreFixture <TestObjects>().WithStorageService(storeService);

                // When
                await fixture.GetItemsAsync();

                // Then
                storeService.Received().GetSyncTable <TestObjects>();
            }
コード例 #7
0
            public async Task Should_Not_Throw_If_Store_Not_Initialized()
            {
                // Given
                var storageService = Substitute.For <IStoreService>();

                storageService.IsInitialized.Returns(false);
                BaseStore <TestObjects> fixture = new BaseStoreFixture <TestObjects>().WithStorageService(storageService);

                // When
                var result = await Record.ExceptionAsync(async() => await fixture.InitializeStore());

                // Then
                result.Should().BeNull();
            }
コード例 #8
0
            public async Task Should_Call_Pull_Async()
            {
                // Given
                var table = Substitute.For <IMobileServiceSyncTable <TestObjects> >();
                BaseStore <TestObjects> fixture = new BaseStoreFixture <TestObjects>().WithSyncTable(table);

                // When
                await fixture.InsertAsync(new TestObjects());

                // Then
                await table.Received().PullAsync(Arg.Any <string>(),
                                                 Arg.Any <IMobileServiceTableQuery <TestObjects> >(),
                                                 true,
                                                 Arg.Any <CancellationToken>(),
                                                 Arg.Any <PullOptions>());
            }
コード例 #9
0
            public async Task Should_Not_Call_Pull_Async()
            {
                // Given
                var table = Substitute.For <IMobileServiceSyncTable <TestObjects> >();
                BaseStore <TestObjects> fixture = new BaseStoreFixture <TestObjects>().WithSyncTable(table);

                // When
                await fixture.GetItemsAsync();

                // Then
                await table.DidNotReceive().PullAsync(Arg.Any <string>(),
                                                      Arg.Any <IMobileServiceTableQuery <TestObjects> >(),
                                                      Arg.Any <bool>(),
                                                      CancellationToken.None,
                                                      Arg.Any <PullOptions>());
            }