public void TestGetRules()
 {
     TextControl control = new TextControl();
     Assert.IsNull(control.VisibilityRule);
     control.VisibilityRule = new IfTruthCondition();
     Assert.IsNotNull(control.VisibilityRule);
 }
        public void TestInitialize()
        {
            this.EvaluatorRegister = new TruthConditionEvaluatorFactory();

            this.ControlList = new ControlList();
            TextControl firstNameControl = new TextControl { Id = 101, Name = "First_name", Label = "First Name" };
            ControlList.Add(firstNameControl);

            TextControl ageControl = new TextControl { Id = 102, Name = "Age", Label = "Age" };
            ControlList.Add(ageControl);
        }
        public void TestControlTypes()
        {
            TextControl textControl = new TextControl();
            Assert.AreEqual(ControlType.Text, textControl.Type);

            ComboControl comboControl = new ComboControl();
            Assert.AreEqual(ControlType.Combo, comboControl.Type);

            RadioControl radioControl = new RadioControl();
            Assert.AreEqual(ControlType.Radio, radioControl.Type);

            CheckboxControl checkboxControl = new CheckboxControl();
            Assert.AreEqual(ControlType.Checkbox, checkboxControl.Type);

            CheckboxGroupControl checkboxGroupControl = new CheckboxGroupControl();
            Assert.AreEqual(ControlType.CheckboxGroup, checkboxGroupControl.Type);

            DateControl dateControl = new DateControl();
            Assert.AreEqual(ControlType.Date, dateControl.Type);

            TimeControl timeControl = new TimeControl();
            Assert.AreEqual(ControlType.Time, timeControl.Type);

            FileBrowserControl fileBrowserControl = new FileBrowserControl();
            Assert.AreEqual(ControlType.FileBrowser, fileBrowserControl.Type);

            HiddenControl hiddenControl = new HiddenControl();
            Assert.AreEqual(ControlType.Hidden, hiddenControl.Type);

            LabelControl labelControl = new LabelControl();
            Assert.AreEqual(ControlType.Label, labelControl.Type);

            HtmlControl htmlControl = new HtmlControl();
            Assert.AreEqual(ControlType.Html, htmlControl.Type);

            GroupControl groupControl = new GroupControl();
            Assert.AreEqual(ControlType.Group, groupControl.Type);

            RepeaterControl repeaterControl = new RepeaterControl();
            Assert.AreEqual(ControlType.Repeater, repeaterControl.Type);

            CalculationControl calculationControl = new CalculationControl();
            Assert.AreEqual(ControlType.Calculation, calculationControl.Type);

            SignaturePadControl signaturePadControl = new SignaturePadControl();
            Assert.AreEqual(ControlType.SignaturePad, signaturePadControl.Type);

            GeolocationControl geolocationControl = new GeolocationControl();
            Assert.AreEqual(ControlType.Geolocation, geolocationControl.Type);

            HeadingControl headingControl = new HeadingControl();
            Assert.AreEqual(ControlType.Heading, headingControl.Type);
        }
        public void EmailUserWithPdf()
        {
            MailQueue queue = new MailQueue();
            EventActionEmailResponseHandler handler = new EventActionEmailResponseHandler(null, queue, null, new StringFormatter("{%", "%}"), new EmailTokenFormatter("{%", "%}"), new SummaryFormatter("{%", "%}"), new ApplicationPdfWriter(), string.Format("{0}/iapply.pdf", System.IO.Path.GetTempPath()), "*****@*****.**")
                                                      {
                                                          Roles = this.roleList,
                                                          GetUsersFn = this.getUserFn,
                                                          SystemSettings = this.systemSettings
                                                      };

            this.action.AttachPdf = true;
            this.application.ApplicationData.Add("Test", "Test");
            this.recipientList.Users.Add("user-1");

            ControlList controlList = new ControlList();
            TextControl textControl = new TextControl
                                      {
                                          Name = "Test",
                                          Label = "Test"
                                      };
            controlList.Add(textControl);

            PageList pages = new PageList
                             {
                                 new UserPage
                                 {
                                     Controls = controlList
                                 }
                             };
            EventResult result = handler.Handle(null, this.action, this.application, pages, this.getApplicationAccessFn);

            Assert.IsTrue(result.Processed);
            MailMessageSerializable message = queue.Dequeue().Message as MailMessageSerializable;
            Assert.AreEqual(1, message.To.Count);
            Assert.AreEqual("*****@*****.**", message.To[0].Address);
            Assert.AreEqual("*****@*****.**", message.Sender.Address);
            Assert.AreEqual(1, message.Attachments.Count);
            Assert.AreEqual(this.action.Subject, message.Subject);
        }
            public void MissingValueUseDefault()
            {
                TextControl defaultControl = new TextControl();
                Assert.AreSame(defaultControl, this.ApplicationData.GetValue("MissingControl", defaultControl));

                Assert.AreEqual(15, this.ApplicationData.GetValue("Repeater1.Child1.Total", 15));
            }
 public void PropertiesAreEqual()
 {
     TextControl control = new TextControl { Id = 42 };
     TextControl clone = control.Clone();
     Assert.AreEqual(42, clone.Id);
 }
 public void AreNotSameObject()
 {
     TextControl control = new TextControl();
     TextControl clone = control.Clone();
     Assert.AreNotSame(control, clone);
 }
 /// <summary>
 /// Creates a <see cref="Microsoft.Practices.EnterpriseLibrary.Validation.Validator"/> that will validate
 /// the content length for a text control.
 /// </summary>
 /// <param name="textControl">The control to create a validator for.</param>
 /// <returns>A <see cref="Microsoft.Practices.EnterpriseLibrary.Validation.Validator"/> that will validate
 /// the content length for a text control.</returns>
 private Validator CreateValidatorForMaxLength(TextControl textControl)
 {
     return new EntLib.StringLengthValidator(textControl.MaxLength.Value) { MessageTemplate = ValidationMessage.StringLength };
 }
 public void TestGetValidators()
 {
     TextControl control = new TextControl();
     Assert.AreEqual(0, control.Validators.Count);
     control.Validators.Add(new ControlRegexValidator());
     Assert.AreEqual(1, control.Validators.Count);
 }
 public void TestSetValidators()
 {
     TextControl control = new TextControl();
     ControlRegexValidatorList validatorList = new ControlRegexValidatorList { new ControlRegexValidator() };
     control.Validators = validatorList;
     Assert.AreEqual(1, control.Validators.Count);
 }