From 0106ca20949b36eee11d3a3c49c6c7d64fca244a Mon Sep 17 00:00:00 2001 From: Florian Trayon <26360935+FlorianLeChat@users.noreply.github.com> Date: Sun, 17 Nov 2024 13:22:44 +0100 Subject: [PATCH] Fixed some edge cases with unit tests following latest changes --- src/Program.cs | 8 +++++--- tests/MonitorTests.cs | 34 ++++++++++++++++++++-------------- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/src/Program.cs b/src/Program.cs index 113c735..cf879ea 100644 --- a/src/Program.cs +++ b/src/Program.cs @@ -63,13 +63,15 @@ private static async Task Main() /// public static string SelectGameCategory(string repository) { - if (repository.Contains("Garrys") && Form.GetRepositories()["Garry's Mod"]) + var loweredName = repository.ToLower(); + + if (loweredName.Contains("garrys") && Form.GetRepositories()["Garry's Mod"]) return "Garry's Mod"; - if (repository.Contains("rust") && Form.GetRepositories()["Rust"]) + if (loweredName.Contains("rust") && Form.GetRepositories()["Rust"]) return "Rust"; - if (repository.Contains("sbox") && Form.GetRepositories()["Sandbox"]) + if (loweredName.Contains("sbox") && Form.GetRepositories()["Sandbox"]) return "S&Box"; return "N/A"; diff --git a/tests/MonitorTests.cs b/tests/MonitorTests.cs index 098243e..63473d6 100644 --- a/tests/MonitorTests.cs +++ b/tests/MonitorTests.cs @@ -1,20 +1,26 @@ using FacepunchCommitsMonitor; using Microsoft.VisualStudio.TestTools.UnitTesting; +using static System.Windows.Forms.AxHost; -namespace FacepunchCommitsMonitorTests; - -[TestClass] -public class MonitorTests +namespace FacepunchCommitsMonitorTests { - [TestMethod] - public void SelectGameCategoryTest() - { - var gmod = Monitor.SelectGameCategory("GarrysMod2"); - var rust = Monitor.SelectGameCategory("Rustify"); - var sbox = Monitor.SelectGameCategory("SboxUnreal"); + [TestClass] + public class MonitorTests + { + [TestMethod] + public void SelectGameCategoryTest() + { + Form.GetRepositories()["Garry's Mod"] = true; + Form.GetRepositories()["Rust"] = true; + Form.GetRepositories()["Sandbox"] = true; + + var gmod = Monitor.SelectGameCategory("GarrysMod2"); + var rust = Monitor.SelectGameCategory("Rustify"); + var sbox = Monitor.SelectGameCategory("SboxUnreal"); - Assert.AreEqual("Garry's Mod", gmod); - Assert.AreEqual("Rust", rust); - Assert.AreEqual("S&Box", sbox); - } + Assert.AreEqual("Garry's Mod", gmod); + Assert.AreEqual("Rust", rust); + Assert.AreEqual("S&Box", sbox); + } + } } \ No newline at end of file