Exemplo n.º 1
0
        private Video CreateVideo()
        {
            var dto     = CreateVideoUtil.GetNewVideoDetails(testLibrary.LibraryId, -1, -1);
            var videoId = videoRepository.CreateVideo(dto);

            return(videoRepository.GetVideo(videoId).Result);
        }
Exemplo n.º 2
0
        public void GetPercentageOfVideosWatchedInSequence_WithVideosInSpecifiedSequence()
        {
            var videoRepository = new VideoRepository();
            var sequence1       = CreateAndRetrievePlaylist();
            var sequence2       = CreateAndRetrievePlaylist();

            var videoDto = CreateVideoUtil.GetNewVideoDetails(testLibrary.LibraryId, -1, -1);

            videoDto.TimesWatched = 1;
            var videoId = videoRepository.CreateVideo(videoDto);

            repository.AddVideoToSequence(videoId, sequence1.SequenceId);

            videoDto = CreateVideoUtil.GetNewVideoDetails(testLibrary.LibraryId, -1, -1);
            videoId  = videoRepository.CreateVideo(videoDto);
            repository.AddVideoToSequence(videoId, sequence1.SequenceId);

            videoDto = CreateVideoUtil.GetNewVideoDetails(testLibrary.LibraryId, -1, -1);
            videoDto.TimesWatched = 1;
            videoId = videoRepository.CreateVideo(videoDto);
            repository.AddVideoToSequence(videoId, sequence2.SequenceId);

            var percentWatched = repository.GetPercentageOfVideosWatchedInSequence(sequence1.SequenceId);

            Assert.AreEqual(50, percentWatched);
        }
        private Video CreateAndRetrieveVideo(long libraryId, long seriesId)
        {
            var dto     = CreateVideoUtil.GetNewVideoDetails(libraryId, -1, seriesId);
            var videoId = videoRepository.CreateVideo(dto);

            return(videoRepository.GetVideo(videoId).Result);
        }
Exemplo n.º 4
0
        public void GetAllPlaylistsContainingVideo_WithPlaylistContainingDifferentVideo()
        {
            var videoRepo = new VideoRepository();
            var videoDto  = CreateVideoUtil.GetNewVideoDetails(testLibrary.LibraryId, -1, -1);
            var videoId   = videoRepo.CreateVideo(videoDto);

            var otherVideoId = videoRepo.CreateVideo(videoDto);

            for (int i = 0; i < 1; ++i)
            {
                var sequence = CreateAndRetrievePlaylist();
                repository.AddVideoToSequence(otherVideoId, sequence.SequenceId);
            }

            var sequences = repository.GetAllPlaylistsContainingVideo(videoId);

            CollectionAssert.AreEquivalent(new List <PlaylistDto>(), sequences);
        }
Exemplo n.º 5
0
        //Post Manager
        public static async Task <List <VideoFeeds> > CreateVideo(VideoFeeds video)
        {
            using (VideoRepository rep = new VideoRepository())
            {
                var response = await rep.CreateVideo(video);

                return(response);
            }
        }
Exemplo n.º 6
0
        public void GetSeriesToWatchInLibrary_WithNotStartedSeriesToWatch()
        {
            var videoRepository = new VideoRepository();

            var seriesToCreate = new CreateSeriesDto("Test library", "https://ingvilt.test.url", -1, "test desc", -1, testLibrary.LibraryId, -1, true);
            var seriesId       = repository.CreateSeries(seriesToCreate);

            var videoToCreate = CreateVideoUtil.GetNewVideoDetails(testLibrary.LibraryId, -1, seriesId);

            videoRepository.CreateVideo(videoToCreate);
            videoRepository.CreateVideo(videoToCreate);

            var expectedSeries = new List <Series> {
                repository.GetSeries(seriesId).Result
            };
            var actualSeries = repository.GetSeriesToWatchInLibrary(GetFirstPage(), testLibrary.LibraryId, "").Result.Results;

            CollectionAssert.AreEquivalent(expectedSeries, actualSeries);
        }
Exemplo n.º 7
0
        public void GetSeriesToWatchInLibrary_ShouldntIncludeSeriesNotWorthWatching()
        {
            var videoRepository = new VideoRepository();

            var seriesToCreate = new CreateSeriesDto("Test library", "https://ingvilt.test.url", -1, "test desc", -1, testLibrary.LibraryId, -1, false);
            var seriesId       = repository.CreateSeries(seriesToCreate);

            var videoToCreate = CreateVideoUtil.GetNewVideoDetails(testLibrary.LibraryId, -1, seriesId);

            videoRepository.CreateVideo(videoToCreate);
            videoToCreate.TimesWatched = 5;
            videoRepository.CreateVideo(videoToCreate);

            var expectedSeries = new List <Series> {
            };
            var actualSeries   = repository.GetSeriesToWatchInLibrary(GetFirstPage(), testLibrary.LibraryId, "").Result.Results;

            CollectionAssert.AreEquivalent(expectedSeries, actualSeries);
        }
Exemplo n.º 8
0
        public void GetAllPlaylistsContainingVideo_WithPlaylistsContainingVideo()
        {
            var expectedPlaylists = new List <PlaylistDto>();
            var videoRepository   = new VideoRepository();
            var videoDto          = CreateVideoUtil.GetNewVideoDetails(testLibrary.LibraryId, -1, -1);
            var videoId           = videoRepository.CreateVideo(videoDto);

            for (int i = 0; i < 2; ++i)
            {
                var sequence = CreateAndRetrievePlaylist();
                expectedPlaylists.Add(sequence);
                repository.AddVideoToSequence(videoId, sequence.SequenceId);
            }

            var sequences = repository.GetAllPlaylistsContainingVideo(videoId);

            CollectionAssert.AreEquivalent(expectedPlaylists, sequences);
        }
Exemplo n.º 9
0
        private Video CreateAndRetrieveVideo(CreateVideoDto dto)
        {
            var id = repository.CreateVideo(dto);

            return(repository.GetVideo(id).Result);
        }
Exemplo n.º 10
0
        private long GetNewVideoId()
        {
            var dto = CreateVideoUtil.GetNewVideoDetails(library.LibraryId, -1, -1);

            return(videoRepository.CreateVideo(dto));
        }
Exemplo n.º 11
0
        public void GetNumberOfFinishedSeriesInLibrary_WithDeletedSeries()
        {
            var activeSeries   = CreateAndRetrieveSeries();
            var createVideoDto = CreateVideoUtil.GetNewVideoDetails(testLibrary.LibraryId, -1, activeSeries.SeriesId);

            createVideoDto.TimesWatched = 1;
            videoRepository.CreateVideo(createVideoDto);

            var deletedSeries = CreateAndRetrieveSeries();

            repository.DeleteSeries(deletedSeries.SeriesId).ConfigureAwait(false);

            var librariesCount = repository.GetNumberOfFinishedSeriesInLibrary(testLibrary.LibraryId).Result;

            Assert.AreEqual(1, librariesCount);
        }