public void ShortCircuitOnNew() { ShortCircuit root = new ShortCircuit(); root.CheckRules(); Assert.AreEqual(1, root.BrokenRulesCollection.ErrorCount, "Only one rule should be broken"); Assert.AreEqual("Test required", root.BrokenRulesCollection.GetFirstBrokenRule("Test").Description, "'Test required' should be broken"); }
public void ShortCircuitOnNew() { IDataPortal <ShortCircuit> dataPortal = _testDIContext.CreateDataPortal <ShortCircuit>(); ShortCircuit root = dataPortal.Create(); root.CheckRules(); Assert.AreEqual(1, root.BrokenRulesCollection.ErrorCount, "Only one rule should be broken"); Assert.AreEqual("Test required", root.BrokenRulesCollection.GetFirstBrokenRule("Test").Description, "'Test required' should be broken"); }
public void ShortCircuitOnPropertySet() { ShortCircuit root = new ShortCircuit(); root.CheckRules(); root.Test = "some data"; Assert.AreEqual(1, root.BrokenRulesCollection.ErrorCount, "Only one rule should be broken with data"); Assert.AreEqual("Always error", root.BrokenRulesCollection.GetFirstBrokenRule("Test").Description, "'Always fails' should be broken"); root.Test = ""; Assert.AreEqual(1, root.BrokenRulesCollection.ErrorCount, "Only one rule should be broken when empty"); Assert.AreEqual("Test required", root.BrokenRulesCollection.GetFirstBrokenRule("Test").Description, "'Test required' should be broken"); }
public void HigherThreshold() { ShortCircuit root = new ShortCircuit(); root.CheckRules(); Assert.AreEqual(1, root.BrokenRulesCollection.ErrorCount, "Only one rule should be broken"); Assert.AreEqual("Test required", root.BrokenRulesCollection.GetFirstBrokenRule("Test").Description, "'Test required' should be broken"); root.Threshold = 100; root.CheckRules(); Assert.AreEqual(2, root.BrokenRulesCollection.ErrorCount, "Two rules should be broken after checkrules"); root.Test = "some data"; Assert.AreEqual(1, root.BrokenRulesCollection.ErrorCount, "One rule should be broken with data"); Assert.AreEqual("Always error", root.BrokenRulesCollection.GetFirstBrokenRule("Test").Description, "'Always fails' should be broken"); root.Test = ""; Assert.AreEqual(2, root.BrokenRulesCollection.ErrorCount, "Two rules should be broken when empty"); }