I have an asynchronous function:
// In a class called DBUtil
public async Task<bool> UpdateRecord(Guid recordId) {
await recordObj = recordService.Get(recordId);
await Task.WhenAll(recordService.UpdateRecord(recordId), adminService.NotifyAdmins(recordObj));
return true;
}
I created a unit test that is supposed to test if calling UpdateRecord()
also called recordService.UpdateRecord()
and adminService.NotifyAdmins()
like:
[TestMethod]
public async Task UpdateRecordWillUpdateAndNotifyAdmins() {
...
await DBUtil.UpdateRecord(record.Id);
recordService.AssertWasCalled(f => f.UpdateRecord(record.Id));
adminService..AssertWasCalled(f => f.NotifyAdmins(record));
}
However, it doesn't seem to call the functions. I tried Task.WaitAll()
and ran the functions synchronously using RunSynchronously()
but got the same results. How do you add blocking to an asynchronous function?
Aucun commentaire:
Enregistrer un commentaire