I am using Visual Studio 2013 and MSTest for unit testing my async method. I have async method as below:
public async Task<Client> AddClientAsync(Client newClient)
{
newClient.ObjectState = ObjectState.Added;
base.Insert(newClient);
await unitOfWorkAsync.SaveChangesAsync();
return newClient;
}
I have written following unit test method to test it.
[TestMethod]
public async Task AddClientAsync_Success()
{
Client client = new Client()
{
Id=2,
FirstName="John",
LastName="Tylor",
MaritalStatusId=1,
RecordStatus=1
};
var result = await clientAppService.AddClientAsync(client);
Assert.IsNotNull(result);
}
When I run/debug test case control reaches till below line and never returns. Its kind of getting stuck and keeps waiting endlessly at this line and test never completes.
await unitOfWorkAsync.SaveChangesAsync();
Any idea what am I missing here?
Aucun commentaire:
Enregistrer un commentaire