public void GetAllAvailableGenre() { var genres = new List <Genre>().AsQueryable(); _genreRepository = A.Fake <IEntityRepository <Genre> >(); A.CallTo(() => _genreRepository.GetAll()).Returns(genres); var sut = new GenreServiceBuilder() .WithFakeGenreRepository(_genreRepository) .WithDefaultFakeValidator() .Build(); var result = sut.GetGenreDtos(); result.Should().NotBeNull(); }
public void ShouldCallRepositoryOnce() { var genres = new List <Genre>().AsQueryable(); _genreRepository = A.Fake <IEntityRepository <Genre> >(); A.CallTo(() => _genreRepository.GetAll()).Returns(genres); var sut = new GenreServiceBuilder() .WithFakeGenreRepository(_genreRepository) .WithDefaultFakeValidator() .Build(); var result = sut.GetGenreDtos(); A.CallTo(() => _genreRepository.GetAll()).MustHaveHappened(Repeated.Exactly.Once); }
public void WhenGetOneGenreFromRepo_ShouldReturnOneGenreDto() { var genres = _fixture.CreateMany <Genre>(1).ToList(); _genreRepository = A.Fake <IEntityRepository <Genre> >(); A.CallTo(() => _genreRepository.GetAll()).Returns(genres.AsQueryable()); _mapper = A.Fake <IMappingEngine>(); var sut = new GenreServiceBuilder() .WithFakeGenreRepository(_genreRepository) .WithDefaultFakeValidator() .WithDefaultFakeMapper() .Build(); IEnumerable <GenreDto> genreDtos = sut.GetGenreDtos(); genreDtos.Count().Should().Be(genres.Count); genreDtos.ShouldBeEquivalentTo(genres, option => option.ExcludingMissingProperties()); }
public void WhenGetGenreFromRepo_ShouldCallMapper() { var genres = _fixture.CreateMany <Genre>().ToList(); _genreRepository = A.Fake <IEntityRepository <Genre> >(); A.CallTo(() => _genreRepository.GetAll()).Returns(genres.AsQueryable()); _mapper = A.Fake <IMappingEngine>(); A.CallTo(() => _mapper.Map <Genre, GenreDto>(A <Genre> .Ignored)).Returns(A <GenreDto> .Ignored); var sut = new GenreServiceBuilder() .WithFakeGenreRepository(_genreRepository) .WithDefaultFakeValidator() .WithFakeMapper(_mapper) .Build(); IEnumerable <GenreDto> genreDtos = sut.GetGenreDtos(); foreach (var genre in genres) { A.CallTo(() => _mapper.Map <Genre, GenreDto>(genre)).MustHaveHappened(Repeated.Exactly.Once); } }
public void WhenGetOneGenreFromRepo_ShouldReturnOneGenreDto() { var genres = _fixture.CreateMany<Genre>(1).ToList(); _genreRepository = A.Fake<IEntityRepository<Genre>>(); A.CallTo(() => _genreRepository.GetAll()).Returns(genres.AsQueryable()); _mapper = A.Fake<IMappingEngine>(); var sut = new GenreServiceBuilder() .WithFakeGenreRepository(_genreRepository) .WithDefaultFakeValidator() .WithDefaultFakeMapper() .Build(); IEnumerable<GenreDto> genreDtos = sut.GetGenreDtos(); genreDtos.Count().Should().Be(genres.Count); genreDtos.ShouldBeEquivalentTo(genres, option => option.ExcludingMissingProperties()); }
public void WhenGetGenreFromRepo_ShouldCallMapper() { var genres = _fixture.CreateMany<Genre>().ToList(); _genreRepository = A.Fake<IEntityRepository<Genre>>(); A.CallTo(() => _genreRepository.GetAll()).Returns(genres.AsQueryable()); _mapper = A.Fake<IMappingEngine>(); A.CallTo(() => _mapper.Map<Genre, GenreDto>(A<Genre>.Ignored)).Returns(A<GenreDto>.Ignored); var sut = new GenreServiceBuilder() .WithFakeGenreRepository(_genreRepository) .WithDefaultFakeValidator() .WithFakeMapper(_mapper) .Build(); IEnumerable<GenreDto> genreDtos = sut.GetGenreDtos(); foreach (var genre in genres) { A.CallTo(() => _mapper.Map<Genre, GenreDto>(genre)).MustHaveHappened(Repeated.Exactly.Once); } }
public void ShouldCallRepositoryOnce() { var genres = new List<Genre>().AsQueryable(); _genreRepository = A.Fake<IEntityRepository<Genre>>(); A.CallTo(() => _genreRepository.GetAll()).Returns(genres); var sut = new GenreServiceBuilder() .WithFakeGenreRepository(_genreRepository) .WithDefaultFakeValidator() .Build(); var result = sut.GetGenreDtos(); A.CallTo(() => _genreRepository.GetAll()).MustHaveHappened(Repeated.Exactly.Once); }
public void GetAllAvailableGenre() { var genres = new List<Genre>().AsQueryable(); _genreRepository = A.Fake<IEntityRepository<Genre>>(); A.CallTo(() => _genreRepository.GetAll()).Returns(genres); var sut = new GenreServiceBuilder() .WithFakeGenreRepository(_genreRepository) .WithDefaultFakeValidator() .Build(); var result = sut.GetGenreDtos(); result.Should().NotBeNull(); }