Beispiel #1
0
		public void Test_Validate_validation_enabled_via_overriding_attribute()
		{
			try
			{
				var foo = new FooG() { Name = "Bethany" };
				var validator = new DomainObjectValidator();
				validator.Validate(foo);

				Assert.Fail("expected validation failure");
			}
			catch (EntityValidationException e)
			{
				// note:exactly 2 broken rules: this is important!!!
				// even though one of the rules was defined on a property of the base class,
				// and validation is disabled on the base class, the rule is still
				// evaluated for the subclass FooG which has validation enabled
				Assert.AreEqual(2, e.Reasons.Length);
			}
		}
		public void Test_Validate_validation_enabled_via_overriding_attribute()
		{
			try
			{
				var foo = new FooG() { Name = "Bethany" };
				var validator = new DomainObjectValidator();
				validator.Validate(foo);

				Assert.Fail("expected validation failure");
			}
			catch (EntityValidationException e)
			{
				// note:exactly 2 broken rules: this is important!!!
				// even though one of the rules was defined on a property of the base class,
				// and validation is disabled on the base class, the rule is still
				// evaluated for the subclass FooG which has validation enabled
				Assert.AreEqual(2, e.Reasons.Length);
			}
		}