public string ToStringCondition(string indent = " ") { String scratch = ""; if (conditions.Count != 0) { switch (Logic) { case eLogic.elUndef: scratch = " UNSET"; log.Error("unset logic for test condition"); break; case eLogic.eAND: scratch = indent + "if all of the following are true: {"; break; case eLogic.eOR: scratch = indent + "if any of the following are true: {"; break; default: scratch = " UNKNOWN"; log.Error("Unknown logic for test condition"); break; } scratch += "\n"; foreach (var cond in conditions) { scratch += cond.ToStringCondition(indent + " "); scratch += "\n"; } scratch += indent + "}"; } else { scratch += indent + TestParam1.GetName() + " " + conditional + " " + TestParam2.GetName(); } return(scratch); }
public bool Evaluate() { bool pass = false; if (TestParam1 == null) { if (Logic == eLogic.eAND) { pass = true; foreach (var cond in conditions) { if (!cond.Evaluate()) { pass = false; } } } else { // Logic must be eOR pass = false; foreach (var cond in conditions) { if (cond.Evaluate()) { pass = true; } } } } else { double compareValue = TestParam2.GetValue(); switch (Comparison) { case eComparison.ecUndef: log.Error("Undefined comparison operator."); break; case eComparison.eEQ: pass = TestParam1.GetDoubleValue() == compareValue; break; case eComparison.eNE: pass = TestParam1.GetDoubleValue() != compareValue; break; case eComparison.eGT: pass = TestParam1.GetDoubleValue() > compareValue; break; case eComparison.eGE: pass = TestParam1.GetDoubleValue() >= compareValue; break; case eComparison.eLT: pass = TestParam1.GetDoubleValue() < compareValue; break; case eComparison.eLE: pass = TestParam1.GetDoubleValue() <= compareValue; break; default: log.Error("Unknown comparison operator."); break; } } return(pass); }
public bool Evaluate() { bool pass = false; double compareValue; if (Logic == eLogic.eAND) { pass = true; foreach (Condition iConditions in conditions) { if (!iConditions.Evaluate()) { pass = false; } } } else if (Logic == eLogic.eOR) { pass = false; foreach (Condition iConditions in conditions) { if (iConditions.Evaluate()) { pass = true; } } } else { if (TestParam2 != null) { compareValue = TestParam2.GetDouble(); } else { compareValue = TestValue; } switch (Comparison) { case eComparison.ecUndef: if (log.IsErrorEnabled) { log.Error("Undefined comparison operator."); } break; case eComparison.eEQ: pass = TestParam1.GetDouble() == compareValue; break; case eComparison.eNE: pass = TestParam1.GetDouble() != compareValue; break; case eComparison.eGT: pass = TestParam1.GetDouble() > compareValue; break; case eComparison.eGE: pass = TestParam1.GetDouble() >= compareValue; break; case eComparison.eLT: pass = TestParam1.GetDouble() < compareValue; break; case eComparison.eLE: pass = TestParam1.GetDouble() <= compareValue; break; default: if (log.IsErrorEnabled) { log.Error("Unknown comparison operator."); } break; } } return(pass); }