public void future_items_ticks_any_items_removed_after_the_subscription() { var repository = new RepositoryMock <int, TestEntity>(MockBehavior.Loose); repository .When(x => x.GetAll()) .Return(ImmutableList <TestEntity> .Empty); repository .When(x => x.Get(42)) .Return(new TestEntity { Id = 42 }); var sut = new AsyncRepositoryBuilder() .WithDataStoreScheduler(ImmediateScheduler.Instance) .WithRepository(repository) .Build(); var futureItems = new List <ItemChange <TestEntity> >(); sut .FutureItems .Subscribe(futureItems.Add); Assert.Empty(futureItems); sut .Delete(42) .Subscribe(); Assert.Single(futureItems); Assert.Equal(ItemChangeType.Remove, futureItems[0].Type); }
public void delete_all_deletes_all_entities_on_provided_scheduler() { var scheduler = new TestScheduler(); var repository = new RepositoryMock <int, TestEntity>(MockBehavior.Loose); repository .When(x => x.Get(42)) .Return(new TestEntity()); var sut = new AsyncRepositoryBuilder() .WithDataStoreScheduler(scheduler) .WithRepository(repository) .Build(); sut .DeleteAll() .Subscribe(); repository .Verify(x => x.DeleteAll()) .WasNotCalled(); scheduler.AdvanceMinimal(); repository .Verify(x => x.DeleteAll()) .WasCalledExactlyOnce(); }
public void items_retrieves_entities_on_provided_scheduler() { var scheduler = new TestScheduler(); var repository = new RepositoryMock <int, TestEntity>(MockBehavior.Loose); repository .When(x => x.GetAll()) .Return(ImmutableList <TestEntity> .Empty); var sut = new AsyncRepositoryBuilder() .WithDataStoreScheduler(scheduler) .WithRepository(repository) .Build(); sut .Items .Subscribe(); repository .Verify(x => x.GetAll()) .WasNotCalled(); scheduler.AdvanceMinimal(); repository .Verify(x => x.GetAll()) .WasCalledExactlyOnce(); }