Пример #1
0
        /// <summary>
        /// Private helper method to return the TesteeAttribute.Value for a given
        /// name, context.  String.Empty if the TesteeAttribute doesn't exist.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        private string GetAttributeValueAsString(string name, TesteeProperty.PropertyContext context)
        {
            string          value = String.Empty;
            TesteeAttribute a     = GetAttribute(name, context);

            if (a != null)
            {
                value = a.Value;
            }
            return(value);
        }
Пример #2
0
        /// <summary>
        /// Add a TesteeAttribute to this Testee.  Returns true if the name/context combination was
        /// added to the collection.  Returns false if it already existed and was not added.
        /// </summary>
        /// <param name="a"></param>
        /// <returns></returns>
        public bool AddAttribute(TesteeAttribute a)
        {
            bool added = false;

            if (!TesteeAttributes.Contains(a))
            {
                TesteeAttributes.Add(a);
                TesteeAttributes.Sort();
                added = true;
            }
            return(added);
        }
Пример #3
0
        /// <summary>
        /// Returns the first TesteeAttribute by name and context given a list of TesteeProperty.PropertyContexts
        /// in order of priority.  Will start with the first element in the list; if that context
        /// is not in the collection, it'll try the 2nd, and so on until a TesteeAttribute is found.  If
        /// no TesteeAttribute is found in the collection, null is returned.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="contextPriority"></param>
        /// <returns></returns>
        public TesteeAttribute GetAttribute(string name, List <TesteeProperty.PropertyContext> contextPriority)
        {
            TesteeAttribute a = null;

            foreach (TesteeProperty.PropertyContext context in contextPriority)
            {
                a = TesteeAttributes.FirstOrDefault(x => x.Name.Equals(name) && x.Context.Equals(context.ToString()));
                if (a != null)
                {
                    break;
                }
            }

            return(a);
        }