I am trying to unit test an async methods of a search query. The unit test is defined below:
[Test]
public async Task MyTest1()
{
var readyToScheduleQuery = new ReadyToScheduleQuery()
{
Facets = new List<Facet>()
{
new Facet()
{
Name = "Service Type",
Values = new List<FacetValue>()
{
new FacetValue()
{
Value = "SomeJob",
Selected = true
}
}
}
}
};
var result = readyToScheduleQuery.ExecuteAsync(_appointmentRespositoryStub);
Assert.IsNotNull(result);
}
The ExecuteAsync
method of readyToScheduleQuery is defined below:
internal async Task<ReadyToScheduleResult> ExecuteAsync(IAppointmentRepository appointments)
{
var query = await appointments.GetReadyToSchedule(this.Id, exclude: NotificationTags.Something);
The unit test just hangs up and never returns a result. Any ideas?
It hangs up if I do the following: (Note the Result
property at the end)
var result = readyToScheduleQuery.ExecuteAsync(_appointmentRespositoryStub).Result;