Exemplo n.º 1
0
 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));
 }
Exemplo n.º 2
0
 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));
 }
Exemplo n.º 3
0
        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();
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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);
            });
        }
Exemplo n.º 7
0
 private void AssertFetch(VideoDetailsItem results, VideoDetailsItem expected)
 {
     Assert.Equal(results.Title, expected.Title);
     Assert.Equal(results.Id, expected.Id);
 }