Last active
March 29, 2020 02:47
-
-
Save davidfowl/5227871499007b53c60c1dbdfe95fd02 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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