public void ValueRequestForNonMappedPropertyReturnsFailure()
        {
            Page page = TestContext.RequestedPage;
            PropertyProxyValidator validator = (PropertyProxyValidator)page.FindControl("NameValidator1");

            ValueAccess valueAccess = new PropertyMappedValidatorValueAccess("InvalidProperty");
            object      value;
            string      valueAccessFailureMessage;

            bool accessStatus = valueAccess.GetValue(validator, out value, out valueAccessFailureMessage);

            Assert.IsFalse(accessStatus);
        }
        public void CanGetConvertedValueForPropertyMappedToProvidedValidator()
        {
            Page page = TestContext.RequestedPage;
            PropertyProxyValidator validator = (PropertyProxyValidator)page.FindControl("NumberPropertyValidator");

            ValueAccess valueAccess = new PropertyMappedValidatorValueAccess("NumberProperty");
            object      value;
            string      valueAccessFailureMessage;

            bool accessStatus = valueAccess.GetValue(validator, out value, out valueAccessFailureMessage);

            Assert.IsTrue(accessStatus);
            Assert.AreEqual(012345, value);
        }
        public void CanGetValueForPropertyMappedToOtherValidator()
        {
            Page page = TestContext.RequestedPage;
            PropertyProxyValidator validator = (PropertyProxyValidator)page.FindControl("NameValidator1");

            ValueAccess valueAccess = new PropertyMappedValidatorValueAccess("SurName");
            object      value;
            string      valueAccessFailureMessage;

            bool accessStatus = valueAccess.GetValue(validator, out value, out valueAccessFailureMessage);

            Assert.IsTrue(accessStatus);
            Assert.AreEqual("LogicalOperationStack", value);
        }
        public void CanGetValueForPropertyMappedToValidatorInSameNamingContainerAsProvidedValidator()
        {
            Page page = TestContext.RequestedPage;

            ValueAccess nameValueAccess    = new PropertyMappedValidatorValueAccess("Name");
            ValueAccess surNameValueAccess = new PropertyMappedValidatorValueAccess("SurName");

            foreach (BaseValidator validator in page.Validators)
            {
                PropertyProxyValidator propertyProxyValidator = validator as PropertyProxyValidator;

                if (propertyProxyValidator != null && propertyProxyValidator.ID.Equals("Name_Validator"))
                {
                    object nameValue;
                    object surNameValue;
                    string targetSurNameValue = null;
                    string valueAccessFailureMessage;

                    bool accessStatus
                        = nameValueAccess.GetValue(propertyProxyValidator, out nameValue, out valueAccessFailureMessage);
                    Assert.IsTrue(accessStatus);

                    switch ((string)nameValue)
                    {
                    case "abc":
                        targetSurNameValue = "123";
                        break;

                    case "def":
                        targetSurNameValue = "456";
                        break;

                    case "ghi":
                        targetSurNameValue = "789";
                        break;
                    }

                    accessStatus
                        = surNameValueAccess.GetValue(propertyProxyValidator, out surNameValue, out valueAccessFailureMessage);
                    Assert.IsTrue(accessStatus);
                    Assert.AreEqual(targetSurNameValue, surNameValue);
                }
            }
        }
        public void CanGetConvertedValueForPropertyMappedToProvidedValidator()
        {
            Page page = TestContext.RequestedPage;
            PropertyProxyValidator validator = (PropertyProxyValidator)page.FindControl("NumberPropertyValidator");

            ValueAccess valueAccess = new PropertyMappedValidatorValueAccess("NumberProperty");
            object value;
            string valueAccessFailureMessage;

            bool accessStatus = valueAccess.GetValue(validator, out value, out valueAccessFailureMessage);

            Assert.IsTrue(accessStatus);
            Assert.AreEqual(012345, value);
        }
        public void ValueRequestForNonMappedPropertyReturnsFailure()
        {
            Page page = TestContext.RequestedPage;
            PropertyProxyValidator validator = (PropertyProxyValidator)page.FindControl("NameValidator1");

            ValueAccess valueAccess = new PropertyMappedValidatorValueAccess("InvalidProperty");
            object value;
            string valueAccessFailureMessage;

            bool accessStatus = valueAccess.GetValue(validator, out value, out valueAccessFailureMessage);

            Assert.IsFalse(accessStatus);
        }
        public void CanGetValueForPropertyMappedToValidatorInSameNamingContainerAsProvidedValidator()
        {
            Page page = TestContext.RequestedPage;

            ValueAccess nameValueAccess = new PropertyMappedValidatorValueAccess("Name");
            ValueAccess surNameValueAccess = new PropertyMappedValidatorValueAccess("SurName");

            foreach (BaseValidator validator in page.Validators)
            {
                PropertyProxyValidator propertyProxyValidator = validator as PropertyProxyValidator;

                if (propertyProxyValidator != null && propertyProxyValidator.ID.Equals("Name_Validator"))
                {
                    object nameValue;
                    object surNameValue;
                    string targetSurNameValue = null;
                    string valueAccessFailureMessage;

                    bool accessStatus
                        = nameValueAccess.GetValue(propertyProxyValidator, out nameValue, out valueAccessFailureMessage);
                    Assert.IsTrue(accessStatus);

                    switch ((string)nameValue)
                    {
                        case "abc":
                            targetSurNameValue = "123";
                            break;
                        case "def":
                            targetSurNameValue = "456";
                            break;
                        case "ghi":
                            targetSurNameValue = "789";
                            break;
                    }

                    accessStatus
                        = surNameValueAccess.GetValue(propertyProxyValidator, out surNameValue, out valueAccessFailureMessage);
                    Assert.IsTrue(accessStatus);
                    Assert.AreEqual(targetSurNameValue, surNameValue);
                }
            }
        }
        public void CanGetValueForPropertyMappedToOtherValidator()
        {
            Page page = TestContext.RequestedPage;
            PropertyProxyValidator validator = (PropertyProxyValidator)page.FindControl("NameValidator1");

            ValueAccess valueAccess = new PropertyMappedValidatorValueAccess("SurName");
            object value;
            string valueAccessFailureMessage;

            bool accessStatus = valueAccess.GetValue(validator, out value, out valueAccessFailureMessage);

            Assert.IsTrue(accessStatus);
            Assert.AreEqual("LogicalOperationStack", value);
        }