NUnit testing of Async Task fails in C#
<p>I have the following class and the interface</p>

<pre><code>public interface IService
{
    Task&lt;double&gt; GetAccDetails(int personId);
}

public class Person
{
    private int _personId;
    private IService _service;

    public Person(int personId, IService service)
    {
        _personId= personId;
        _service = service;
    }

    public double Amount {get; set;}

    public async void UpdateBanckingAcc()
    {
        Amount = await _service.GetAccDetails(_personId);
    }
}
</code></pre>

<p>I am trying to write nunit test for it:</p>

<pre><code>[Test]
public async void Test1([Values(200)]int personId)
{
    const double expectedResult = 20;    
    var serviceMock = new Mock&lt;IAccountService&gt;();

    //Here I tried both options:
    //serviceMock.Setup(s =&gt;  s.GetAccDetails(It.Is&lt;int&gt;(id =&gt; id == personId)))
    //    .ReturnsAsync(() =&gt; expectedResult);
    //And:
    serviceMock.Setup(s=&gt;  s.GetAccDetails(It.Is&lt;int&gt;(id =&gt; id == personId)))
    .Returns(() =&gt; Task.FromResult&lt;double&gt;(personId));

    var person = new Person(personId, serviceMock.Object);

    person.UpdateBanckingAcc();

    double res = person.Amount;
    Assert.AreEqual(expectedResult, res);
}
</code></pre>

<p>And the test fails. For some strange reason I can not debug it.<br>
So the issue I see here is the call :  </p>

<pre><code>person.UpdateBanckingAcc();
</code></pre>

<p>it should be  </p>

<pre><code>await person.UpdateBanckingAcc();
</code></pre>

<p>but it does not like if I use <code>await</code> keyword.</p>

<p>Please advise.</p>

<p>Also one more question: is there something specific in terms of nunit testing for async methods I should test, like task status testing, etc?</p>