Skip to content

Commit 2ac593b

Browse files
committed
Fixed logger / loggerfactory usage
1 parent 28100f3 commit 2ac593b

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

Fritz.Chatbot/Commands/ShoutoutCommand.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ public class ShoutoutCommand : IBasicCommand2
1212
private readonly HttpClient _HttpClient;
1313
private readonly ILogger _Logger;
1414

15-
public ShoutoutCommand(IHttpClientFactory httpClientFactory, ILogger logger)
15+
public ShoutoutCommand(IHttpClientFactory httpClientFactory, ILoggerFactory logger)
1616
{
1717

1818
_HttpClient = httpClientFactory.CreateClient("ShoutoutCommand");
1919
_HttpClient.BaseAddress = new Uri("https://api.twitch.tv/helix/users");
2020

21-
_Logger = logger;
21+
_Logger = logger.CreateLogger(nameof(ShoutoutCommand));
2222

2323
}
2424

Test/Chatbot/ShoutoutCommandFixture.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,17 @@ public class ShoutoutCommandFixture
1818
private readonly MockRepository _Mockery;
1919
private readonly Mock<IHttpClientFactory> _ClientFactory;
2020
private readonly Mock<IChatService> _ChatService;
21-
private readonly ILogger _Logger;
21+
private readonly ILoggerFactory _Logger;
2222

2323
public ShoutoutCommandFixture(ITestOutputHelper output)
2424
{
2525
_Mockery = new MockRepository(MockBehavior.Default);
2626
_ClientFactory = new Mock<IHttpClientFactory>();
2727
_ChatService = new Mock<IChatService>();
28-
_Logger = new XunitLogger<ShoutoutCommand>(output);
28+
29+
var thisLogger = new Mock<ILoggerFactory>();
30+
thisLogger.Setup(f => f.CreateLogger(It.IsAny<string>())).Returns( new XunitLogger<ShoutoutCommand>(output));
31+
_Logger = thisLogger.Object;
2932

3033
}
3134

0 commit comments

Comments
 (0)