mirror of
https://github.com/RaidMax/IW4M-Admin.git
synced 2025-06-10 15:20:48 -05:00
refactor logging in pretty big overhaul
This commit is contained in:
@ -9,6 +9,7 @@ using SharedLibraryCore;
|
||||
using SharedLibraryCore.Configuration;
|
||||
using SharedLibraryCore.Interfaces;
|
||||
using System;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using static SharedLibraryCore.GameEvent;
|
||||
|
||||
namespace ApplicationTests
|
||||
@ -18,7 +19,6 @@ namespace ApplicationTests
|
||||
{
|
||||
private EventLogTest eventLogData;
|
||||
private IServiceProvider serviceProvider;
|
||||
private ILogger fakeLogger;
|
||||
private ApplicationConfiguration appConfig;
|
||||
|
||||
[SetUp]
|
||||
@ -27,13 +27,12 @@ namespace ApplicationTests
|
||||
eventLogData = JsonConvert.DeserializeObject<EventLogTest>(System.IO.File.ReadAllText("Files/GameEvents.json"));
|
||||
appConfig = ConfigurationGenerators.CreateApplicationConfiguration();
|
||||
|
||||
fakeLogger = A.Fake<ILogger>();
|
||||
serviceProvider = new ServiceCollection()
|
||||
.AddSingleton(A.Fake<ILogger>())
|
||||
.AddSingleton<BaseEventParser>()
|
||||
.AddTransient<IParserPatternMatcher, ParserPatternMatcher>()
|
||||
.AddSingleton<IParserRegexFactory, ParserRegexFactory>()
|
||||
.AddSingleton(appConfig)
|
||||
.AddSingleton(fakeLogger)
|
||||
.BuildServiceProvider();
|
||||
}
|
||||
|
||||
@ -86,18 +85,6 @@ namespace ApplicationTests
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestCustomEventParsingLogsWarningOnException()
|
||||
{
|
||||
var eventParser = serviceProvider.GetService<BaseEventParser>();
|
||||
|
||||
eventParser.RegisterCustomEvent("test", "test", (a, b, c) => throw new Exception());
|
||||
eventParser.GenerateGameEvent("12:12 test");
|
||||
|
||||
A.CallTo(() => fakeLogger.WriteWarning(A<string>.Ignored))
|
||||
.MustHaveHappenedOnceExactly();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Test_CustomCommandPrefix_Parses()
|
||||
{
|
||||
|
Reference in New Issue
Block a user