Example #1
0
            public async Task Should_return_empty_collection()
            {
                //Arrange
                string title          = "Expected Title";
                string titleToSearch  = "not existing";
                Video  expectedVideo0 = TestDataFactory.CreateVideo();

                expectedVideo0.Title = title;
                Video expectedVideo1 = TestDataFactory.CreateVideo();

                expectedVideo1.Title = title;
                List <Video> videos = new List <Video>(2)
                {
                    expectedVideo0,
                    expectedVideo1
                };

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

                //Act
                IEnumerable <Video> result = await RepoUnderTest.GetVideosContainTitleAsync(titleToSearch);

                //Assert
                Assert.Empty(result);
            }
Example #2
0
            public async Task Should_return_videos_with_specified_title()
            {
                //Arrange
                string expectedTitle = "Expected Title";
                string titleToSearch = "EXPected";

                Video expectedVideo0 = TestDataFactory.CreateVideo();

                expectedVideo0.Title = expectedTitle;
                Video expectedVideo1 = TestDataFactory.CreateVideo();

                expectedVideo1.Title = expectedTitle;
                List <Video> videos = new List <Video>(2)
                {
                    expectedVideo0,
                    expectedVideo1
                };

                GenData.RepeatCount = 3;
                GenData.AddManyTo(videos, () => TestDataFactory.CreateVideo());

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

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

                //Act
                IEnumerable <Video> result = await RepoUnderTest.GetVideosContainTitleAsync(titleToSearch);

                //Assert
                result.Should().BeEquivalentTo(expectedVideos, o =>
                                               o.Excluding(x => x.Kind)
                                               .Excluding(x => x.Genre));
            }