Skip to content

Commit

Permalink
Fixed some edge cases with unit tests following latest changes
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianLeChat committed Nov 17, 2024
1 parent 35b243a commit 0106ca2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
8 changes: 5 additions & 3 deletions src/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,15 @@ private static async Task Main()
/// </summary>
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";
Expand Down
34 changes: 20 additions & 14 deletions tests/MonitorTests.cs
Original file line number Diff line number Diff line change
@@ -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);
}
}
}

0 comments on commit 0106ca2

Please sign in to comment.