Esempio n. 1
0
        public void TestErrorType()
        {
            EnvironmentValueType type
                = this.validator.ValueType(@"C:\12345");

            Assert.AreEqual(EnvironmentValueType.Error, type);
        }
Esempio n. 2
0
        /// <summary>
        /// Check the type of the Environment Variable.
        /// </summary>
        /// <param name="varValue">The Variable Value.</param>
        /// <returns>Variable Type</returns>
        public EnvironmentValueType ValueType(string varValue)
        {
            EnvironmentValueType type = EnvironmentValueType.String;

            if (IsNumber(varValue))
            {
                type = EnvironmentValueType.Number;
            }
            else if (varValue.Length >= 3 && varValue.Substring(0, 3).Contains(@":\"))
            {   // Make sure that path starts with "C:\" where "C" is a drive letter
                if (System.IO.File.Exists(varValue))
                {
                    type = EnvironmentValueType.File;
                }
                else if (System.IO.Directory.Exists(varValue))
                {
                    type = EnvironmentValueType.Folder;
                }
                else
                {
                    type = EnvironmentValueType.Error;
                }
            }

            return(type);
        }
Esempio n. 3
0
        public void TestFolderType()
        {
            EnvironmentValueType type
                = this.validator.ValueType(@"C:\Windows");

            Assert.AreEqual(EnvironmentValueType.Folder, type);
        }
Esempio n. 4
0
        public void TestStringType()
        {
            EnvironmentValueType type
                = this.validator.ValueType("This is a string value");

            Assert.AreEqual(EnvironmentValueType.String, type);
        }
Esempio n. 5
0
        public void TestFileType()
        {
            string fileName = @"C:\EnvMan.test";

            // create temp file for a test
            FileStream file = File.Create(fileName);

            file.Close();

            // Test
            EnvironmentValueType type = this.validator.ValueType(fileName);

            Assert.AreEqual(EnvironmentValueType.File, type);

            // remove temp file after completing a test
            File.Delete(fileName);
        }
Esempio n. 6
0
        public void TestFloatNumberType()
        {
            EnvironmentValueType type = this.validator.ValueType("10.50");

            Assert.AreEqual(EnvironmentValueType.Number, type);
        }
        public void TestFullNumberType()
        {
            EnvironmentValueType type = validator.ValueType("10");

            Assert.AreEqual(EnvironmentValueType.Number, type);
        }