public void EnvVarSearch_FindInPath_MultipleResult() { Dictionary <string, string> setup = new Dictionary <string, string>(); OsDetector.OsSelection os = OsDetector.DetectOs(); string retval = null; string baseDir = AppDomain.CurrentDomain.BaseDirectory; if (os == OsDetector.OsSelection.Unix) { // TestData folder before base dir setup.Add("PATH", "/usr/local/bin:/usr/bin:" + folder_testdata + ":" + baseDir); EnvVarSearch search = new EnvVarSearch(setup); retval = search.FindInPath("EnvVarSearch_File.txt"); } else if (os == OsDetector.OsSelection.Windows) { setup.Add("path", @"C:\Windows\system32;C:\Windows;" + folder_testdata + ";" + baseDir); EnvVarSearch search = new EnvVarSearch(setup); retval = search.FindInPath("EnvVarSearch_File.txt"); } else { Assert.Fail("Bad platform"); } Assert.NotNull(retval, "The path should have been found"); Assert.AreEqual(Path.Combine(folder_testdata, "EnvVarSearch_File.txt"), retval, "The path found should be the TestData foldfer"); }
public void EnvVarSearch_FindInPath_NotFound() { Dictionary <string, string> setup = new Dictionary <string, string>(); OsDetector.OsSelection os = OsDetector.DetectOs(); bool isFound = false; if (os == OsDetector.OsSelection.Unix) { setup.Add("PATH", "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"); EnvVarSearch search = new EnvVarSearch(setup); isFound = search.IsPathInEnv("/home/test/folder"); } else if (os == OsDetector.OsSelection.Windows) { setup.Add("path", @"C:\Windows\system32;C:\Windows"); EnvVarSearch search = new EnvVarSearch(setup); isFound = search.IsPathInEnv(@"C:\home\test\folder"); } else { Assert.Fail("Bad platform"); } Assert.IsFalse(isFound, "The path should not have been found"); }
public void EnvVarSearch_FindInPath_NotFound_Folder() { Dictionary <string, string> setup = new Dictionary <string, string>(); OsDetector.OsSelection os = OsDetector.DetectOs(); string retval = null; if (os == OsDetector.OsSelection.Unix) { setup.Add("PATH", "/usr/local/bin:/usr/bin"); EnvVarSearch search = new EnvVarSearch(setup); retval = search.FindInPath(@"FooBarSomethingFolder/"); } else if (os == OsDetector.OsSelection.Windows) { setup.Add("path", @"C:\Windows\system32;C:\Windows"); EnvVarSearch search = new EnvVarSearch(setup); retval = search.FindInPath(@"FooBarSomethingFolder/"); } else { Assert.Fail("Bad platform"); } Assert.IsNull(retval, "The path should not have been found"); }
public void EnvVarSearch_FindInPath_Valid_Folder() { Dictionary <string, string> setup = new Dictionary <string, string>(); OsDetector.OsSelection os = OsDetector.DetectOs(); string retval = null; if (os == OsDetector.OsSelection.Unix) { setup.Add("PATH", "/usr/local/bin:/usr/bin:" + AppDomain.CurrentDomain.BaseDirectory); EnvVarSearch search = new EnvVarSearch(setup); retval = search.FindInPath(@"TestData/"); } else if (os == OsDetector.OsSelection.Windows) { setup.Add("path", @"C:\Windows\system32;C:\Windows;" + AppDomain.CurrentDomain.BaseDirectory); EnvVarSearch search = new EnvVarSearch(setup); retval = search.FindInPath(@"TestData\"); } else { Assert.Fail("Bad platform"); } Assert.NotNull(retval, "The path should have been found"); }
public void OsD_SetOs_Win32() { OsDetector.SetOS(testOsWin32); OsDetector.OsSelection selectedOS = OsDetector.DetectOs(); Assert.AreEqual(selectedOS, OsDetector.OsSelection.Windows, "OS detected is not as expected"); Assert.AreEqual(OsDetector.currentOs, OsDetector.OsSelection.Windows); }
public void OsD_SetOs_Mac() { OsDetector.SetOS(testOsMac); OsDetector.OsSelection selectedOS = OsDetector.DetectOs(); Assert.AreEqual(selectedOS, OsDetector.OsSelection.Mac, "OS detected is not as expected"); Assert.AreEqual(OsDetector.currentOs, OsDetector.OsSelection.Mac); }
public override void DataPrepare() { OsDetector.OsSelection os = OsDetector.DetectOs(); if (os == OsDetector.OsSelection.Unix) { runnerFile = "mono"; runnerArgs = "DummyRunner-Linux.exe "; AddInputFile(Path.Combine(folder_testdata, "DummyRunner-Linux.exe"), true, false); } else if (os == OsDetector.OsSelection.Windows) { runnerFile = "DummyRunner-Windows.exe"; runnerArgs = ""; AddInputFile(Path.Combine(folder_testdata, "DummyRunner-Windows.exe"), true, false); } else { // do nothing, unsuported } }