public override async Task Invoke(IOwinContext context) { // Create a request id - depending on deployment, the // owin variable may or may not be initialized var requestId = Guid.NewGuid().ToString(); // Record the request var requestAudit = context.ToAuditModel(requestId); // Check if path should be excluded var exclude = IsExcludedPath(requestAudit); // Record the request if (!exclude) { await _auditService.RecordAsync(requestAudit); } // Continue pipeline execution await Next.Invoke(context); // Record the response var responseAudit = context.ToAuditModel(requestId); // Check if the response is an error that should be processed if (_processor.ShouldProcess(context.Response)) { responseAudit.Error = await _processor.GetResponseStringAsync(context.Response); } if (!exclude) { await _auditService.RecordAsync(responseAudit); } }
public void ShouldProcess_Should_Return_False_When_CanSeek_False() { _mockStream.Setup(_ => _.CanSeek).Returns(false); _processor.ShouldProcess(_mockResponse.Object).Should().BeFalse(); Mock.VerifyAll(); }