コード例 #1
0
        public async Task InvokeLogHandler_Test()
        {
            var applicationInsightsMock = new ApplicationInsightsSettings()
            {
                InstrumentationKey = "118047f1-b165-4bff-9471-e87fd3fe167c"
            };

            _applicationInsightsMock.Setup(x => x.Value)
            .Returns(applicationInsightsMock);

            var httpContext = new DefaultHttpContext().Request.HttpContext;

            var logMiddleware = new LogMiddleware(async(innerHttpContext) =>
            {
                await innerHttpContext.Response.WriteAsync("Response body mock");
            }, _applicationInsightsMock.Object);

            await logMiddleware.Invoke(httpContext, _identityServiceMock.Object);

            Assert.NotNull(logMiddleware);
        }
コード例 #2
0
        public async Task InvokeLogHandler_Test()
        {
            var fakeChannel = new TelemetryChannelMock();
            var config      = new TelemetryConfiguration
            {
                TelemetryChannel   = fakeChannel,
                InstrumentationKey = string.Empty,
            };
            var client = new TelemetryClient(config);

            var httpContext = new DefaultHttpContext().Request.HttpContext;

            httpContext.Request.Method = HttpMethods.Post;

            var logMiddleware = new LogMiddleware(async(innerHttpContext) =>
            {
                await innerHttpContext.Response.WriteAsync("Response body mock");
            }, client);

            await logMiddleware.Invoke(httpContext, _identityServiceMock.Object);

            Assert.NotNull(logMiddleware);
        }