コード例 #1
0
        public static void Initialize(string filePath, List <Type> knownTypes)
        {
            TestAssert.IsFalse(string.IsNullOrEmpty(filePath), "The file path cannot be a null or empty value.");

            Initialize();

            TestPropertiesFile = filePath;

            if (knownTypes == null)
            {
                knownTypes = new List <Type>();
            }

            var tempCollection = deserializeFromFile(filePath, knownTypes);

            foreach (TestProperty property in tempCollection)
            {
                if (property is TestSystemProperty)
                {
                    SetPropertyValue(property.Name, property.Value);
                }
                else
                {
                    AddProperty(property);
                }
            }

            FireTestPropertiesInitializedEvent();
        }
コード例 #2
0
        public TestParameter(string name, string displayName, object value, Type type)
        {
            TestAssert.IsFalse(string.IsNullOrEmpty(name), "The parameter name cannot be a null or empty value.");
            TestAssert.IsFalse(string.IsNullOrEmpty(displayName), "The parameter display name cannot be a null or empty value.");

            Name          = name;
            DisplayName   = displayName;
            ValueAsString = value != null?value.ToString() : null;

            TypeAsString = type.FullName;
        }
コード例 #3
0
        /// <summary>
        /// Iteratively processes a string all property callouts with actual property values.
        /// </summary>
        /// <param name="source"></param>
        /// <returns></returns>
        public static string ExpandString(string source, bool ignoreEscaped)
        {
            TestAssert.IsNotNull(_testPropertyCollection, "The TestProperties collection must be initialized before use.");
            TestAssert.IsFalse(string.IsNullOrEmpty(source), "The target string key cannot be a null or empty value.");

            //source = GetPropertyValueAsString(source, source);

            string leftEscapeToken  = "&@#!~?^";
            string rightEscapeToken = "!@*&%+";

            string target        = source;
            bool   macroExpanded = false;

            TestProperty testProperty;

            if (source.ToUpper() == "[NULL]")
            {
                target = null;
            }
            else if (source.ToUpper() == "[EMPTYSTRING]")
            {
                target = "";
            }
            else
            {
                string macro = StripMacro(source, ignoreEscaped);

                if (null != macro)
                {
                    if (_testPropertyCollection.TryGetValue(macro, out testProperty))
                    {
                        if (testProperty.Value is string)
                        {
                            target        = target.Replace(string.Format("[{0}]", macro), (string)testProperty.Value);
                            macroExpanded = true;
                        }
                    }
                }

                if (macroExpanded)
                {
                    target = ExpandString(target, ignoreEscaped);
                }

                target = target.Replace(leftEscapeToken, "[");
                target = target.Replace(rightEscapeToken, "]");
            }

            return(target);
        }