Skip to content

Instantly share code, notes, and snippets.

@davidfowl
Last active March 29, 2020 02:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidfowl/5227871499007b53c60c1dbdfe95fd02 to your computer and use it in GitHub Desktop.
Save davidfowl/5227871499007b53c60c1dbdfe95fd02 to your computer and use it in GitHub Desktop.
using System;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
using UnitTestingDiagnostics;
using Xunit;
namespace XUnitTestProject1
{
public class OtherComponent
{
public static void Execute(TaskCompletionSource<object> tcs)
{
ThreadPool.QueueUserWorkItem(_ =>
{
BuggyCode();
tcs.TrySetResult(null);
},
null);
static void BuggyCode() => throw new InvalidOperationException();
}
}
public class UnitTest1
{
[Fact]
public async Task Test1()
{
await Task.Delay(1000);
}
[Fact]
public async Task CrashTestRunner()
{
var tcs = new TaskCompletionSource<object>();
OtherComponent.Execute(tcs);
await tcs.Task;
}
[Fact]
public async Task Test2()
{
await Task.Delay(5000);
Assert.True(false);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment