Exemplo n.º 1
0
        public void Setup()
        {
            _mockOwinContext = new MockOwinContext();
            _owinContext     = _mockOwinContext.GetImplementation <IOwinContext>(null);

            const string body       = "Body of the request";
            var          bodyStream = new MemoryStream(Encoding.UTF8.GetBytes(body));

            _mockOwinContext.SetMockequest(new Uri("http://test.com/mypath?param=value"), bodyStream);
        }
        public async Task Should_Not_Substitue_Existing_Operation_Id_If_Context_Contains_Null()
        {
            OperationIdContext.Set("test");
            var context = new MockOwinContext();

            var collector = new OperationIdCollectingMiddleware();
            var sut = new RestoreOperationIdContextMiddleware(collector);

            await sut.Invoke(context);

            collector.OperationIdFromAmbientContext.Should().Be("test");
        }
        public async Task Can_Restore_Operation_Context_Id_From_Owin_Context()
        {
            var context = new MockOwinContext();
            context.Set(Consts.OperationIdContextKey, "test");

            var collector = new OperationIdCollectingMiddleware();
            var sut = new RestoreOperationIdContextMiddleware(collector);

            await sut.Invoke(context);

            collector.OperationIdFromAmbientContext.Should().Be("test");
        }
        public async Task Should_Not_Substitue_Existing_Operation_Id_If_Context_Contains_Null()
        {
            OperationIdContext.Set("test");
            var context = new MockOwinContext();

            var collector = new OperationIdCollectingMiddleware();
            var sut       = new RestoreOperationIdContextMiddleware(collector);

            await sut.Invoke(context);

            collector.OperationIdFromAmbientContext.Should().Be("test");
        }
Exemplo n.º 5
0
        public async Task Can_Clean_Context()
        {
            var context = new MockOwinContext();

            var sut = new OperationIdContextMiddleware(
                new NoopMiddleware(),
                new OperationIdContextMiddlewareConfiguration());

            await sut.Invoke(context);

            context.Get <string>(Consts.OperationIdContextKey).Should().BeNull();
            OperationIdContext.Get().Should().BeNull();
        }
        public async Task Can_Restore_Operation_Context_Id_From_Owin_Context()
        {
            var context = new MockOwinContext();

            context.Set(Consts.OperationIdContextKey, "test");

            var collector = new OperationIdCollectingMiddleware();
            var sut       = new RestoreOperationIdContextMiddleware(collector);

            await sut.Invoke(context);

            collector.OperationIdFromAmbientContext.Should().Be("test");
        }
        public async Task Can_Clean_Context()
        {
            var context = new MockOwinContext();

            var sut = new OperationIdContextMiddleware(
                new NoopMiddleware(),
                new OperationIdContextMiddlewareConfiguration());

            await sut.Invoke(context);

            context.Get<string>(Consts.OperationIdContextKey).Should().BeNull();
            OperationIdContext.Get().Should().BeNull();
        }
Exemplo n.º 8
0
        public async Task Should_Not_Substitue_Existing_Operation_Id_If_Context_Contains_Null()
        {
            using (new OperationContextScope("opid", "parentid"))
            {
                var context = new MockOwinContext();

                var collector = new OperationContextCollectingMiddleware();
                var sut       = new RestoreOperationIdContextMiddleware(collector);

                await sut.Invoke(context);

                collector.OperationIdFromAmbientContext.Should().Be("opid");
                collector.ParentOperationIdFromAmbientContext.Should().Be("parentid");
            }
        }
 public void SetUp()
 {
     _owinContext     = SetupMock <IOwinContext>();
     _mockOwinContext = GetMock <MockOwinContext, IOwinContext>();
 }