title: how to mock (awaitable) System.Threading.Tasks.Task<EMCResponse> in c#
body: <p>I am novice to C# and have been trying to mock an object of type <code>System.Threading.Tasks.Task&lt;EMCResponse&gt;</code> but could not succeed. Can anyone help me how to mock?  </p>
  
  <pre><code>public class PEProcessor : IPEProcessor
  {
      public PEProcessor(IService service)
      {
          _proxy = service;
          _emUpdate = new EMUpdate(service);
      }
  
  
      public void CreateAddress(string modelName, string version, string name, MType mType, Address address, EMRequest request)
      {
          var response = _proxy.EMCreateAsync(request); // should return object of type (awaitable) System.Threading.Tasks.Task&lt;EMCResponse&gt;
          address.Id = Convert.ToInt32(response.Result.CM[0].Code);
      }
  
  }
  </code></pre>
  
  <p>I am mocking as below</p>
  
  <pre><code>[Fact]
  public void RequestIsVerifiable()
  {
  
      //Arrange
      var wcfMock = new Mock&lt;IService&gt;();
  
      // wcfMock.Setup(x =&gt; x.EMCreateAsync(It.IsAny&lt;EMCreateRequest&gt;())).ReturnAsync(??);
  
      //Act
      var peProcessor = new PEProcessor(wcfMock.Object);
      peProcessor.CreateAddress(MoqData.ModelName, MoqData.version, MoqData.name,
          MoqData.MType, MoqData.AddressesList(), MoqData.EMRequest);
  
      //Assert
      wcfMock.Verify(service =&gt; service.EMCreateAsync(It.IsAny&lt;EMCreateRequest&gt;()), Times.AtLeastOnce);
  }
  </code></pre>
  
  <p>Thanks in advance!!</p>