ValidationRule checks a specified predicate and creates a BrokenRule if necessary.

[Test]
public void FuncValidationRule()
{
    var e = new Entity();
    e.Extensions.CreateValidationRule(en => en.Name != "name")
        .WithMessage("error text")
        .WithSeverity(BrokenRuleSeverity.Error)
        .Start();

    e.Name = "abc";
    e.Extensions.BrokenRules.Count.ShouldEqual(0);
            
    e.Name = "name";
    e.Extensions.BrokenRules.Count.ShouldEqual(1);
}

Last edited Oct 14, 2010 at 7:45 PM by michalmac, version 1

Comments

No comments yet.