Пример #1
0
        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");
        }
Пример #2
0
        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");
        }
Пример #3
0
        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");
        }
Пример #4
0
        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");
        }