예제 #1
0
        public void when_there_is_an_exception_during_validation_then_the_exception_is_diplayed_in_the_valiation_result()
        {
            var testSchedulerProvider = new TestDispatcherSchedulerProvider();

            var validatingObject = new ErrorValidatingObject();

            var sut = new ValidationAsync <ErrorValidatingObject, ErrorValidatingObjectValidator>(testSchedulerProvider);

            sut.Initialise(validatingObject);

            sut.ValidateProperty(() => validatingObject.ErrorValidating);

            var validationResults = sut.GetErrors("ErrorValidating").OfType <string>().ToList();

            Assert.That(validationResults.Count(), Is.EqualTo(1));
            Assert.That(validationResults[0], Is.EqualTo(string.Format("Error during validation : {0}", ErrorValidatingObjectValidator.TestException)));
        }
예제 #2
0
        public void when_a_property_is_invalid_then_GetErrors_return_the_correct_validation_results()
        {
            var testSchedulerProvider = new TestDispatcherSchedulerProvider();

            var validatingObject = new ValidatingObject();

            var sut = new ValidationAsync <ValidatingObject, ValidatingObjectValidator>(testSchedulerProvider);

            sut.Initialise(validatingObject);

            sut.ValidateProperty(() => validatingObject.Name);

            var validationResults = sut.GetErrors("Name").OfType <string>().ToList();

            Assert.That(validationResults.Count(), Is.EqualTo(1));
            Assert.That(validationResults[0], Is.EqualTo("'Name' must not be empty."));
        }