本文整理汇总了C#中IEntityRepository.GetAll方法的典型用法代码示例。如果您正苦于以下问题:C# IEntityRepository.GetAll方法的具体用法?C# IEntityRepository.GetAll怎么用?C# IEntityRepository.GetAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEntityRepository
的用法示例。
在下文中一共展示了IEntityRepository.GetAll方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WhenGetOneGenreFromRepo_ShouldReturnOneGenreDto
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());
}
示例2: WhenGetGenreFromRepo_ShouldCallMapper
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);
}
}
示例3: GetAllAvailableGenre
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();
}
示例4: ShouldCallRepositoryOnce
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);
}
示例5: GetFirstRestaurant
public Restaurant GetFirstRestaurant()
{
_restaurantRepository = new EfEntityRepository<Restaurant>(); // nécessaire pour avoir le dernier "context".
return _restaurantRepository.GetAll().First();
}