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_empty_collection() { //Arrange Kind kindWithoutVideos = TestDataFactory.CreateKind(); Kind kind = TestDataFactory.CreateKind(); List <Video> videos = new List <Video>() { TestDataFactory.CreateVideo(kind), TestDataFactory.CreateVideo(kind) }; using (VODContext context = ContextFactory.CreateContext()) { context.Videos.AddRange(videos); context.Kinds.Add(kindWithoutVideos); context.SaveChanges(); } //Act IEnumerable <Video> result = await RepoUnderTest.GetVideosByKindIdAsync(kindWithoutVideos.Id); //Assert Assert.Empty(result); }