public void AddGenres_ShouldCallRepositoryAddMethod_WhenValidParametersPassed() { var genreRepositoryMock = new Mock <IRepository <Genre> >(); var unitOfWorkMock = new Mock <IUnitOfWork>(); var genreFactoryMock = new Mock <IGenreFactory>(); var genreService = new GenreService( genreRepositoryMock.Object, unitOfWorkMock.Object, genreFactoryMock.Object); var genres = new List <Genre>() { new Genre("Comedy"), new Genre("Adventure") }; genreService.AddGenres(genres); genreRepositoryMock.Verify(r => r.Add(It.IsAny <Genre>()), Times.Exactly(genres.Count)); }
public void AddGenres_ShouldCallUnitOfWorkCommitMethod_WhenValidParametersPassed() { var genreRepositoryMock = new Mock <IRepository <Genre> >(); var unitOfWorkMock = new Mock <IUnitOfWork>(); var genreFactoryMock = new Mock <IGenreFactory>(); var genreService = new GenreService( genreRepositoryMock.Object, unitOfWorkMock.Object, genreFactoryMock.Object); var genres = new List <Genre>() { new Genre("Comedy"), new Genre("Adventure") }; genreService.AddGenres(genres); unitOfWorkMock.Verify(n => n.Commit(), Times.Once); }