Esempio n. 1
0
        public void GetChild()
        {
            var notification = new Notification();
            var child = new Notification();
            notification.AddChild("something", child);

            Assert.AreSame(child, notification.GetChild("something"));
        }
        public void add_child()
        {
            var child = new Notification();
            child.RegisterMessage<ContactModel>(x => x.FirstName, ValidationKeys.REQUIRED);
            child.RegisterMessage<ContactModel>(x => x.LastName, ValidationKeys.REQUIRED);

            var notification = new Notification(typeof (CompositeModel));
            var property = ReflectionHelper.GetAccessor<CompositeModel>(x => x.Contact);

            notification.AddChild(property, child);

            notification.MessagesFor<CompositeModel>(x => x.Contact.FirstName).Single().StringToken.ShouldEqual(ValidationKeys.REQUIRED);
            notification.MessagesFor<CompositeModel>(x => x.Contact.LastName).Single().StringToken.ShouldEqual(ValidationKeys.REQUIRED);
        }
Esempio n. 3
0
        public void add_child()
        {
            var child = new Notification();

            child.RegisterMessage <ContactModel>(x => x.FirstName, ValidationKeys.Required);
            child.RegisterMessage <ContactModel>(x => x.LastName, ValidationKeys.Required);

            var notification = new Notification(typeof(CompositeModel));
            var property     = ReflectionHelper.GetAccessor <CompositeModel>(x => x.Contact);

            notification.AddChild(property, child);

            notification.MessagesFor <CompositeModel>(x => x.Contact.FirstName).Single().StringToken.ShouldEqual(ValidationKeys.Required);
            notification.MessagesFor <CompositeModel>(x => x.Contact.LastName).Single().StringToken.ShouldEqual(ValidationKeys.Required);
        }
Esempio n. 4
0
        public void FlattenA3DeepNotification()
        {
            Notification notification = new  Notification();
            notification.RegisterMessage("f1", "hello", Severity.Error);

            Notification child = new Notification();
            child.RegisterMessage("f3", "something", Severity.Warning);

            notification.AddChild("f2", child);

            Notification grandchild = new Notification();
            grandchild.RegisterMessage("f4", "bad", Severity.Error);

            child.AddChild("f5", grandchild);

            Notification flat = notification.Flatten();
            flat.AllMessages.Length.ShouldEqual(3);
        }
Esempio n. 5
0
        public void IsTopLevelValid()
        {
            var notification = new Notification();
            var child = new Notification();
            notification.AddChild("something", child);
            child.RegisterMessage("f1", "bad", Severity.Error);

            notification.IsTopLevelValid().ShouldBeTrue();

            notification.RegisterMessage("f2", "not bad", Severity.Warning);
            notification.IsTopLevelValid().ShouldBeTrue();

            notification.RegisterMessage("f2", "really bad", Severity.Error);
            notification.IsTopLevelValid().ShouldBeFalse();
        }
Esempio n. 6
0
        public void UseChildInIsValidForFieldDetermination()
        {
            var notification = new Notification();
            notification.IsValid("field1").ShouldBeTrue();

            var child = new Notification();
            notification.AddChild("something", child);

            notification.IsValid("field1").ShouldBeTrue();

            child.RegisterMessage("field1", "bad value!", Severity.Error);

            notification.IsValid("field1").ShouldBeFalse();
            notification.IsValid("different").ShouldBeTrue();
        }