@@ -13,9 +13,7 @@ namespace BepInEx.Configuration
/// </summary>
public class ConfigFile
{
- // Need to be lazy evaluated to not cause problems for unit tests
- private static ConfigFile _coreConfig;
- internal static ConfigFile CoreConfig => _coreConfig ?? (_coreConfig = new ConfigFile(Paths.BepInExConfigPath, true));
+ internal static ConfigFile CoreConfig { get; } = new ConfigFile(Paths.BepInExConfigPath, true);
protected Dictionary<ConfigDefinition, ConfigEntry> Entries { get; } = new Dictionary<ConfigDefinition, ConfigEntry>();
@@ -25,6 +25,7 @@ using BepInEx;
[assembly: Guid("4ffba620-f5ed-47f9-b90c-dad1316fd9b9")]
[assembly: InternalsVisibleTo("BepInEx.Preloader")]
+[assembly: InternalsVisibleTo("BepInExTests")]
// Version information for an assembly consists of the following four values:
//
@@ -0,0 +1,29 @@
+using System.IO;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace BepInEx.Tests
+{
+ [TestClass]
+ public class AssemblyInit
+ {
+ private static string _testPath;
+ [AssemblyInitialize]
+ public static void InitAss(TestContext context)
+ _testPath = Path.Combine(Path.GetTempPath(), "BepinexTestDir");
+ Directory.CreateDirectory(_testPath);
+ string exePath = Path.Combine(_testPath, "Text.exe");
+ File.WriteAllBytes(exePath, new byte[] { });
+ Paths.SetExecutablePath(_testPath);
+ }
+ [AssemblyCleanup]
+ public static void CleanupAss()
+ Directory.Delete(_testPath, true);
+}
@@ -62,6 +62,7 @@
<Otherwise />
</Choose>
<ItemGroup>
+ <Compile Include="AssemblyInit.cs" />
<Compile Include="Configuration\ConfigFileTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>