相关疑难解决方法(0)

Moq与任务等待

由于我已将我的WCF方法转换为Async,因此我的单元测试失败了,我无法找出正确的语法来使它们工作.

Cllient代理类

 public interface IClientProxy
{
     Task DoSomething(CredentialDataList credentialData, string store);
}
Run Code Online (Sandbox Code Playgroud)

服务类

  public class CredentialSync : ICredentialSync
{
    private ICredentialRepository _repository;

    private IClientProxy _client;

    public CredentialSync()
    {
        this._repository = new CredentialRepository();
        this._client = new ClientProxy();
    }

    public CredentialSync(ICredentialRepository repository, IClientProxy client)
    {
        this._repository = repository;
        this._client = client;
    }

   public async Task Synchronise(string payrollNumber)
    {
        try
        {
            if (string.IsNullOrEmpty(payrollNumber))
            {
                .... some code
              }
            else
            {
                CredentialDataList credentialData = new CredentialDataList();
                List<CredentialData> credentialList = new List<CredentialData>();

                // fetch the …
Run Code Online (Sandbox Code Playgroud)

.net c# asynchronous moq async-await

44
推荐指数
3
解决办法
3万
查看次数

标签 统计

.net ×1

async-await ×1

asynchronous ×1

c# ×1

moq ×1