Ejemplo n.º 1
0
        public void GetLastWatchedVideoInSeries_WithWatchedVideos_ShouldReturnLast()
        {
            var seriesRepository = new SeriesRepository();
            var seriesId         = seriesRepository.CreateSeries(new CreateSeriesDto("test", "", -1, "", -1, testLibrary.LibraryId));
            var series           = seriesRepository.GetSeries(seriesId).Result;

            var dto      = GetNewVideoDetails(series);
            var video1Id = repository.CreateVideo(dto);

            var video2Id = repository.CreateVideo(dto);
            var video2   = repository.GetVideo(video2Id).Result;

            var sequenceRepository = new SeriesSequenceRepository();
            var sequenceId         = sequenceRepository.CreateVideoSequence(new CreateSeriesSequenceDto(series.SeriesId, "", "", -1, true, 1));

            sequenceRepository.AddVideosToSequence(new List <long> {
                video1Id, video2Id
            }, sequenceId);

            var historyRepository = new WatchHistoryRepository();

            historyRepository.AddWatchedVideo(video1Id).ConfigureAwait(false);
            historyRepository.AddWatchedVideo(video2Id).ConfigureAwait(false);

            var lastWatchedVideo = repository.GetLastWatchedVideoInSeries(seriesId).Result;

            Assert.AreEqual(video2, lastWatchedVideo);
        }