-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: use Serilog.Sinks.InMemory (#22)
- Loading branch information
1 parent
b890c89
commit c1b9c5b
Showing
5 changed files
with
28 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 4 additions & 12 deletions
16
.../Cnblogs.Architecture.IntegrationTestProject/EventHandlers/TestIntegrationEventHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,22 @@ | ||
using Cnblogs.Architecture.Ddd.EventBus.Abstractions; | ||
using Cnblogs.Architecture.TestIntegrationEvents; | ||
using static Cnblogs.Architecture.IntegrationTestProject.Constants; | ||
|
||
namespace Cnblogs.Architecture.IntegrationTestProject.EventHandlers; | ||
|
||
public class TestIntegrationEventHandler : IIntegrationEventHandler<TestIntegrationEvent> | ||
{ | ||
private readonly IHttpContextAccessor _httpContextAccessor; | ||
private readonly ILogger _logger; | ||
|
||
public TestIntegrationEventHandler(IHttpContextAccessor httpContextAccessor, ILogger<TestIntegrationEventHandler> logger) | ||
public TestIntegrationEventHandler(ILogger<TestIntegrationEventHandler> logger) | ||
{ | ||
_httpContextAccessor = httpContextAccessor; | ||
_logger = logger; | ||
} | ||
|
||
public Task Handle(TestIntegrationEvent notification, CancellationToken cancellationToken) | ||
{ | ||
var context = _httpContextAccessor.HttpContext; | ||
context?.Response.OnStarting(() => | ||
{ | ||
context.Response.Headers.Add(Constants.IntegrationEventIdHeaderName, notification.Id.ToString()); | ||
return Task.CompletedTask; | ||
}); | ||
|
||
_logger.LogInformation("Handled integration event {event}.", notification); | ||
_logger.LogInformation(LogTemplates.HandledIntegratonEvent, notification); | ||
|
||
return Task.CompletedTask; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters