From 14eb3e697ecd718cfb7db36456cab58e6f228be7 Mon Sep 17 00:00:00 2001 From: Timothy Baldridge Date: Wed, 2 Oct 2019 21:23:11 -0600 Subject: [PATCH] put the tests back, I think it was a message box error --- Wabbajack.Common/Consts.cs | 3 ++- Wabbajack.Common/GameMetaData.cs | 20 +++++++++++++++---- .../ContentRightsManagementTests.cs | 6 ++++++ Wabbajack.Test/SanityTests.cs | 6 +++--- Wabbajack/Validation/ValidateModlist.cs | 4 +--- 5 files changed, 28 insertions(+), 11 deletions(-) diff --git a/Wabbajack.Common/Consts.cs b/Wabbajack.Common/Consts.cs index 19fcfe30..aeb4d3f3 100644 --- a/Wabbajack.Common/Consts.cs +++ b/Wabbajack.Common/Consts.cs @@ -7,10 +7,11 @@ namespace Wabbajack.Common { public static class Consts { + public static bool TestMode { get; set; } = false; + public static string ModlistExtension = ".modlist_v1"; public static string GameFolderFilesDir = "Game Folder Files"; public static string LOOTFolderFilesDir = "LOOT Config Files"; - public static string ModListMagic = "Celebration!, Cheese for Everyone!"; public static string BSACreationDir = "TEMP_BSA_FILES"; public static string MegaPrefix = "https://mega.nz/#!"; diff --git a/Wabbajack.Common/GameMetaData.cs b/Wabbajack.Common/GameMetaData.cs index 0c214030..0ab94bd7 100644 --- a/Wabbajack.Common/GameMetaData.cs +++ b/Wabbajack.Common/GameMetaData.cs @@ -1,9 +1,11 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Reflection; using System.Security.Cryptography.X509Certificates; using System.Text; using System.Threading.Tasks; +using Alphaleonis.Win32.Filesystem; using Microsoft.Win32; namespace Wabbajack.Common @@ -26,10 +28,20 @@ namespace Wabbajack.Common public string MO2Name { get; internal set; } public string GameLocationRegistryKey { get; internal set; } - public string GameLocation => - (string)Registry.GetValue(GameLocationRegistryKey, "installed path", null) - ?? - (string)Registry.GetValue(GameLocationRegistryKey.Replace(@"HKEY_LOCAL_MACHINE\SOFTWARE\", @"HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\"), "installed path", null); + public string GameLocation + { + get + { + if (Consts.TestMode) + return Directory.GetCurrentDirectory(); + + return (string) Registry.GetValue(GameLocationRegistryKey, "installed path", null) + ?? + (string) Registry.GetValue( + GameLocationRegistryKey.Replace(@"HKEY_LOCAL_MACHINE\SOFTWARE\", + @"HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\"), "installed path", null); + } + } } public class GameRegistry diff --git a/Wabbajack.Test/ContentRightsManagementTests.cs b/Wabbajack.Test/ContentRightsManagementTests.cs index 91077307..870c6f8e 100644 --- a/Wabbajack.Test/ContentRightsManagementTests.cs +++ b/Wabbajack.Test/ContentRightsManagementTests.cs @@ -236,6 +236,12 @@ namespace Wabbajack.Test Assert.AreEqual(errors.Count(), 0); } + + [TestMethod] + public void CanLoadFromGithub() + { + new ValidateModlist().LoadListsFromGithub(); + } } diff --git a/Wabbajack.Test/SanityTests.cs b/Wabbajack.Test/SanityTests.cs index beb79f04..2755620e 100644 --- a/Wabbajack.Test/SanityTests.cs +++ b/Wabbajack.Test/SanityTests.cs @@ -2,12 +2,11 @@ using System.Collections.Generic; using System.Linq; using System.Runtime; +using Alphaleonis.Win32.Filesystem; using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting.Logging; using VFS; using Wabbajack.Common; -using Wabbajack.Validation; -using File = Alphaleonis.Win32.Filesystem.File; namespace Wabbajack.Test { @@ -21,7 +20,8 @@ namespace Wabbajack.Test [TestInitialize] public void TestInitialize() { - ValidateModlist.TestMode = true; + Consts.TestMode = true; + utils = new TestUtils(); utils.GameName = "Skyrim Special Edition"; diff --git a/Wabbajack/Validation/ValidateModlist.cs b/Wabbajack/Validation/ValidateModlist.cs index d0e69e21..eef43f75 100644 --- a/Wabbajack/Validation/ValidateModlist.cs +++ b/Wabbajack/Validation/ValidateModlist.cs @@ -19,7 +19,6 @@ namespace Wabbajack.Validation /// public class ValidateModlist { - public static bool TestMode { get; set; } = false; public Dictionary AuthorPermissions { get; set; } = new Dictionary(); public ServerWhitelist ServerWhitelist { get; set; } = new ServerWhitelist(); @@ -65,8 +64,7 @@ namespace Wabbajack.Validation { var validator = new ValidateModlist(); - if (!TestMode) - validator.LoadListsFromGithub(); + validator.LoadListsFromGithub(); Utils.Log("Running validation checks"); var errors = validator.Validate(modlist);