System.Threading.Tests.ExecutionContextTests.VerifyExecutionContext C# (CSharp) Method

VerifyExecutionContext() private static method

private static VerifyExecutionContext ( ExecutionContext executionContext, AsyncLocal asyncLocal, int expectedValue ) : void
executionContext ExecutionContext
asyncLocal AsyncLocal
expectedValue int
return void
        private static void VerifyExecutionContext(
            ExecutionContext executionContext,
            AsyncLocal<int> asyncLocal,
            int expectedValue)
        {
            int actualValue = 0;
            Action run = () => ExecutionContext.Run(executionContext, state => actualValue = asyncLocal.Value, null);
            if (executionContext == null)
            {
                Assert.Throws<InvalidOperationException>(() => run());
            }
            else
            {
                run();
            }
            Assert.Equal(expectedValue, actualValue);
        }