コード例 #1
0
            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();
            }
コード例 #2
0
            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);
            }
コード例 #3
0
            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());
            }
コード例 #4
0
            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);
                }
            }
コード例 #5
0
            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());
            }
コード例 #6
0
            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);
                }
            }
コード例 #7
0
            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);
            }
コード例 #8
0
            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();
            }