Skip to content

Commit 09ce801

Browse files
committed
refactor: changes for code review
1 parent 7b656cc commit 09ce801

File tree

4 files changed

+11
-19
lines changed

4 files changed

+11
-19
lines changed

.editorconfig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,9 @@ indent_style = space
7979
indent_size = 4
8080
tab_width = 4
8181

82-
[*.xml]
82+
[*.{xml,csproj}]
8383
indent_size = 2
84+
tab_width = 2
8485

8586
#### C# Coding Conventions ####
8687
[*.cs]

test/Cnblogs.Architecture.IntegrationTestProject/EventHandlers/TestIntegrationEventHandler.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
1-
using Cnblogs.Architecture.Ddd.EventBus.Abstractions;
1+
using System.Diagnostics;
2+
using Cnblogs.Architecture.Ddd.EventBus.Abstractions;
23
using Cnblogs.Architecture.TestIntegrationEvents;
34
using MediatR;
4-
using System.Diagnostics;
55

66
namespace Cnblogs.Architecture.IntegrationTestProject.EventHandlers;
77

88
public class TestIntegrationEventHandler : IIntegrationEventHandler<TestIntegrationEvent>
99
{
1010
private readonly IHttpContextAccessor _httpContextAccessor;
11+
private readonly ILogger _logger;
1112

12-
public TestIntegrationEventHandler(IHttpContextAccessor httpContextAccessor)
13+
public TestIntegrationEventHandler(IHttpContextAccessor httpContextAccessor, ILogger<TestIntegrationEventHandler> logger)
1314
{
1415
_httpContextAccessor = httpContextAccessor;
16+
_logger = logger;
1517
}
1618

1719
public Task Handle(TestIntegrationEvent notification, CancellationToken cancellationToken)
@@ -23,7 +25,7 @@ public Task Handle(TestIntegrationEvent notification, CancellationToken cancella
2325
return Task.CompletedTask;
2426
});
2527

26-
Debug.WriteLine($"notification message: " + notification.Message);
28+
_logger.LogInformation("Handled integration event {event}.", notification);
2729

2830
return Task.CompletedTask;
2931
}

test/Cnblogs.Architecture.IntegrationTests/Cnblogs.Architecture.IntegrationTests.csproj

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2-
<PropertyGroup>
3-
<Nullable>disable</Nullable>
4-
</PropertyGroup>
52
<ItemGroup>
63
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="7.0.2" />
74
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />

test/Cnblogs.Architecture.IntegrationTests/IntegrationEventHandlerTests.cs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
1-
using System.Diagnostics;
2-
using System.IO.Pipes;
3-
using System.Net;
4-
using System.Net.Http.Json;
1+
using System.Net.Http.Json;
52
using Cnblogs.Architecture.IntegrationTestProject;
6-
using Cnblogs.Architecture.IntegrationTestProject.EventHandlers;
73
using Cnblogs.Architecture.TestIntegrationEvents;
84
using FluentAssertions;
9-
using MediatR;
10-
using Microsoft.AspNetCore.Http;
11-
using Microsoft.AspNetCore.Mvc.Testing;
12-
using Microsoft.Extensions.DependencyInjection;
5+
using Xunit.Abstractions;
136

147
namespace Cnblogs.Architecture.IntegrationTests;
158

@@ -22,7 +15,6 @@ public class IntegrationEventHandlerTests
2215
public IntegrationEventHandlerTests(IntegrationTestFactory factory, ITestOutputHelper testOutputHelper)
2316
{
2417
_factory = factory;
25-
_factory.TestOutputHelper = testOutputHelper;
2618
_testOutputHelper = testOutputHelper;
2719
}
2820

@@ -35,7 +27,7 @@ public async Task IntegrationEventHandler_TestIntegrationEvent_SuccessAsync()
3527

3628
// Act
3729
var subscriptions = await client.GetFromJsonAsync<Subscription[]>("/dapr/subscribe");
38-
var sub = subscriptions.First(x => x.Route.Contains(nameof(TestIntegrationEvent)));
30+
var sub = subscriptions!.First(x => x.Route.Contains(nameof(TestIntegrationEvent)));
3931
var response = await client.PostAsJsonAsync(sub.Route, @event);
4032
_testOutputHelper.WriteLine("Subscription Route: " + sub.Route);
4133

0 commit comments

Comments
 (0)