如何测试return await _propertyRepository.UnitOfWork.SaveEntitiesAsync();
?
public async Task<bool> Handle(AddCommand message, CancellationToken cancellationToken)
{
_logger.LogInformation("----- Adding Property - Property: {@Property}", property);
_propertyRepository.Add(property);
return await _propertyRepository.UnitOfWork.SaveEntitiesAsync();
}
任何人都请引导我为此编写测试用例。我这样写。但是测试用例失败。
public class PropertyRepository : IPropertyRepository
{
private readonly RealxContext _realxContext;
public IUnitOfWork UnitOfWork
{
get
{
return _realxContext;
}
}
public PropertyRepository(RealxContext realxContext)
{
_realxContext = realxContext ?? throw new ArgumentNullException(nameof(realxContext));
}
_propertyRepository.Setup(propertyRepo => propertyRepo.UnitOfWork.SaveEntitiesAsync(default(CancellationToken))).Returns(Task.FromResult(true));