public void ShouldAddAlreadyExistElementInsteadOfNew() { //Arange ICollection <Genres> initial = new List <Genres>(); ICollection <Genres> newColl = new List <Genres>(); Genres genreToTest = new Genres() { Name = "TestGenre", Id = Guid.NewGuid() }; newColl.Add(genreToTest); ICollection <Genres> exist = new List <Genres>(); Genres existGenre = new Genres() { Name = "TestGenre", Id = Guid.NewGuid() }; exist.Add(existGenre); this.genresRepo.Setup(x => x.AllNotDeleted()).Returns(exist.AsQueryable()); StubClass sut = new StubClass(movies.Object, genresRepo.Object, commentsRepo.Object, userRepo.Object, likesRepo.Object, dislikesRepo.Object, saver.Object); //Act sut.UpdateGenresCollection(initial, newColl); //Assert Assert.IsTrue(initial.Select(x => x.Id).Contains(existGenre.Id)); }
public void ShouldAddNewElemetnsToInitialIfDoesntAlreadyExist() { //Arange ICollection <Genres> initial = new List <Genres>(); ICollection <Genres> newColl = new List <Genres>(); Genres genreToTest = new Genres() { Name = "TestGenre" }; newColl.Add(genreToTest); this.genresRepo.Setup(x => x.AllNotDeleted()).Returns(new List <Genres>().AsQueryable()); StubClass sut = new StubClass(movies.Object, genresRepo.Object, commentsRepo.Object, userRepo.Object, likesRepo.Object, dislikesRepo.Object, saver.Object); //Act sut.UpdateGenresCollection(initial, newColl); //Assert Assert.IsTrue(initial.Contains(genreToTest)); }