示例#1
0
        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");
        }
示例#2
0
        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");
        }
示例#3
0
        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");
        }
示例#4
0
        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");
        }
示例#5
0
        public void EnvVarSearch_GetDictionary()
        {
            EnvVarSearch search = new EnvVarSearch();

            Assert.Greater(search.GetDictionary().Count, 0, "Dictionary Size should be greater than 0");
        }