2020-04-13 16:16:31 -05:00
|
|
|
|
using IW4MAdmin;
|
2020-04-14 15:46:14 -05:00
|
|
|
|
using IW4MAdmin.Application.Misc;
|
2020-04-13 16:16:31 -05:00
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
|
|
|
|
|
namespace ApplicationTests
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
|
|
|
|
public class IW4MServerTests
|
|
|
|
|
{
|
|
|
|
|
[Test]
|
|
|
|
|
public void Test_GenerateLogPath_Basic()
|
|
|
|
|
{
|
|
|
|
|
string expected = "C:\\Game\\main\\log.log";
|
2020-04-14 15:46:14 -05:00
|
|
|
|
var info = new LogPathGeneratorInfo()
|
|
|
|
|
{
|
|
|
|
|
BasePathDirectory = "C:\\Game",
|
|
|
|
|
GameDirectory = "main",
|
|
|
|
|
LogFile = "log.log"
|
|
|
|
|
};
|
|
|
|
|
string generated = IW4MServer.GenerateLogPath(info);
|
2020-04-13 16:16:31 -05:00
|
|
|
|
|
|
|
|
|
Assert.AreEqual(expected, generated);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void Test_GenerateLogPath_WithMod()
|
|
|
|
|
{
|
|
|
|
|
string expected = "C:\\Game\\mods\\mod\\log.log";
|
2020-04-14 15:46:14 -05:00
|
|
|
|
var info = new LogPathGeneratorInfo()
|
|
|
|
|
{
|
|
|
|
|
BasePathDirectory = "C:\\Game",
|
|
|
|
|
GameDirectory = "main",
|
|
|
|
|
ModDirectory = "mods\\mod",
|
|
|
|
|
LogFile = "log.log"
|
|
|
|
|
};
|
|
|
|
|
string generated = IW4MServer.GenerateLogPath(info);
|
2020-04-13 16:16:31 -05:00
|
|
|
|
|
|
|
|
|
Assert.AreEqual(expected, generated);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
2020-04-14 15:46:14 -05:00
|
|
|
|
public void Test_GenerateLogPath_WithBaseGame()
|
2020-04-13 16:16:31 -05:00
|
|
|
|
{
|
|
|
|
|
string expected = "C:\\GameAlt\\main\\log.log";
|
2020-04-14 15:46:14 -05:00
|
|
|
|
var info = new LogPathGeneratorInfo()
|
|
|
|
|
{
|
|
|
|
|
BaseGameDirectory = "C:\\GameAlt",
|
|
|
|
|
BasePathDirectory = "C:\\Game",
|
|
|
|
|
GameDirectory = "main",
|
|
|
|
|
LogFile = "log.log"
|
|
|
|
|
};
|
|
|
|
|
string generated = IW4MServer.GenerateLogPath(info);
|
2020-04-13 16:16:31 -05:00
|
|
|
|
|
|
|
|
|
Assert.AreEqual(expected, generated);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
2020-04-14 15:46:14 -05:00
|
|
|
|
public void Test_GenerateLogPath_WithBaseGameAndMod()
|
2020-04-13 16:16:31 -05:00
|
|
|
|
{
|
|
|
|
|
string expected = "C:\\GameAlt\\mods\\mod\\log.log";
|
2020-04-14 15:46:14 -05:00
|
|
|
|
var info = new LogPathGeneratorInfo()
|
|
|
|
|
{
|
|
|
|
|
BaseGameDirectory = "C:\\GameAlt",
|
|
|
|
|
BasePathDirectory = "C:\\Game",
|
|
|
|
|
GameDirectory = "main",
|
|
|
|
|
ModDirectory = "mods\\mod",
|
|
|
|
|
LogFile = "log.log"
|
|
|
|
|
};
|
|
|
|
|
string generated = IW4MServer.GenerateLogPath(info);
|
2020-04-13 16:16:31 -05:00
|
|
|
|
|
|
|
|
|
Assert.AreEqual(expected, generated);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void Test_GenerateLogPath_InvalidBasePath()
|
|
|
|
|
{
|
|
|
|
|
string expected = "C:\\Game\\main\\log.log";
|
2020-04-14 15:46:14 -05:00
|
|
|
|
var info = new LogPathGeneratorInfo()
|
|
|
|
|
{
|
|
|
|
|
BaseGameDirectory = "game",
|
|
|
|
|
BasePathDirectory = "C:\\Game",
|
|
|
|
|
GameDirectory = "main",
|
|
|
|
|
LogFile = "log.log"
|
|
|
|
|
};
|
|
|
|
|
string generated = IW4MServer.GenerateLogPath(info);
|
2020-04-13 16:16:31 -05:00
|
|
|
|
|
|
|
|
|
Assert.AreEqual(expected, generated);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void Test_GenerateLogPath_BadSeparators()
|
|
|
|
|
{
|
|
|
|
|
string expected = "C:\\Game\\main\\folder\\log.log";
|
2020-04-14 15:46:14 -05:00
|
|
|
|
var info = new LogPathGeneratorInfo()
|
|
|
|
|
{
|
|
|
|
|
BasePathDirectory = "C:/Game",
|
|
|
|
|
GameDirectory = "main/folder",
|
|
|
|
|
LogFile = "log.log"
|
|
|
|
|
};
|
|
|
|
|
string generated = IW4MServer.GenerateLogPath(info);
|
2020-04-13 16:16:31 -05:00
|
|
|
|
|
|
|
|
|
Assert.AreEqual(expected, generated);
|
|
|
|
|
}
|
2020-04-13 18:15:46 -05:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void Test_GenerateLogPath_RelativeBasePath()
|
|
|
|
|
{
|
|
|
|
|
string expected = "C:\\Game\\main\\folder\\log.log";
|
2020-04-14 15:46:14 -05:00
|
|
|
|
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('\\', '/');
|
2020-04-13 18:15:46 -05:00
|
|
|
|
|
|
|
|
|
Assert.AreEqual(expected, generated);
|
|
|
|
|
}
|
2020-04-13 16:16:31 -05:00
|
|
|
|
}
|
|
|
|
|
}
|