Exemplo n.º 1
0
        public void MaxLengthConstraintWillFailValidation(int count)
        {
            // setup
            var textField   = new Field(XDocumentFactory.XmlWithOneForm().Element("forms").Element("form").Element("fields").Element("field"));
            var textControl = new TextControl(textField);

            // Act
            textControl.Value = new string('a', count);

            // Verify
            Assert.IsFalse(textControl.IsValid());
            Assert.AreEqual("First Name must be less than 100 characters", textControl.ErrorMessage);
        }
Exemplo n.º 2
0
        public void CanCreateValidRequiredTextField()
        {
            // setup
            var textField   = new Field(XDocumentFactory.XmlWithOneForm().Element("forms").Element("form").Element("fields").Element("field"));
            var textControl = new TextControl(textField);

            // Act
            textControl.Value = "some value";

            // Verify
            Assert.IsTrue(textControl.IsValid());
            Assert.IsNull(textControl.ErrorMessage);
        }
Exemplo n.º 3
0
        public void CanCreateTextControl()
        {
            // setup
            var textField = new Field(XDocumentFactory.XmlWithOneForm().Element("forms").Element("form").Element("fields").Element("field"));

            // Act
            var textControl = new TextControl(textField);

            // Verify
            Assert.IsNotNull(textControl.Field);
            Assert.AreEqual("text", textControl.Type);
            Assert.IsNull(textControl.ErrorMessage);
            Assert.IsNull(textControl.Value);
            Assert.IsFalse(textControl.IsValid());
        }
Exemplo n.º 4
0
        public void CanParseSingleForm()
        {
            // Setup
            var xdocument = XDocumentFactory.XmlWithOneForm();

            // Act
            var forms = new Forms(xdocument);

            // Verify
            Assert.IsNotNull(forms.FormViews);
            Assert.AreEqual(1, forms.FormViews.Count);
            Assert.AreEqual("Personal Details", forms.FormViews[0].Title);

            VerifyForms(forms);
            VerifyCommands(forms);
        }
Exemplo n.º 5
0
        public void MaxLengthConstraintWillPassWhenLenghtIsSame()
        {
            // setup
            var textField = new Field(XDocumentFactory.XmlWithOneForm()
                                      .Element("forms")
                                      .Element("form")
                                      .Element("fields")
                                      .Element("field"));

            var textControl = new TextControl(textField);

            // Act
            textControl.Value = new string('a', 100);

            // Verify
            Assert.IsTrue(textControl.IsValid());
            Assert.IsNull(textControl.ErrorMessage);
        }
Exemplo n.º 6
0
        public void TooManyDecimalPlacesConstraintWillFire()
        {
            // setup
            var grossSalaryField = XDocumentFactory.XmlWithOneForm()
                                   .Element("forms")
                                   .Element("form")
                                   .Element("fields")
                                   .Elements("field")
                                   .ToList()[10];

            var textField   = new Field(grossSalaryField);
            var textControl = new TextControl(textField);

            // Act
            textControl.Value = "11.0000";

            // Verify
            Assert.IsFalse(textControl.IsValid());
            Assert.AreEqual("Gross Salary has too many decimal places (max 2)", textControl.ErrorMessage);
        }
Exemplo n.º 7
0
        public void DecimalPlacesConstraintWillPass(string validValues)
        {
            // setup
            // get field with decimal place constraint
            var grossSalaryField = XDocumentFactory.XmlWithOneForm()
                                   .Element("forms")
                                   .Element("form")
                                   .Element("fields")
                                   .Elements("field")
                                   .ToList()[10];

            var textField   = new Field(grossSalaryField);
            var textControl = new TextControl(textField);

            // Act
            textControl.Value = validValues;

            // Verify
            Assert.IsTrue(textControl.IsValid());
            Assert.IsNull(textControl.ErrorMessage);
        }
            private Form GenerateForm()
            {
                var formDoc = XDocumentFactory.XmlWithOneForm().Element("forms").Element("form");

                return(new Form(formDoc));
            }