From f3101aeb5051852917fb718b8b9b8c2004ee6117 Mon Sep 17 00:00:00 2001 From: Vitaly Mikhailov Date: Sun, 9 May 2021 00:58:39 +0300 Subject: [PATCH] Fixed tests (#100) --- tests/MCM.Tests/BaseTests.cs | 4 ++++ .../SettingsFormat/BaseSettingsFormatTests.cs | 14 ++++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/tests/MCM.Tests/BaseTests.cs b/tests/MCM.Tests/BaseTests.cs index db0b7779..3b50d3a3 100644 --- a/tests/MCM.Tests/BaseTests.cs +++ b/tests/MCM.Tests/BaseTests.cs @@ -19,6 +19,8 @@ using v4::MCM; using v4::MCM.Implementation; +using ModuleInfoHelper = Bannerlord.BUTR.Shared.Helpers.ModuleInfoHelper; +using AccessTools2 = v4::HarmonyLib.BUTR.Extensions.AccessTools2; using SymbolExtensions2 = v4::HarmonyLib.BUTR.Extensions.SymbolExtensions2; namespace MCM.Tests @@ -51,6 +53,8 @@ private static bool MockedGetModulesNames(ref string[] __result) [OneTimeSetUp] public void OneTimeSetUp() { + _harmony.Patch(AccessTools2.Method(typeof(ButterLibSubModule).Assembly.GetType("Bannerlord.BUTR.Shared.Helpers.FSIOHelper"), "GetConfigPath"), + prefix: new HarmonyMethod(DelegateHelper.GetMethodInfo(MockedGetConfigsPath))); _harmony.Patch(SymbolExtensions2.GetMethodInfo(() => FSIOHelper.GetConfigPath()), prefix: new HarmonyMethod(DelegateHelper.GetMethodInfo(MockedGetConfigsPath))); _harmony.Patch(SymbolExtensions2.GetMethodInfo(() => ModuleInfoHelper.GetLoadedModules()), diff --git a/tests/MCM.Tests/SettingsFormat/BaseSettingsFormatTests.cs b/tests/MCM.Tests/SettingsFormat/BaseSettingsFormatTests.cs index d5284f9e..627c5ab4 100644 --- a/tests/MCM.Tests/SettingsFormat/BaseSettingsFormatTests.cs +++ b/tests/MCM.Tests/SettingsFormat/BaseSettingsFormatTests.cs @@ -1,14 +1,24 @@ extern alias v4; +using NUnit.Framework; + +using System; +using System.Runtime.CompilerServices; + using v4::MCM.Abstractions.Settings.Base.Global; using v4::MCM.Abstractions.Settings.Formats; -using NUnit.Framework; - namespace MCM.Tests.SettingsFormat { public class BaseSettingsFormatTests : BaseTests { + [MethodImpl(MethodImplOptions.NoInlining)] + protected static bool MockedGetConfigPath(ref string __result) + { + __result = AppDomain.CurrentDomain.BaseDirectory; + return false; + } + protected bool _boolValue; protected int _intValue; protected float _floatValue;