Exemple #1
0
        public void AddHandler(object sender, EventArgs args)
        {
            Expectation expectation = (Expectation)acceptor.getFactory().createExpectation();

            expectation.Name = "<Expectation" + (GetNodeCount(false)) + ">";
            Item.appendExpectations(expectation);
        }
 /// <summary>
 /// Adds an expectation for this sub-step
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="args"></param>
 public void AddExpectationHandler(object sender, EventArgs args)
 {
     DataDictionary.Tests.Expectation expectation = (DataDictionary.Tests.Expectation)DataDictionary.Generated.acceptor.getFactory().createExpectation();
     expectation.Enclosing = Item;
     expectation.Name      = "Expectation" + expectations.Nodes.Count;
     createExpectation(expectation);
 }
 public void AddHandler(object sender, EventArgs args)
 {
     DataDictionary.Tests.Expectation expectation = (DataDictionary.Tests.Expectation)DataDictionary.Generated.acceptor.getFactory().createExpectation();
     expectation.Name     = "<Expectation" + (GetNodeCount(false)) + ">";
     expectation.Blocking = true;
     expectation.DeadLine = 1000;
     addExpectation(expectation);
 }
        /// <summary>
        ///     Creates an expectation in a sub step
        /// </summary>
        /// <param name="enclosing"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        protected Expectation CreateExpectation(SubStep enclosing, string name)
        {
            Expectation retVal = (Expectation)Factory.createExpectation();

            enclosing.appendExpectations(retVal);
            retVal.ExpressionText = name;

            return(retVal);
        }
        /// <summary>
        /// Adds the given action to the list of actions
        /// </summary>
        /// <param name="action"></param>
        public void addExpectation(DataDictionary.Tests.Expectation expectation)
        {
            expectation.Enclosing = Item;
            ExpectationTreeNode expectationNode = new ExpectationTreeNode(expectation);

            Item.appendExpectations(expectation);
            Nodes.Add(expectationNode);
            SortSubNodes();
        }
        /// <summary>
        /// Creates a new expectation
        /// </summary>
        /// <param name="testCase"></param>
        /// <returns></returns>
        public ExpectationTreeNode createExpectation(DataDictionary.Tests.Expectation expectation)
        {
            ExpectationTreeNode retVal = new ExpectationTreeNode(expectation);

            Item.appendExpectations(expectation);
            expectations.Nodes.Add(retVal);

            return(retVal);
        }
Exemple #7
0
 /// <summary>
 ///     Executes the action
 /// </summary>
 /// <param name="e"></param>
 protected override void OnClick(EventArgs e)
 {
     if (SubStep != null)
     {
         Expectation expectation = (Expectation)acceptor.getFactory().createExpectation();
         expectation.Name = "";
         SubStep.appendExpectations(expectation);
     }
     base.OnClick(e);
 }
        private void fillBrakingParametersExpectations(TestCase aTestCase, int stepNumber, string name,
            string expression, List<double> distanceValues, List<double> speedValues, List<double> values)
        {
            Step aStep = new Step();
            aStep.Name = String.Format("Step{0} - {1}", stepNumber, name);
            aTestCase.AddModelElement(aStep);

            SubStep aSubStep = new SubStep();
            aSubStep.Name = String.Format("SubStep1 - Verify {0} values", name);
            aStep.AddModelElement(aSubStep);

            for (int i = 0; i < values.Count; i++)
            {
                if (values[i] != -1)
                {
                    Expectation expectation = new Expectation();
                    expectation.ExpressionText = String.Format(CultureInfo.InvariantCulture, expression,
                        Math.Round(distanceValues[i], 2), Math.Round(speedValues[i], 2), Math.Round(values[i], 4));
                    aSubStep.AddModelElement(expectation);
                }
            }
        }
 private void addExpectation(SubStep aSubStep, string expression)
 {
     Expectation anExpectation = new Expectation();
     anExpectation.ExpressionText = expression;
     anExpectation.Blocking = true;
     aSubStep.AddModelElement(anExpectation);
 }
Exemple #10
0
        /// <summary>
        ///     Handles a drop event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TimeLineControl_DragDrop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent("WindowsForms10PersistentObject", false))
            {
                BaseTreeNode sourceNode = e.Data.GetData("WindowsForms10PersistentObject") as BaseTreeNode;
                if (sourceNode != null)
                {
                    VariableTreeNode variableNode = sourceNode as VariableTreeNode;
                    if (variableNode != null)
                    {
                        SubStep subStep = SubStepRelatedToMousePosition();
                        if (subStep != null)
                        {
                            // Create the default value
                            IValue     value        = null;
                            Expression expression   = null;
                            string     defaultValue = variableNode.Item.Default;
                            if (defaultValue != null)
                            {
                                const bool doSemanticalAnalysis = true;
                                const bool silent = true;
                                expression = new Parser().Expression(variableNode.Item, defaultValue,
                                                                     AllMatches.INSTANCE, doSemanticalAnalysis, null, silent);
                            }

                            if (expression != null)
                            {
                                InterpretationContext context = new InterpretationContext {
                                    UseDefaultValue = false
                                };
                                value = expression.GetExpressionValue(context, null);
                            }

                            if (value == null || value is EmptyValue)
                            {
                                Structure structureType = variableNode.Item.Type as Structure;
                                if (structureType != null)
                                {
                                    const bool setDefaultValue = false;
                                    value = new StructureValue(structureType, setDefaultValue);
                                }
                            }

                            // Create the action or the expectation according to the keyboard modifier keys
                            if (value != null)
                            {
                                if ((e.KeyState & Ctrl) != 0)
                                {
                                    Expectation expectation = (Expectation)acceptor.getFactory().createExpectation();
                                    expectation.ExpressionText = variableNode.Item.FullName + " == " + value.FullName;
                                    subStep.appendExpectations(expectation);
                                }
                                else
                                {
                                    Action action = (Action)acceptor.getFactory().createAction();
                                    action.ExpressionText = variableNode.Item.FullName + " <- " + value.FullName;
                                    subStep.appendActions(action);
                                }
                            }
                            else
                            {
                                MessageBox.Show(
                                    Resources
                                    .StaticTimeLineControl_TimeLineControl_DragDrop_Cannot_evaluate_variable_default_value,
                                    Resources.StaticTimeLineControl_TimeLineControl_DragDrop_Cannot_create_event,
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                            }
                        }
                    }
                }
            }
        }