Changed how the test awaits on executed queries to make it more reliable (#427)

This commit is contained in:
Anthony Dresser
2017-08-04 14:44:57 -07:00
committed by GitHub
parent aa725c51ca
commit 70d658b9a8
2 changed files with 11 additions and 12 deletions

View File

@@ -15,10 +15,10 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
/// </summary> /// </summary>
public class ResultOnlyContext<TResult> : IEventSender public class ResultOnlyContext<TResult> : IEventSender
{ {
private readonly RequestContext<TResult> origContext; private readonly RequestContext<TResult> OrigContext;
public ResultOnlyContext(RequestContext<TResult> context) { public ResultOnlyContext(RequestContext<TResult> context) {
origContext = context; OrigContext = context;
} }
public virtual Task SendEvent<TParams>(EventType<TParams> eventType, TParams eventParams) public virtual Task SendEvent<TParams>(EventType<TParams> eventType, TParams eventParams)
@@ -27,5 +27,10 @@ namespace Microsoft.SqlTools.ServiceLayer.QueryExecution
// in the future this could be used to roll up events and send them back in the result // in the future this could be used to roll up events and send them back in the result
return Task.FromResult(true); return Task.FromResult(true);
} }
public virtual Task SendError(string errorMessage, int errorCode = 0)
{
return OrigContext.SendError(errorMessage, errorCode);
}
} }
} }

View File

@@ -486,16 +486,10 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.QueryExecution.Execution
await Task.WhenAll(queryService.ActiveSimpleExecuteRequests.Values); await Task.WhenAll(queryService.ActiveSimpleExecuteRequests.Values);
var queries = queryService.ActiveQueries.Values.Take(2).ToArray(); var queries = queryService.ActiveQueries.Values.ToArray();
Query q1 = queries[0]; var queryTasks = queries.Select(query => query.ExecutionTask);
Query q2 = queries[1];
await Task.WhenAll(queryTasks);
Assert.NotNull(q1);
Assert.NotNull(q2);
// wait on the task to finish
q1.ExecutionTask.Wait();
q2.ExecutionTask.Wait();
efv1.Validate(); efv1.Validate();
efv2.Validate(); efv2.Validate();