Это одна из тех спецификаций, которые я создал:
Код: Выделить всё
public sealed class SomeSpecification: Specification
{
public SomeSpecification(Guid someSubEntityID)
{
Query
.Include(p => p.SomeSubEntity)
.Where(p => p.SomeSubEntity.Id == someSubEntityID)
.Include(p => p.SomeOtherSubEntity)
.OrderBy(p => p.SomeProperty);
}
}
Я могу сделать что-то вроде этого, когда метод просто возвращает определенную коллекцию, которую я сохраняю в классе EntityConstants, когда передается какая-либо SomeSpecification:
Код: Выделить всё
_pfRepoMock.ListAsync(
Arg.Any(), Arg.Any())
.Returns(Task.FromResult(EntityConstants.SomeEntityCollection()));
Код: Выделить всё
_pfRepoMock.ListAsync(
Arg.Any().ConstructedWith(EntityConstants.SomeID), Arg.Any())
.Returns(Task.FromResult(EntityConstants.SomeEntityCollection()));
_pfRepoMock.ListAsync(
Arg.Any().ConstructedWith(EntityConstants.SomeOtherID), Arg.Any())
.Returns(Task.FromResult(EntityConstants.SomeDifferentEntityCollection()));
Как я могу этого добиться?>
Подробнее здесь: https://stackoverflow.com/questions/798 ... -parameter
Мобильная версия