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); }
public void DeleteCalendar_ShouldRemoveFromSeries() { var seriesRepository = new SeriesRepository(); var deletedCalendar = CreateAndRetrieveCalendar(); var notDeletedCalendar = CreateAndRetrieveCalendar(); var seriesId = seriesRepository.CreateSeries(new CreateSeriesDto("", "", -1, "", -1, testLibrary.LibraryId, deletedCalendar.CalendarId)); var series2Id = seriesRepository.CreateSeries(new CreateSeriesDto("", "", -1, "", -1, testLibrary.LibraryId, notDeletedCalendar.CalendarId)); repository.DeleteCalendar(deletedCalendar.CalendarId); var series = seriesRepository.GetSeries(seriesId).Result; var series2 = seriesRepository.GetSeries(series2Id).Result; Assert.AreEqual(DatabaseConstants.DEFAULT_ID, series.CalendarId); Assert.AreEqual(notDeletedCalendar.CalendarId, series2.CalendarId); }
public void GetLastWatchedVideoInSeries_WithNoWatchedVideos_ShouldBeNull() { 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 videoId = repository.CreateVideo(dto); var lastWatchedVideo = repository.GetLastWatchedVideoInSeries(seriesId).Result; Assert.AreEqual(null, lastWatchedVideo); }
public long CreateSeries(CreateSeriesDto dto) { return(seriesRepository.CreateSeries(dto)); }
private Series CreateAndRetrieveSeries(CreateSeriesDto dto) { var id = repository.CreateSeries(dto); return(repository.GetSeries(id).Result); }