예제 #1
0
 public void GetJoinedMessage()
 {
     var notification = new Notification();
     notification.Register("field1", "message1");
     notification.Register("field1", "message2");
     Assert.AreEqual("message1, message2", notification.GetMessageFor("field1", ", "));
 }
예제 #2
0
 public void FieldsWithErrors()
 {
     var notification = new Notification();
     notification.Register("field1", "message1");
     notification.Register("field2", "message2");
     Assert.AreEqual(new[] { "field1", "field2" }, notification.GetFieldsWithMessages());
 }
예제 #3
0
        public void GetMessages()
        {
            var notification = new Notification();
            notification.Register("field1", "message1");
            notification.Register("field2", "message2");
            notification.Register("field1", "message3");

            var messages = notification.GetMessagesFor("field1");
            Assert.AreEqual(new[] { "message1", "message3" }, messages);
        }
예제 #4
0
 public void HasMessage()
 {
     var notification = new Notification();
     Assert.IsFalse(notification.HasMessage("field", "message"), "message should not exist yet");
     notification.Register("field", "message");
     Assert.IsTrue(notification.HasMessage("field", "message"), "message should exist");
 }
예제 #5
0
 public void IsNotValidWhenNotEmpty()
 {
     var notification = new Notification();
     notification.Register("field", "message");
     Assert.IsFalse(notification.IsValid);
 }
예제 #6
0
 public void Validate(object target, Notification notification)
 {
     var rawValue = Property.GetValue(target, null);
     if (!IsValid(rawValue))
         notification.Register(Property.Name, Message);
 }