public void ReturnUsersInOrganisation()
        {
            const string id = "1234";
            OptionSourceProviderRegister register = new OptionSourceProviderRegister();
            List<OptionSourceUser> users = new List<OptionSourceUser>
                                           {
                                               this.CreateMockUser(id, id),
                                               this.CreateMockUser(id, id),
                                               this.CreateMockUser(id + "5", id)
                                           };

            register.Register(new SystemOptionSourceProvider(this.CreateFindUserFn(users), id));

            ControlWithOptions control = new ComboControl
            {
                OptionSource = new SystemOptionSource
                {
                    ResponseFieldMap = new MappedFieldList
                                        {
                                            new MappedField { Target = "Value" },
                                            new MappedField { Target = "Description" },
                                            new MappedField { Target = "Category" }
                                        }
                }
            };
            control.LoadOptions(register);

            Assert.AreEqual(2, control.OptionValues.Count);
        }
        public void ReturnUsersInRole()
        {
            const string organisationId = "1234";
            const string roleId = "5678";
            OptionSourceProviderRegister register = new OptionSourceProviderRegister();
            List<OptionSourceUser> users = new List<OptionSourceUser>
                                           {
                                               this.CreateMockUser(organisationId, roleId),
                                               this.CreateMockUser(organisationId, roleId),
                                               this.CreateMockUser(organisationId, roleId + "5")
                                           };

            register.Register(new SystemOptionSourceProvider(this.CreateFindUserFn(users), organisationId));

            ControlWithOptions control = new ComboControl
            {
                OptionSource = new SystemOptionSource
                {
                    FilterRoleId = roleId
                }
            };
            control.LoadOptions(register);

            Assert.AreEqual(2, control.OptionValues.Count);
        }
Пример #3
0
        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 FormatCombo()
 {
     ComboControl control = new ComboControl
                                {
                                    OptionValues = new ControlValueOptionList
                                                       {
                                                           new ControlValueOption { Description = "Option 1", Value = "o1" },
                                                           new ControlValueOption { Description = "Option 2", Value = "o2" },
                                                           new ControlValueOption { Description = "Option 3", Value = "o3" }
                                                       }
                                };
     ApplicationValueFormatter formatter = new ApplicationValueFormatter();
     string formattedValue = formatter.FormatApplicationValue("o2", control);
     Assert.AreEqual("Option 2", formattedValue);
 }