Just wondering, if anyone thought like this:
This is incorrect design to have async call within TestInitialize, as TestInitialize has to happen befo
Probably the cleanest way to do this is to have TestInitialize start the asynchronous operation, as such:
[TestClass]
public class UnitTestAsync
{
private Task val = null;
[TestInitialize]
public void TestInitializeMethod()
{
val = TestInitializeMethodAsync();
}
private async Task TestInitializeMethodAsync()
{
return await LongRunningMethod();
}
private async Task LongRunningMethod()
{
await Task.Delay(20);
return 10;
}
[TestMethod]
public async Task TestMehod2()
{
Assert.AreEqual(10, await val);
}
}