1
0
mirror of https://github.com/RaidMax/IW4M-Admin.git synced 2025-06-10 15:20:48 -05:00

refactor and test log path generation to support pluto IW5 better

This commit is contained in:
RaidMax
2020-04-13 16:16:31 -05:00
parent c71356344d
commit 957f7d1a0f
4 changed files with 118 additions and 21 deletions

View File

@ -0,0 +1,63 @@
using IW4MAdmin;
using NUnit.Framework;
namespace ApplicationTests
{
[TestFixture]
public class IW4MServerTests
{
[Test]
public void Test_GenerateLogPath_Basic()
{
string expected = "C:\\Game\\main\\log.log";
string generated = IW4MServer.GenerateLogPath("", "C:\\Game", "main", null, "log.log");
Assert.AreEqual(expected, generated);
}
[Test]
public void Test_GenerateLogPath_WithMod()
{
string expected = "C:\\Game\\mods\\mod\\log.log";
string generated = IW4MServer.GenerateLogPath("", "C:\\Game", "main", "mods\\mod", "log.log");
Assert.AreEqual(expected, generated);
}
[Test]
public void Test_GenerateLogPath_WithBasePath()
{
string expected = "C:\\GameAlt\\main\\log.log";
string generated = IW4MServer.GenerateLogPath("C:\\GameAlt", "C:\\Game", "main", null, "log.log");
Assert.AreEqual(expected, generated);
}
[Test]
public void Test_GenerateLogPath_WithBasePathAndMod()
{
string expected = "C:\\GameAlt\\mods\\mod\\log.log";
string generated = IW4MServer.GenerateLogPath("C:\\GameAlt", "C:\\Game", "main", "mods\\mod", "log.log");
Assert.AreEqual(expected, generated);
}
[Test]
public void Test_GenerateLogPath_InvalidBasePath()
{
string expected = "C:\\Game\\main\\log.log";
string generated = IW4MServer.GenerateLogPath("game", "C:\\Game", "main", null, "log.log");
Assert.AreEqual(expected, generated);
}
[Test]
public void Test_GenerateLogPath_BadSeparators()
{
string expected = "C:\\Game\\main\\folder\\log.log";
string generated = IW4MServer.GenerateLogPath("", "C:/Game", "main/folder", null, "log.log");
Assert.AreEqual(expected, generated);
}
}
}