public void Validate_Empty_ReturnsTrue()
        {
            var group = new ValidatableGroup();

            var result = group.Validate();

            Assert.True(result);
        }
        public void Validate_NotEmpty_ReturnsValue(bool validationResult)
        {
            var obj1  = CreateValidatableObject(validationResult);
            var group = new ValidatableGroup(obj1);

            var result = group.Validate();

            Assert.Equal(validationResult, result);
        }
        public void Validate_NotEmpty_ReturnsCorrectValue()
        {
            var obj1  = CreateValidatableObject(true);
            var obj2  = CreateValidatableObject(false);
            var group = new ValidatableGroup(obj1, obj2);

            var result = group.Validate();

            Assert.False(result);
        }
        public void Validate_NotEmpty_AllChecked()
        {
            var obj1  = CreateValidatableObject(false);
            var obj2  = CreateValidatableObject(true);
            var group = new ValidatableGroup(obj1, obj2);

            group.Validate();

            obj1.Received(1).Validate();
            obj2.Received(1).Validate();
        }
Beispiel #5
0
        public ValidationPageViewModel()
        {
            UserName = new ValidatableObject <string>();
            UserName.AddRule(new StringNotEmptyRule("A username is required."));
            UserName.AddRule(new StringLengthRule(3, 10, "Username must be 3-10 characters."));

            Email = new ValidatableObject <string>();
            Email.AddRule(new StringNotEmptyRule("Email is required."));
            Email.AddRule(new EmailRule("Invalid Email."));

            TermsAndCondition = new ValidatableObject <bool>();
            TermsAndCondition.AddRule(new IsValueTrueRule("Please accept terms and condition"));

            _validationGroup = new ValidatableGroup(UserName, Email, TermsAndCondition);

            CheckNameCommand = new RelayCommand(CheckName);
            SubmitCommand    = new AsyncCommand(SubmitAsync);
        }