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

fix regression issue with wine drive name mangling

This commit is contained in:
RaidMax
2020-04-14 15:46:14 -05:00
parent 2b4aaed4bf
commit 86edd8a25e
3 changed files with 141 additions and 22 deletions

View File

@ -1,4 +1,5 @@
using IW4MAdmin;
using IW4MAdmin.Application.Misc;
using NUnit.Framework;
namespace ApplicationTests
@ -10,7 +11,13 @@ namespace ApplicationTests
public void Test_GenerateLogPath_Basic()
{
string expected = "C:\\Game\\main\\log.log";
string generated = IW4MServer.GenerateLogPath("", "C:\\Game", "main", null, "log.log");
var info = new LogPathGeneratorInfo()
{
BasePathDirectory = "C:\\Game",
GameDirectory = "main",
LogFile = "log.log"
};
string generated = IW4MServer.GenerateLogPath(info);
Assert.AreEqual(expected, generated);
}
@ -19,25 +26,47 @@ namespace ApplicationTests
public void Test_GenerateLogPath_WithMod()
{
string expected = "C:\\Game\\mods\\mod\\log.log";
string generated = IW4MServer.GenerateLogPath("", "C:\\Game", "main", "mods\\mod", "log.log");
var info = new LogPathGeneratorInfo()
{
BasePathDirectory = "C:\\Game",
GameDirectory = "main",
ModDirectory = "mods\\mod",
LogFile = "log.log"
};
string generated = IW4MServer.GenerateLogPath(info);
Assert.AreEqual(expected, generated);
}
[Test]
public void Test_GenerateLogPath_WithBasePath()
public void Test_GenerateLogPath_WithBaseGame()
{
string expected = "C:\\GameAlt\\main\\log.log";
string generated = IW4MServer.GenerateLogPath("C:\\GameAlt", "C:\\Game", "main", null, "log.log");
var info = new LogPathGeneratorInfo()
{
BaseGameDirectory = "C:\\GameAlt",
BasePathDirectory = "C:\\Game",
GameDirectory = "main",
LogFile = "log.log"
};
string generated = IW4MServer.GenerateLogPath(info);
Assert.AreEqual(expected, generated);
}
[Test]
public void Test_GenerateLogPath_WithBasePathAndMod()
public void Test_GenerateLogPath_WithBaseGameAndMod()
{
string expected = "C:\\GameAlt\\mods\\mod\\log.log";
string generated = IW4MServer.GenerateLogPath("C:\\GameAlt", "C:\\Game", "main", "mods\\mod", "log.log");
var info = new LogPathGeneratorInfo()
{
BaseGameDirectory = "C:\\GameAlt",
BasePathDirectory = "C:\\Game",
GameDirectory = "main",
ModDirectory = "mods\\mod",
LogFile = "log.log"
};
string generated = IW4MServer.GenerateLogPath(info);
Assert.AreEqual(expected, generated);
}
@ -46,7 +75,14 @@ namespace ApplicationTests
public void Test_GenerateLogPath_InvalidBasePath()
{
string expected = "C:\\Game\\main\\log.log";
string generated = IW4MServer.GenerateLogPath("game", "C:\\Game", "main", null, "log.log");
var info = new LogPathGeneratorInfo()
{
BaseGameDirectory = "game",
BasePathDirectory = "C:\\Game",
GameDirectory = "main",
LogFile = "log.log"
};
string generated = IW4MServer.GenerateLogPath(info);
Assert.AreEqual(expected, generated);
}
@ -55,7 +91,13 @@ namespace ApplicationTests
public void Test_GenerateLogPath_BadSeparators()
{
string expected = "C:\\Game\\main\\folder\\log.log";
string generated = IW4MServer.GenerateLogPath("", "C:/Game", "main/folder", null, "log.log");
var info = new LogPathGeneratorInfo()
{
BasePathDirectory = "C:/Game",
GameDirectory = "main/folder",
LogFile = "log.log"
};
string generated = IW4MServer.GenerateLogPath(info);
Assert.AreEqual(expected, generated);
}
@ -64,7 +106,30 @@ namespace ApplicationTests
public void Test_GenerateLogPath_RelativeBasePath()
{
string expected = "C:\\Game\\main\\folder\\log.log";
string generated = IW4MServer.GenerateLogPath("main\\folder", "C:\\Game", "main\\folder", null, "log.log");
var info = new LogPathGeneratorInfo()
{
BaseGameDirectory = "main\\folder",
BasePathDirectory = "C:\\Game",
GameDirectory = "main\\folder",
LogFile = "log.log"
};
string generated = IW4MServer.GenerateLogPath(info);
Assert.AreEqual(expected, generated);
}
[Test]
public void Test_GenerateLogPath_FixWineDriveMangling()
{
string expected = "/opt/server/game/log.log";
var info = new LogPathGeneratorInfo()
{
BasePathDirectory = "Z:\\opt\\server",
GameDirectory = "game",
LogFile = "log.log",
IsWindows = false
};
string generated = IW4MServer.GenerateLogPath(info).Replace('\\', '/');
Assert.AreEqual(expected, generated);
}