private void Arrange(VideoDetailsItem localStoreItem, VideoDetailsItem externalStoreItem) { A.CallTo(() => _localStoreReader.GetVideoDetailsItem(A <int> ._)) .Returns(Observable.Return(localStoreItem)); A.CallTo(() => _externalStoreReader.GetVideoDetailsItem(A <int> ._)) .Returns(Observable.Return(externalStoreItem)); }
public IObservable <Unit> PersistVideoDetailsItem(VideoDetailsItem item) { if (item.Id == 0) { _context.VideoDetailsItems.Add(item); } else { _context.VideoDetailsItems.Update(item); } return(_context.SaveChangesAsync().ToObservable().Select(_ => Unit.Default)); }
public void Persists_all_data_from_externalReader() { var local = (VideoDetailsItem)null; var external = new VideoDetailsItem() { Id = 100, Title = "Title1" }; Arrange(local, external); var result = Act(1).Wait(); A.CallTo(() => _localStoreWriter.PersistVideoDetailsItem(external)).MustHaveHappened(); }
public void Returns_all_data_from_externalReader_when_localReader_empty() { var local = (VideoDetailsItem)null; var external = new VideoDetailsItem() { Id = 100, Title = "Title1" }; Arrange(local, external); var result = Act(1).Wait(); AssertFetch(result, external); }
public void Returns_all_data_from_localReader_and_ignores_externalReader() { var local = new VideoDetailsItem() { Id = 1, Title = "Title1" }; var external = new VideoDetailsItem() { Id = 100, Title = "Title1" }; Arrange(local, external); var result = Act(1).Wait(); AssertFetch(result, local); A.CallTo(() => _externalStoreReader.GetVideoDetailsItem(A <int> ._)).MustNotHaveHappened(); }
public MapperConfiguration() { Mapper.AddMap <VideoInfo, VideoItem>(src => { var dst = new VideoItem(); dst.InjectFrom(src); dst.Description = src.Overview; dst.Genre = string.Join(", ", src.GenreIds.Cast <Genre>()); return(dst); }); Mapper.AddMap <VideoDetailsInfo, VideoDetailsItem>(src => { var dst = new VideoDetailsItem(); dst.InjectFrom(src); dst.Description = src.Overview; dst.Genre = string.Join(", ", src.Genres); return(dst); }); }
private void AssertFetch(VideoDetailsItem results, VideoDetailsItem expected) { Assert.Equal(results.Title, expected.Title); Assert.Equal(results.Id, expected.Id); }