/// <summary>
        /// Gets a message describing whether or not the condition is fulfilled.
        /// </summary>
        /// <remarks>
        /// If the condition is fulfilled the message is "Passed." If the condition is not fulfilled the
        /// message uses the pattern:
        ///		File '&lt;file>' is not &lt;state>.
        /// </remarks>
        /// <param name="coreDelegates">The Core delegates component.</param>
        /// <param name="invert">Invert the logic in the message, explaining why it passed instead of why not</param>
        /// <returns>A message describing whether or not the condition is fulfilled.</returns>
        /// <seealso cref="ICondition.GetMessage(CoreDelegates)"/>
        public string GetMessage(ConditionStateManager csmState, CoreDelegates coreDelegates, bool invert)
        {
            bool       booAllFulfilled  = (Operator == ConditionOperator.And) ? true : false;
            bool       booThisFulfilled = true;
            ICondition conCondition     = null;

            List <string> lines = new List <string>();

            for (Int32 i = 0; i < m_lstConditions.Count; i++)
            {
                conCondition     = m_lstConditions[i];
                booThisFulfilled = conCondition.GetIsFulfilled(csmState, coreDelegates);
                if (!booThisFulfilled)
                {
                    lines.Add(conCondition.GetMessage(csmState, coreDelegates, invert));
                }

                booAllFulfilled = Operator == ConditionOperator.And
          ? booAllFulfilled & booThisFulfilled
          : booAllFulfilled | booThisFulfilled;
            }

            string sep     = (Operator == ConditionOperator.Or) ? " OR\n" : "\n";
            string message = string.Join(sep, lines);

            return(booAllFulfilled && !invert ? "Passed" : message);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets a message describing whether or not the condition is fulfilled.
        /// </summary>
        /// <remarks>
        /// If the condition is fulfilled the message is "Passed." If the condition is not fulfilled the
        /// message uses the pattern:
        ///		File '&lt;file>' is not &lt;state>.
        /// </remarks>
        /// <param name="coreDelegates">The Core delegates component.</param>
        /// <returns>A message describing whether or not the condition is fulfilled.</returns>
        /// <seealso cref="ICondition.GetMessage(CoreDelegates)"/>
		public string GetMessage(ConditionStateManager csmState, CoreDelegates coreDelegates)
		{
			StringBuilder stbMessage = new StringBuilder();
			if (m_dopOperator == ConditionOperator.Or)
				stbMessage.Append("(");

			bool booAllFulfilled = (m_dopOperator == ConditionOperator.And) ? true : false;
			bool booThisFulfilled = true;
			ICondition conCondition = null;
			for (Int32 i = 0; i < m_lstConditions.Count; i++)
			{
				conCondition = m_lstConditions[i];
				booThisFulfilled = conCondition.GetIsFulfilled(csmState, coreDelegates);
				if (!booThisFulfilled)
					stbMessage.Append(conCondition.GetMessage(csmState, coreDelegates));
				switch (m_dopOperator)
				{
					case ConditionOperator.And:
						if (i < m_lstConditions.Count - 1)
							stbMessage.AppendLine();
						booAllFulfilled &= booThisFulfilled;
						break;
					case ConditionOperator.Or:
						if (i < m_lstConditions.Count - 1)
							stbMessage.AppendLine(" OR");
						booAllFulfilled |= booThisFulfilled;
						break;
				}
			}
			if (m_dopOperator == ConditionOperator.Or)
				stbMessage.Append(")");
			return booAllFulfilled ? "Passed" : stbMessage.ToString();
		}