Skip to content

Commit

Permalink
Fixed tests (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aragas authored May 8, 2021
1 parent e72e95b commit f3101ae
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 4 additions & 0 deletions tests/MCM.Tests/BaseTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()),
Expand Down
14 changes: 12 additions & 2 deletions tests/MCM.Tests/SettingsFormat/BaseSettingsFormatTests.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down

0 comments on commit f3101ae

Please sign in to comment.