public void ContextResolverSetGet() { var ctx = new TestContext { CorrelationId = "1", OtherId = "2" }; ContextResolver.SetRequestContext(ctx); var gotCtx = ContextResolver.GetRequestContext <TestContext>(); TestContextHelper.AssertAreEqual(ctx, gotCtx); }
public async Task ContextResolverSetGetAsyncTask() { var ctx = new TestContext { CorrelationId = "1", OtherId = "2" }; ContextResolver.SetRequestContext(ctx); var t = Task.Run(() => ContextResolver.GetRequestContext <TestContext>()); await t.ConfigureAwait(false); TestContextHelper.AssertAreEqual(ctx, t.Result); }
public void ContextResolverSetOtherThread() { var ctx = new TestContext { CorrelationId = "1", OtherId = "2" }; ContextResolver.SetRequestContext(ctx); TestContext gotCtx = null; var t = new Thread(() => { gotCtx = ContextResolver.GetRequestContext <TestContext>(); }); t.Start(); t.Join(); TestContextHelper.AssertAreEqual(ctx, gotCtx); }