public void Validation_Of_Field_When_Invalid_Should_Fail()
        {
            var model = new MockModelWithValidation() { Title = string.Empty };
            var target = new BindableValidator(model);

            bool isValid = target.ValidateProperty("Title");

            Assert.IsFalse(isValid);
            Assert.IsFalse(target.GetAllErrors().Values.Count == 0);
        }
        public void Validation_Of_Field_When_Valid_Should_Succeeed()
        {
            var model = new MockModelWithValidation() { Title = "A valid Title" };
            var target = new BindableValidator(model);

            bool isValid = target.ValidateProperty("Title");

            Assert.IsTrue(isValid);
            Assert.IsTrue(target.GetAllErrors().Values.Count == 0);
        }
Пример #3
0
        public void Validation_Of_Field_When_Invalid_Should_Fail()
        {
            var model = new MockModelWithValidation()
            {
                Title = string.Empty
            };
            var target = new BindableValidator(model);

            bool isValid = target.ValidateProperty("Title");

            Assert.IsFalse(isValid);
            Assert.IsFalse(target.GetAllErrors().Values.Count == 0);
        }
Пример #4
0
        public void Validation_Of_Field_When_Valid_Should_Succeeed()
        {
            var model = new MockModelWithValidation()
            {
                Title = "A valid Title"
            };
            var target = new BindableValidator(model);

            bool isValid = target.ValidateProperty("Title");

            Assert.IsTrue(isValid);
            Assert.IsTrue(target.GetAllErrors().Values.Count == 0);
        }
Пример #5
0
        public void Validation_Of_A_Nonexistent_Property_Should_Throw()
        {
            var model  = new MockModelWithValidation();
            var target = new BindableValidator(model, (mapId, key) => "ErrorMessage");

            var exception = Assert.ThrowsException <ArgumentException>(() =>
            {
                target.ValidateProperty("DoesNotExist");
            });
            const string expectedMessage = "ErrorMessage\r\nParameter name: DoesNotExist";

            Assert.AreEqual(expectedMessage, exception.Message);
        }
        public void Validation_Of_A_Nonexistent_Property_Should_Throw()
        {
            var model = new MockModelWithValidation();
            var target = new BindableValidator(model);
   
           var exception = Assert.ThrowsException<ArgumentException>(() =>
                                       {
                                           target.ValidateProperty("DoesNotExist");
                                       });
            const string expectedMessage = "The entity does not contain a property with that name\r\nParameter name: DoesNotExist";

            Assert.AreEqual(expectedMessage, exception.Message);
        }
Пример #7
0
 public bool ValidateProperty(string propertyName)
 {
     return(_bindableValidator.ValidateProperty(propertyName));
 }