Skip to content
This repository has been archived by the owner on Jun 25, 2022. It is now read-only.

Commit

Permalink
test(back-end): Rewrite the method 'IAsyncQueryProvider.ExecuteAsync'…
Browse files Browse the repository at this point in the history
… to avoid errors in the execution of expressions
  • Loading branch information
CarlosPavajeau committed Dec 25, 2020
1 parent d3c2b40 commit 1da0576
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Kaizen.Test/Helpers/TestAsyncQueryProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,15 @@ public TResult Execute<TResult>(Expression expression)

TResult IAsyncQueryProvider.ExecuteAsync<TResult>(Expression expression, CancellationToken cancellationToken)
{
return Execute<TResult>(expression);
var expectedResultType = typeof(TResult).GetGenericArguments()[0];
var executionResult = typeof(IQueryProvider)
.GetMethod(name: nameof(IQueryProvider.Execute), genericParameterCount: 1,
types: new[] { typeof(Expression) })
.MakeGenericMethod(expectedResultType)
.Invoke(this, new[] { expression });

return (TResult)typeof(Task).GetMethod(nameof(Task.FromResult))?.MakeGenericMethod(expectedResultType)
.Invoke(null, new[] { executionResult });
}

public Task<object> ExecuteAsync(Expression expression, CancellationToken cancellationToken)
Expand Down

1 comment on commit 1da0576

@CarlosPavajeau
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.