public void Run_StartsOnUIThread_ExecuteOnUIThread() { bool operationExecuted = false; using var hackedThreadingScope = new HackedVSThreadingScope(); // Act RunOnUIThread.Run(() => operationExecuted = true); operationExecuted.Should().BeTrue(); hackedThreadingScope.CheckThreadSwitchNotRequested(); }
public async Task RunAsync_StartsOnBackgroundThread_ExecuteOnUIThread() { bool operationExecuted = false; using var hackedThreadingScope = new HackedVSThreadingScope(); // Act await Task.Run(async() => { // Now on a background thread, so expecting the VS to request a switch to the main thread await RunOnUIThread.RunAsync(() => operationExecuted = true); }); operationExecuted.Should().BeTrue(); hackedThreadingScope.CheckThreadSwitchRequested(); }