public async Task Should_not_return_inactive_videos() { //Arrange Kind expectedKind = TestDataFactory.CreateKind(); List <Video> videos = new List <Video>() { TestDataFactory.CreateVideo(expectedKind), TestDataFactory.CreateVideo(expectedKind), }; GenData.RepeatCount = 1; GenData.AddManyTo(videos, TestDataFactory.CreateVideo); videos.First().IsInactive = true; using (VODContext context = ContextFactory.CreateContext()) { context.Videos.AddRange(videos); context.SaveChanges(); } //Act IEnumerable <Video> result = await RepoUnderTest.GetVideosByKindIdAsync(expectedKind.Id); //Assert result.Any(x => x.IsInactive).Should().BeFalse(); }
public async Task Should_return_the_videos_with_specified_kind() { //Arrange Kind expectedKind = TestDataFactory.CreateKind(); List <Video> videos = new List <Video>() { TestDataFactory.CreateVideo(expectedKind), TestDataFactory.CreateVideo(expectedKind), }; GenData.RepeatCount = 1; 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.GetVideosByKindIdAsync(expectedKind.Id); //Assert result.Should().BeEquivalentTo(expectedVideos, o => o.Excluding(x => x.Kind) .Excluding(x => x.Genre)); }
public async Task Should_return_empty_kind_does_not_exist() { //Arrange GenData.RepeatCount = 3; List <Video> expectedVideos = new List <Video>(GenData.RepeatCount); GenData.AddManyTo(expectedVideos, TestDataFactory.CreateVideo); using (VODContext context = ContextFactory.CreateContext()) { context.Videos.AddRange(expectedVideos); context.SaveChanges(); } //Act IEnumerable <Video> result = await RepoUnderTest.GetVideosByKindIdAsync(Guid.NewGuid()); //Assert Assert.Empty(result); }
public async Task Should_return_all_genres() { //Arrange GenData.RepeatCount = 3; List <Genre> expectedGenres = new List <Genre>(GenData.RepeatCount); GenData.AddManyTo(expectedGenres, TestDataFactory.CreateGenre); using (VODContext context = ContextFactory.CreateContext()) { context.Genres.AddRange(expectedGenres); context.SaveChanges(); } //Act IEnumerable <Genre> result = await RepoUnderTest.GetAsync(); //Assert result.Should().BeEquivalentTo(expectedGenres); }
public async Task Should_return_all_videos() { //Arrange GenData.RepeatCount = 3; List <Video> expectedVideos = new List <Video>(GenData.RepeatCount); GenData.AddManyTo(expectedVideos, TestDataFactory.CreateVideo); using (VODContext context = ContextFactory.CreateContext()) { context.Videos.AddRange(expectedVideos); context.SaveChanges(); } //Act IEnumerable <Video> result = await RepoUnderTest.GetAsync(); //Assert result.Should().BeEquivalentTo(expectedVideos, o => o.Excluding(x => x.Kind) .Excluding(x => x.Genre)); }
public async Task Should_return_empty_collection() { //Arrange Genre notIncludedGenre = TestDataFactory.CreateGenre(); 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.Genres.Add(notIncludedGenre); context.SaveChanges(); } //Act IEnumerable <Video> result = await RepoUnderTest.GetVideosByGenreIdAsync(notIncludedGenre.Id); //Assert Assert.Empty(result); }
public async Task Should_not_return_inactive_videos() { //Arrange GenData.RepeatCount = 3; List <Video> videos = new List <Video>(GenData.RepeatCount); GenData.AddManyTo(videos, TestDataFactory.CreateVideo); videos.Last().IsInactive = true; using (VODContext context = ContextFactory.CreateContext()) { context.Videos.AddRange(videos); context.SaveChanges(); } List <Video> expectedVideos = videos.Take(2).ToList(); //Act IEnumerable <Video> result = await RepoUnderTest.GetAsync(); //Assert result.Any(x => x.IsInactive).Should().BeFalse(); }
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)); }