I am trying to test a method whose signature is of the form
public async Task<List<int>> MethodToBeTested()
I have written a unit test as follows
[TestMethod]
public async Task MethodToBeTestedSuccess()
{
Task<List<int>> results = await MethodToBeTested()
......
}
If the method's return type had been a generic List of integers I would have performed the following steps to test the output
List<int> results = MethodToBeTested();
int numberOfResults = results.Count;
Assert.AreEqual(numberOfResults,2300);
My question therefore is: how can I test the async method, whose return type is wrapped in a task, and validate that 2300 results have been returned?
If I try the strategy I attempted on the generic list of integers I get the error: cannot convert the method group Count to non-delegate type int.
Thanks in advance for any help.
Aucun commentaire:
Enregistrer un commentaire