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_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_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"); }