Exemple #1
0
            public async Task Should_not_return_inactive_videos()
            {
                //Arrange
                Genre expectedGenre = TestDataFactory.CreateGenre();
                Genre genre         = TestDataFactory.CreateGenre();

                List <Video> videos = new List <Video>()
                {
                    TestDataFactory.CreateVideo(TestDataFactory.CreateKind(), expectedGenre),
                    TestDataFactory.CreateVideo(TestDataFactory.CreateKind(), expectedGenre),
                    TestDataFactory.CreateVideo(TestDataFactory.CreateKind(), genre)
                };

                videos.First().IsInactive = true;

                using (VODContext context = ContextFactory.CreateContext())
                {
                    context.Videos.AddRange(videos);
                    context.SaveChanges();
                }

                //Act
                IEnumerable <Video> result = await RepoUnderTest.GetVideosByGenreIdAsync(expectedGenre.Id);

                //Assert
                result.Any(x => x.IsInactive).Should().BeFalse();
            }
Exemple #2
0
            public async Task Should_return_the_videos_with_specified_genre()
            {
                //Arrange
                Genre expectedGenre = TestDataFactory.CreateGenre();
                Genre genre         = TestDataFactory.CreateGenre();

                List <Video> videos = new List <Video>()
                {
                    TestDataFactory.CreateVideo(TestDataFactory.CreateKind(), expectedGenre),
                    TestDataFactory.CreateVideo(TestDataFactory.CreateKind(), expectedGenre),
                    TestDataFactory.CreateVideo(TestDataFactory.CreateKind(), genre)
                };

                using (VODContext context = ContextFactory.CreateContext())
                {
                    context.Videos.AddRange(videos);
                    context.SaveChanges();
                }

                List <Video> expectedVideos = videos.Take(2).ToList();

                //Act
                IEnumerable <Video> result = await RepoUnderTest.GetVideosByGenreIdAsync(expectedGenre.Id);

                //Assert
                result.Should().BeEquivalentTo(expectedVideos, o =>
                                               o.Excluding(x => x.Kind)
                                               .Excluding(x => x.Genre));
            }
Exemple #3
0
            public async Task Should_return_empty_collection_genre_does_not_exist()
            {
                //Arrange
                GenData.RepeatCount = 3;
                List <Video> videos = new List <Video>(GenData.RepeatCount);

                GenData.AddManyTo(videos, TestDataFactory.CreateVideo);

                using (VODContext context = ContextFactory.CreateContext())
                {
                    context.Videos.AddRange(videos);
                    context.SaveChanges();
                }

                //Act
                IEnumerable <Video> result = await RepoUnderTest.GetVideosByGenreIdAsync(Guid.NewGuid());

                //Assert
                Assert.Empty(result);
            }