示例#1
0
        public async Task Invoke_DoesNotOverrideExistingHttpContextOnAccessor()
        {
            var accessor = Mock.Of <IHttpContextAccessor>();

            accessor.HttpContext = new DefaultHttpContext();
            var next    = new RequestDelegate(ctx => Task.FromResult(0));
            var context = CreateContext();

            var mtc = CreateServiceProvider().GetRequiredService <MultitenantContainer>();

            var mw = new MultitenantRequestServicesMiddleware(next, accessor, mtc);
            await mw.Invoke(context);

            Assert.NotSame(context, accessor.HttpContext);
        }