private void RunTest(Action action, CancellationToken cancellationToken) { _readyForCancellation = _caughtException = _finishedExecution = false; _exception = null; _counter = 0; try { ControlledExecution.Run(action, cancellationToken); } catch (Exception e) { _exception = e; } }
public void TestNestedRunInvocation() { bool nestedExecution = false; var cts = new CancellationTokenSource(); RunTest(Test, cts.Token); Assert.False(nestedExecution); Assert.IsType <InvalidOperationException>(_exception); void Test() { ControlledExecution.Run(() => nestedExecution = true, cts.Token); } }