1
0
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:
RaidMax
2020-11-11 17:31:26 -06:00
parent f8c886d9db
commit 04fe6836c6
86 changed files with 1603 additions and 1534 deletions

View File

@ -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()
{