public void JoinTest() { string path1 = "game.ServerScriptService"; string path2 = "Test.Module"; Assert.AreEqual("game.ServerScriptService.Test.Module", RobloxPathHelper.Join(path1, path2)); }
public void ToFsPathTest() { string rbxPath1 = @"game.ServerScriptService.Test.Module"; string rbxPath2 = @"Test.Module"; Assert.AreEqual(@"game\ServerScriptService\Test\Module", RobloxPathHelper.ToFsPath(rbxPath1)); Assert.AreEqual(@"Test\Module", RobloxPathHelper.ToFsPath(rbxPath2)); }
public void MakeRelativePathTest() { string rootPath = @"game.ServerScriptService"; string absPath1 = @"game.ServerScriptService.Test.Module"; string absPath2 = @"game.ServerScriptService.Module"; Assert.AreEqual("Test.Module", RobloxPathHelper.MakeRelativePath(absPath1, rootPath)); Assert.AreEqual("Module", RobloxPathHelper.MakeRelativePath(absPath2, rootPath)); }
public void FromFsPathTest() { string fsPath1 = @"C:\Test\Test1"; string fsPath2 = @"Test\Test2\Test3"; string fsPath3 = @"Test\Test2\Module.lua"; string fsPath4 = @"Test\Test3\Module.mod.lua"; Assert.AreEqual("Test.Test1", RobloxPathHelper.FromFsPath(fsPath1)); Assert.AreEqual("Test.Test2.Test3", RobloxPathHelper.FromFsPath(fsPath2)); Assert.AreEqual("Test.Test2.Module", RobloxPathHelper.FromFsPath(fsPath3)); Assert.AreEqual("Test.Test3.Module", RobloxPathHelper.FromFsPath(fsPath4)); }
public static Script FromRoblox(string rbxPath, ScriptType rbxType, Mapping mapping) { string relativeRbxPath = RobloxPathHelper.MakeRelativePath(rbxPath, mapping.RobloxPath); string relativeFsPath = RobloxPathHelper.ToFsPath(relativeRbxPath); string absoluteFsPath = PathExtension.MakeAbsolutePath(relativeFsPath, mapping.FsPath); string ext = GetExtension(rbxType) + ".lua"; absoluteFsPath = absoluteFsPath + ext; Script script = new Script(); script.RobloxPath = rbxPath; script.FilePath = absoluteFsPath; script.Name = RobloxPathHelper.GetName(rbxPath); script.Type = rbxType; return(script); }
public static Script FromFileSystem(string filePath, Mapping mapping) { string info = Path.GetFileNameWithoutExtension(filePath); string name = Path.GetFileNameWithoutExtension(info); string typeString = Path.GetExtension(info); string relativeFsPath = PathExtension.MakeRelativePath(mapping.FsPath, filePath); string relativeRbxPath = RobloxPathHelper.FromFsPath(relativeFsPath); string rbxPath = RobloxPathHelper.Join(mapping.RobloxPath, relativeRbxPath); Script script = new Script(); script.RobloxPath = rbxPath; script.FilePath = filePath; script.Name = name; script.Type = GetScriptType(typeString); return(script); }
public void NormalizeTest() { string test1 = "game.Workspace"; string test2 = ".game.Workspace"; string test3 = "game.Workspace."; string test4 = ".game.Workspace."; string test5 = "game..Workspace"; string test6 = "game.Workspace..."; string test7 = "..game.Workspace"; string test8 = "..game.Workspace...."; Assert.AreEqual("game.Workspace", RobloxPathHelper.Normalize(test1)); Assert.AreEqual("game.Workspace", RobloxPathHelper.Normalize(test2)); Assert.AreEqual("game.Workspace", RobloxPathHelper.Normalize(test3)); Assert.AreEqual("game.Workspace", RobloxPathHelper.Normalize(test4)); Assert.AreEqual("game.Workspace", RobloxPathHelper.Normalize(test5)); Assert.AreEqual("game.Workspace", RobloxPathHelper.Normalize(test6)); Assert.AreEqual("game.Workspace", RobloxPathHelper.Normalize(test7)); Assert.AreEqual("game.Workspace", RobloxPathHelper.Normalize(test8)); }