コード例 #1
0
        public void Test_CombinationOfRequiredAndLengthOnSameProperty()
        {
            var builder = new ValidationBuilder(typeof(FooD));
            var ruleSet = builder.LowLevelRules;

            var foo = new FooD();

            // should fail the "required" but not the "length" test
            var result = ruleSet.Test(foo);

            Assert.IsFalse(result.Success);
            Assert.AreEqual(1, result.Reasons.Length);

            // should fail the "length" test but not the "required" test
            foo.Name = "Robert";
            result   = ruleSet.Test(foo);
            Assert.IsFalse(result.Success);
            Assert.AreEqual(1, result.Reasons.Length);

            // should fail neither
            foo.Name = "Bob";
            result   = ruleSet.Test(foo);
            Assert.IsTrue(result.Success);
            Assert.AreEqual(0, result.Reasons.Length);
        }
コード例 #2
0
		public void Test_CombinationOfRequiredAndLengthOnSameProperty()
		{
			var builder = new ValidationBuilder(typeof(FooD));
			var ruleSet = builder.LowLevelRules;

			var foo = new FooD();

			// should fail the "required" but not the "length" test
			var result = ruleSet.Test(foo);
			Assert.IsFalse(result.Success);
			Assert.AreEqual(1, result.Reasons.Length);

			// should fail the "length" test but not the "required" test
			foo.Name = "Robert";
			result = ruleSet.Test(foo);
			Assert.IsFalse(result.Success);
			Assert.AreEqual(1, result.Reasons.Length);

			// should fail neither
			foo.Name = "Bob";
			result = ruleSet.Test(foo);
			Assert.IsTrue(result.Success);
			Assert.AreEqual(0, result.Reasons.Length);
		}