コード例 #1
0
        public void RuleDecoratorExecuted()
        {
            var e = new RuleInitializerEntity();
            e.Extensions.InitializeRules();

            RuleInitializerEntity.DecoratorExecuted.ShouldBeTrue();
        }
コード例 #2
0
 public void PropertiesTest()
 {
     var e = new RuleInitializerEntity();
     e.Extensions.DynamicProperties["abc"] = 5;
     e.Extensions.DynamicProperties["x"] = 5;
     RuleInitializerEntity.PropertiesExecuted.ShouldBeTrue();
 }
コード例 #3
0
 public void RangeAttributeTest()
 {
     var e = new RuleInitializerEntity();
     e.Extensions.InitializeRules();
     e.Value2 = 33;
     e.Value3 = 34;
     e.Extensions.BrokenRules.Count.ShouldEqual(2);
 }
コード例 #4
0
 public void AttributeRules()
 {
     var e = new RuleInitializerEntity();
     e.Extensions.InitializeRules();
     e.Email = "a";
     e.Extensions.BrokenRules.ShouldContains("Email", 1);
     e.Email = "*****@*****.**";
     e.Extensions.BrokenRules.ShouldContains("Email", 0);
 }
コード例 #5
0
        public void CompareTest()
        {
            var e = new RuleInitializerEntity();
            e.Extensions.InitializeRules();

            e.Password = "******";

            //e.Extensions.Validate();
            e.Extensions.BrokenRules.Count.ShouldEqual(1);

        }
コード例 #6
0
        public void CollectionIsValid()
        {
            var entity = new Entity();
            entity.Extensions.CreateValidationRule(en => en.Number == 0).Start();

            var e = new RuleInitializerEntity {Entities2 = {entity}};
            e.Extensions.IsValid.ShouldBeTrue();

            entity.Number = 4;
            e.Extensions.IsValid.ShouldBeFalse();
        }
コード例 #7
0
        public void RecursiveValidation()
        {
            var entity = new Entity();
            entity.Extensions.CreateValidationRule(en => en.Number == 0).Start();

            var e = new RuleInitializerEntity{Entity = entity};
            e.Extensions.Validate().ShouldBeTrue();

            entity.Number = 4;
            e.Extensions.Validate().ShouldBeFalse();
        }
コード例 #8
0
 public void RuleInit2Executed()
 {
     try
     {
         var e = new RuleInitializerEntity();
         var c = new Child();
         c.Parent = e;
         e.Child = c;
         e.Extensions.InitializeRules();
         e.Inited.ShouldBeTrue();
     }
     catch (StackOverflowException e)
     {
         Console.WriteLine(e);
     }
 }