Exemplo n.º 1
0
        public void ContextResolverSetGet()
        {
            var ctx = new TestContext {
                CorrelationId = "1", OtherId = "2"
            };

            ContextResolver.SetRequestContext(ctx);
            var gotCtx = ContextResolver.GetRequestContext <TestContext>();

            TestContextHelper.AssertAreEqual(ctx, gotCtx);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }