Fixed enum serialization

This commit is contained in:
Alex
2025-01-16 15:35:26 +00:00
parent 088248706d
commit 0c08bac439
7 changed files with 137150 additions and 5 deletions
+47
View File
@@ -0,0 +1,47 @@
using Core.Models.Logging;
using Core.Models.Utils;
namespace UnitTests.Mock;
public class MockLogger<T> : ISptLogger<T>
{
public void LogWithColor(
string data,
Exception? ex = null,
LogTextColor? textColor = null,
LogBackgroundColor? backgroundColor = null
)
{
Console.WriteLine(data);
}
public void Success(string data, Exception? ex = null)
{
Console.WriteLine(data);
}
public void Error(string data, Exception? ex = null)
{
Console.WriteLine(data);
}
public void Warning(string data, Exception? ex = null)
{
Console.WriteLine(data);
}
public void Info(string data, Exception? ex = null)
{
Console.WriteLine(data);
}
public void Debug(string data, Exception? ex = null)
{
Console.WriteLine(data);
}
public void Critical(string data, Exception? ex = null)
{
Console.WriteLine(data);
}
}
File diff suppressed because it is too large Load Diff
+30
View File
@@ -0,0 +1,30 @@
using Core.Models.Spt.Server;
using Core.Models.Spt.Templates;
using Core.Utils;
using UnitTests.Mock;
namespace UnitTests.Tests;
[TestClass]
public class Test
{
private Templates _templates;
[TestInitialize]
public void Setup()
{
var importer = new ImporterUtil(new MockLogger<ImporterUtil>(), new FileUtil(), new JsonUtil());
var loadTask = importer.LoadRecursiveAsync<Templates>("./TestAssets/");
loadTask.Wait();
_templates = loadTask.Result;
}
[TestMethod]
public void TestMethod1()
{
var result = new JsonUtil().Serialize(_templates);
Console.WriteLine(result);
}
}
+3 -1
View File
@@ -20,7 +20,9 @@
</ItemGroup>
<ItemGroup>
<Folder Include="Tests\Mock\" />
<Content Include="TestAssets\**">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>