示例#1
0
 /// <summary>
 /// Create all proper controls for an ElementItem using all information gathered.
 /// Usually, not all parameters need values.
 /// </summary>
 /// <param name="tag"> The XML Element to apply changes backwards and allow save. </param>
 /// <param name="name"> The name of the element. (Mandatory) </param>
 /// <param name="isRequired"> If the element is optional or mandatory. (Optional) </param>
 /// <param name="help"> Some help text if exists. (Optional) </param>
 /// <param name="controlTypes"> The special list that shows which controls should be made. (Mandatory) </param>
 /// <param name="typeOptions"> Can have these options: Constant/Variable/Function. (Used in Constant/Variable/Function only) </param>
 /// <param name="unitOptions"> What options to show in the unit dropdown. (Used in Constant/Variable only) </param>
 /// <param name="xUnitOptions"> What options to show in the x_unit dropdown. (Used in Variable only) </param>
 /// <param name="funcOptions"> What options to show in the functions dropdown. (Used in Function only) </param>
 /// <param name="keyOptions"> What options to show in the keywords dropdown. (Used in Keywords only) </param>
 public GeneralControl(string name, bool isRequired, string help, List<CustomControlType> controlTypes,
     List<string> typeOptions, List<string> unitOptions, List<string> xUnitOptions,
     List<string> funcOptions, List<string> keyOptions,
     Dictionary<CustomControlType, string> defaultValues, string defaultUnit, string defaultXUnit,
     ValueValidator valueValidator, SaveVariable saveVariableTable, TypeChange typeChange, UnitChange unitChange, XUnitChange xUnitChange)
 {
     CreateGeneralControl(name, isRequired, help, controlTypes, typeOptions, unitOptions, xUnitOptions,
         funcOptions, keyOptions, defaultValues, defaultUnit, defaultXUnit,
         valueValidator, saveVariableTable, typeChange, unitChange, xUnitChange);
 }
示例#2
0
        public static void Assert3(IWebDriver driver)
        {
            string text = SaveVariable.On(driver, SearchUI.Item3);

            Assert.AreEqual("Puma Clyde X WWE dinero en el Bank Oro tenis zapatos Limited 100 pares nuevo 10", text);
        }
示例#3
0
        public static void Assert2(IWebDriver driver)
        {
            string text = SaveVariable.On(driver, SearchUI.Item2);

            Assert.AreEqual("Puma Clyde X WWE \"dinero en el banco\" Colección maletín Limitada US talla 10 para hombre", text);
        }
示例#4
0
        public static void Assert1(IWebDriver driver)
        {
            string text = SaveVariable.On(driver, SearchUI.Item1);

            Assert.AreEqual("Zapatos De Cuero rara VINTAGE PUMA especial 657, Alemania del Oeste, Azul Talla 10, NUEVO!!!", text);
        }
示例#5
0
        public static string Save(IWebDriver driver)
        {
            string text = SaveVariable.On(driver, SearchUI.Number);

            return(text);
        }
示例#6
0
        private void CreateGeneralControl(string name, bool isRequired, string help, List<CustomControlType> controlTypes,
            List<string> typeOptions, List<string> unitOptions, List<string> xUnitOptions,
            List<string> funcOptions, List<string> keyOptions,
            Dictionary<CustomControlType, string> defaultValues, string defaultUnit, string defaultXUnit,
            ValueValidator valueValidator, SaveVariable saveVariableTable, TypeChange typeChange, UnitChange unitChange, XUnitChange xUnitChange)
        {
            _customControls = new List<CustomControl>();

            //Handle bad situations
            if (controlTypes == null || controlTypes.Count < 1)
                return;

            //Initialize simple values
            Name = name;
            IsRequired = isRequired;
            Help = help ?? "";
            _updateType = typeChange;

            // Create Controls and connect the XML Element - Object with the control via Tag.
            foreach (var type in controlTypes)
                switch (type)
                {
                    case CustomControlType.Constant:
                        if (typeOptions != null && typeOptions.Contains("Constant") && unitOptions != null)
                        {
                            _controlConstant = new ControlConstant(
                                name, typeOptions, unitOptions, isRequired, help, this);

                            // Set default values.
                            if (defaultValues.ContainsKey(CustomControlType.Constant))
                                _controlConstant.DefaultValue = defaultValues[CustomControlType.Constant];
                            _controlConstant.DefaultUnit = defaultUnit;

                            // Set Value Validator.
                            _controlConstant.Validator = valueValidator;

                            _controlConstant.UnitChange = unitChange;

                            _customControls.Add(_controlConstant);
                        }
                        break;
                    case CustomControlType.Variable:
                        if (typeOptions != null && typeOptions.Contains("Variable") && unitOptions != null)// && xUnitOptions != null)
                        {
                            _controlVariable = new ControlVariable(
                                name, typeOptions, unitOptions, xUnitOptions, isRequired, help, this);

                            // Set default values.
                            if (defaultValues.ContainsKey(CustomControlType.Variable))
                                _controlVariable.DefaultValue = defaultValues[CustomControlType.Variable];
                            _controlVariable.DefaultUnit = defaultUnit;
                            _controlVariable.DefaultXUnit = defaultXUnit;

                            // Set Value Validators.
                            _controlVariable.Validator = valueValidator;
                            _controlVariable.SaveVariableTable = saveVariableTable;

                            _controlVariable.UnitChange = unitChange;
                            _controlVariable.XUnitChange = xUnitChange;

                            _customControls.Add(_controlVariable);
                        }
                        break;
                    case CustomControlType.Function:
                        if (typeOptions != null && typeOptions.Contains("Function") && funcOptions != null)
                        {
                            _controlFunction = new ControlFunction(
                                name, typeOptions, funcOptions, isRequired, help, this);

                            // Set default values.
                            if (defaultValues.ContainsKey(CustomControlType.Function))
                                _controlFunction.DefaultValue = defaultValues[CustomControlType.Function];

                            // Set Value Validators.
                            _controlFunction.Validator = valueValidator;

                            _customControls.Add(_controlFunction);
                        }
                        break;
                    case CustomControlType.Group:
                        _controlGroup = new ControlGroup(name, isRequired, this);
                        _customControls.Add(_controlGroup);
                        break;
                    case CustomControlType.Reference:
                        _controlReference = new ControlReference(name, isRequired, help, this);
                        _customControls.Add(_controlReference);

                        // Set Value Validators.
                        _controlReference.Validator = valueValidator;
                        break;
                    case CustomControlType.Keyword:
                        _controlKeyword = new ControlKeyword(name, keyOptions, isRequired, help, this);

                        // Set default values.
                        if (defaultValues.ContainsKey(CustomControlType.Keyword))
                            _controlKeyword.DefaultValue = defaultValues[CustomControlType.Keyword];

                        // Set Value Validators.
                        _controlKeyword.Validator = valueValidator;

                        _customControls.Add(_controlKeyword);
                        break;
                }

            //Find Default Control
            switch (controlTypes[0])
            {
                case CustomControlType.Constant:
                    CurrentControl = _controlConstant;
                    break;
                case CustomControlType.Variable:
                    CurrentControl = _controlVariable;
                    break;
                case CustomControlType.Function:
                    CurrentControl = _controlFunction;
                    break;
                case CustomControlType.Group:
                    CurrentControl = _controlGroup;
                    break;
                case CustomControlType.Reference:
                    CurrentControl = _controlReference;
                    break;
                case CustomControlType.Keyword:
                    CurrentControl = _controlKeyword;
                    break;
            }

            // Update Items' values (default).
            CurrentControl.UpdateValues();
        }