コード例 #1
0
        public void CanNumberRequiredBeEnforcedWithDefaultMessage()
        {
            var rules = new NumberTestSubjectRules();

            var result = rules.Validate(new NumberTestSubject {
            });

            Assert.IsTrue(result.Errors.Any(e => e.Name == "TestNumber3_IsRequired" && e.Message == "The 'TestNumber3' property is required."));
        }
コード例 #2
0
        public void CanNumberRequiredBeEnforcedWithMessage()
        {
            var rules = new NumberTestSubjectRules();

            var result = rules.Validate(new NumberTestSubject {
            });

            Assert.IsTrue(result.Errors.Any(e => e.Name == "TestNumber2_IsRequired"));
        }
コード例 #3
0
        public void CanNumberMinimumBeEnforcedWithMessageLambda()
        {
            var rules       = new NumberTestSubjectRules();
            var testSubject = new NumberTestSubject {
                TestNumber1 = 1
            };

            var result = rules.Validate(testSubject);

            Assert.IsTrue(result.Errors.Any(e => e.Name == "TestNumber1_MinimumValue"));
            testSubject.TestNumber1 = 10;
            result = rules.Validate(testSubject);
            Assert.IsFalse(result.Errors.Any(e => e.Name == "TestNumber1_MinimumValue"));
        }