Tidy up test

This commit is contained in:
Ben Adams 2021-01-03 22:48:11 +00:00
parent 8c36d75d91
commit cf4ce5d5a2

View File

@ -87,12 +87,12 @@ namespace Ben.Demystifier.Test
} }
[Fact] [Fact]
public void DemistifiesMethodWithAsyncLambda() public async Task DemistifiesMethodWithAsyncLambda()
{ {
Exception dex = null; Exception dex = null;
try try
{ {
MethodWithAsyncLambda(); await MethodWithAsyncLambda();
} }
catch (Exception e) catch (Exception e)
{ {
@ -106,9 +106,9 @@ namespace Ben.Demystifier.Test
var expected = string.Join(string.Empty, var expected = string.Join(string.Empty,
"System.ArgumentException: Value does not fall within the expected range.", "System.ArgumentException: Value does not fall within the expected range.",
" at async void Ben.Demystifier.Test.MethodTests.MethodWithAsyncLambda()+(?) => { }", " at async Task Ben.Demystifier.Test.MethodTests.MethodWithAsyncLambda()+(?) => { }",
" at void Ben.Demystifier.Test.MethodTests.MethodWithAsyncLambda()", " at async Task Ben.Demystifier.Test.MethodTests.MethodWithAsyncLambda()",
" at void Ben.Demystifier.Test.MethodTests.DemistifiesMethodWithAsyncLambda()"); " at async Task Ben.Demystifier.Test.MethodTests.DemistifiesMethodWithAsyncLambda()");
Assert.Equal(expected, trace); Assert.Equal(expected, trace);
} }
@ -123,10 +123,15 @@ namespace Ben.Demystifier.Test
action(); action();
} }
private void MethodWithAsyncLambda() private async Task MethodWithAsyncLambda()
{ {
Func<Task> action = async () => throw new ArgumentException(); Func<Task> action = async () =>
action().ConfigureAwait(false).GetAwaiter().GetResult(); {
await Task.Delay(0);
throw new ArgumentException();
};
await action();
} }
} }
} }