Esempio n. 1
0
        public void AbstractViewModel_it_should_be_possible_to_change_a_validatable_property_at_custom_validation_time()
        {
            var sut = new SampleTestViewModelWithValidationCallback();
            var svc = DataAnnotationValidationService.CreateFor(sut);

            sut.ValidateUsing(svc, forceIsValidationEnabledTo: true);
            sut.Test_OnValidate = ctx =>
            {
                sut.AnotherOne = "fail";
            };

            sut.NotNullNotEmpty = "a value";
        }
Esempio n. 2
0
        public void AbstractViewModel_it_should_be_possible_to_change_a_validatable_property_in_the_validated_event()
        {
            var sut = new SampleTestViewModel();
            var svc = DataAnnotationValidationService.CreateFor(sut);

            sut.ValidateUsing(svc, forceIsValidationEnabledTo: true);
            sut.Validated += (s, e) =>
            {
                sut.AnotherOne = "fail";
            };

            sut.NotNullNotEmpty = "a value";
        }
Esempio n. 3
0
        public void AbstractMementoViewModel_it_should_be_possible_to_change_a_validatable_property_in_a_custom_validation_rule()
        {
            var sut = new SampleTestViewModel();
            var svc = DataAnnotationValidationService.CreateFor(sut);

            svc.AddRule(
                property: () => sut.NotNullNotEmpty,
                error: ctx => "error",
                rule: ctx =>
            {
                sut.AnotherOne = "fail";

                return(true);
            });

            sut.ValidateUsing(svc, forceIsValidationEnabledTo: true);

            sut.NotNullNotEmpty = "a value";
        }