Example #1
0
        public async Task AddVideo_should_return_the_expected_video(string kindId, string genreId)
        {
            //Arrange
            string data = GenData.Create <string>();

            AddVideoRequest expectedVideo = new AddVideoRequest()
            {
                AltTitle    = data,
                Description = data,
                Duration    = 123,
                Episode     = 7,
                ReleaseYear = DateTime.Now,
                Season      = 1,
                Title       = data,
                KindId      = new Guid(kindId),
                GenreId     = new Guid(genreId)
            };

            VideoService sut = new VideoService(Repository, Mapper);

            //Act
            VideoResponse result = await sut.AddVideoAsync(expectedVideo);

            //Assert
            result.Should().BeEquivalentTo(expectedVideo);
        }
Example #2
0
        public async Task RemoveVideoById()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: "VideoRemoveById_Database")
                          .Options;
            var dbContext    = new ApplicationDbContext(options);
            var videoService = new VideoService(dbContext);

            await videoService.AddVideoAsync("https://www.youtube.com/watch?v=mjrOA8Qe38k", "TE AMO1", "COVER BY GABBY G1", "asdf1");

            await videoService.AddVideoAsync("https://www.youtube.com/watch?v=mjrOA8Qe38k", "TE AMO2", "COVER BY GABBY G2", "asdf2");

            await videoService.AddVideoAsync("https://www.youtube.com/watch?v=mjrOA8Qe38k", "TE AMO3", "COVER BY GABBY G3", "asdf3");

            await videoService.RemoveVideoByIdAsync(1);

            var videoCount = await dbContext.Videos.CountAsync();

            Assert.Equal(2, videoCount);
        }
Example #3
0
        public async Task AllVideosBySearch()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: "AllVideosBySearch_Database")
                          .Options;
            var dbContext    = new ApplicationDbContext(options);
            var videoService = new VideoService(dbContext);

            await videoService.AddVideoAsync("https://www.youtube.com/watch?v=mjrOA8Qe38k", "TE AMO1", "COVER BY GABBY G1", "asdf1");

            await videoService.AddVideoAsync("https://www.youtube.com/watch?v=mjrOA8Qe38k", "TE AMO2", "COVER BY GABBY G2", "asdf2");

            var videoCount = await videoService.VideosBySearch("TE AMO1").AllVideos.CountAsync();

            var video = videoService.VideosBySearch("TE AMO1").AllVideos.ToList().First();

            Assert.Equal("https://www.youtube.com/watch?v=mjrOA8Qe38k", video.Link);
            Assert.Equal("TE AMO1", video.Title);
            Assert.Equal("COVER BY GABBY G1", video.Description);
            Assert.Equal(1, videoCount);
        }