I have an ASP.NET Web API application, with an ApiController that features asynchronous methods, returning Task<> objects and marked with the async<
It seems to me there is no support built into NUnit 2.6 for testing async methods returning Tasks. The best option I can see right now is to use Visual Studio's own UnitTesting framework or xUnit.net as both support asynchronous tests.
With the Visual Studio UnitTesting framework I can write asynchronous tests like this:
using Microsoft.VisualStudio.TestTools.UnitTesting;
[TestClass]
public class TestAsyncMethods
{
[TestMethod]
public async Task TestGetBinBuildById()
{
...
var rslt = await obj.GetAsync();
Assert.AreEqual(rslt, expected);
}
}