public void MultipleANDFail2() { BooleanCondition bc = new BooleanCondition(); bc.AddCondition(new MockCondition(true), BooleanCondition.ConditionType.AND); bc.AddCondition(new MockCondition(false), BooleanCondition.ConditionType.AND); bool isMet = bc.IsMet(null); Assert.IsFalse(isMet); }
public void LastORPass() { BooleanCondition bc = new BooleanCondition(); bc.AddCondition(new MockCondition(false), BooleanCondition.ConditionType.AND); bc.AddCondition(new MockCondition(false), BooleanCondition.ConditionType.AND); bc.AddCondition(new MockCondition(true), BooleanCondition.ConditionType.OR); bool isMet = bc.IsMet(null); Assert.IsTrue(isMet); }
public void ShortCircuitOR() { BooleanCondition bc = new BooleanCondition(); bc.AddCondition(new MockCondition(true), BooleanCondition.ConditionType.OR); bc.AddCondition(new MockCondition(true), BooleanCondition.ConditionType.OR); bc.AddCondition(new MockCondition(false), BooleanCondition.ConditionType.OR); bool isMet = bc.IsMet(null); Assert.IsTrue(isMet, "Expected the second or to short circuit the condition list"); }
private IUpdateCondition ReadCondition(XmlNode cnd) { IUpdateCondition conditionObject = null; if (cnd.ChildNodes.Count > 0 || "GroupCondition".Equals(cnd.Name)) { BooleanCondition bc = new BooleanCondition(); foreach (XmlNode child in cnd.ChildNodes) { IUpdateCondition childCondition = ReadCondition(child); if (childCondition != null) bc.AddCondition(childCondition, BooleanCondition.ConditionTypeFromString(child.Attributes["type"] == null ? null : child.Attributes["type"].Value)); } if (bc.ChildConditionsCount > 0) conditionObject = bc.Degrade(); } else if (_updateConditions.ContainsKey(cnd.Name)) { conditionObject = (IUpdateCondition)Activator.CreateInstance(_updateConditions[cnd.Name]); // Store all other attributes, to be used by the condition object later foreach (XmlAttribute att in cnd.Attributes) { if ("type".Equals(att.Name)) continue; conditionObject.Attributes.Add(att.Name, att.Value); } } return conditionObject; }
public void Not() { BooleanCondition bc = new BooleanCondition(); bc.AddCondition(new MockCondition(false), BooleanCondition.ConditionType.AND | BooleanCondition.ConditionType.NOT); bool isMet = bc.IsMet(null); Assert.IsTrue(isMet); }