Exemple #1
0
        public static Step MakeStep(IDbConnection dbConn)
        {
            String stepName = "Step" + TestUtil.NextString();

            Step.StepType type = Step.StepType.Terminating;
            switch (RANDOM.Next(0, 4))
            {
            case 0:
                type = Step.StepType.Failure;
                break;

            case 1:
                type = Step.StepType.Failure;
                break;

            case 2:
                type = Step.StepType.Start;
                break;

            default:
                break;
            }
            return(Step.Insert(dbConn
                               , stepName
                               , MakeMap(dbConn)
                               , MakeQueue(dbConn)
                               , type
                               ));
        }
Exemple #2
0
        public void CanInsertWithoutFollowing()
        {
            String stepName = TestUtil.NextString();

            Step.StepType type   = Step.StepType.Standard;
            var           dbConn = ConnectionFactory.Create();
            int           before = TestUtil.SelectCount(dbConn, Step.TABLE);

            var step = Step.Insert(dbConn
                                   , stepName
                                   , TestUtil.MakeMap(dbConn)
                                   , TestUtil.MakeQueue(dbConn)
                                   , type
                                   );

            Assert.AreEqual(step.NextStepId, Step.NO_NEXT_STEP);

            int after = TestUtil.SelectCount(dbConn, Step.TABLE);

            Assert.AreEqual(before + 1, after);
        }
Exemple #3
0
        public Int32 AddStep(
            Step previousStep,
            Step.StepType type,
            String stereotype,
            UseCase referencedUseCase,
            DependencyItem.ReferenceType referenceType)
        {
            Step  step = new Step();
            Int32 index;
            Int32 ret;

            if (referenceType != DependencyItem.ReferenceType.None)
            {
                step.Dependency.Stereotype      = stereotype;
                step.Dependency.PartnerUniqueID = referencedUseCase.UniqueID;
                step.Dependency.Type            = referenceType;
                step.Description  = (step.Dependency.Stereotype != "") ? "<<" + step.Dependency.Stereotype + ">>" : "";
                step.Description += " \"";
                step.Description += referencedUseCase.Name;
                step.Description += "\"";
            }

            if (previousStep == null)
            {
                step.ID = 1;
                ret     = this.steps.Add(step);
                return(ret);
            }
            else
            {
                switch (type)
                {
                case Step.StepType.Default:
                    if (previousStep.Type == Step.StepType.Default)
                    {
                        step.ID = previousStep.ID;
                        index   = this.FindStepIndexByUniqueID(previousStep.UniqueID) + 1;
                        while (true)
                        {
                            if (index == this.steps.Count)
                            {
                                previousStep = (Step)this.steps[index - 1];
                                break;
                            }
                            Step tmpStep = (Step)this.steps[index];
                            if (tmpStep.ID != step.ID)
                            {
                                previousStep = (Step)this.steps[index - 1];
                                break;
                            }
                            index += 1;
                        }
                        step.ID = previousStep.ID + 1;
                        foreach (Step tmpStep in this.steps)
                        {
                            if (tmpStep.ID >= step.ID)
                            {
                                tmpStep.ID += 1;
                            }
                        }
                    }
                    else if (previousStep.Type == Step.StepType.Alternative)
                    {
                        step.ID   = previousStep.ID;
                        step.Type = Step.StepType.Alternative;

                        index = this.FindStepIndexByUniqueID(previousStep.UniqueID) + 1;
                        while (true)
                        {
                            if (index == this.steps.Count)
                            {
                                previousStep = (Step)this.steps[index - 1];
                                break;
                            }
                            Step tmpStep = (Step)this.steps[index];
                            if (tmpStep.ID != step.ID || tmpStep.Prefix == String.Empty)
                            {
                                previousStep = (Step)this.steps[index - 1];
                                break;
                            }
                            index += 1;
                        }
                        step.Prefix = previousStep.Prefix;
                        if (step.Prefix != String.Empty)
                        {
                            Char nextChar = step.Prefix[0];
                            nextChar++;
                            step.Prefix = new String(nextChar, 1);
                        }
                        else
                        {
                            step.Prefix = "A";
                        }

                        foreach (Step tmpStep in this.steps)
                        {
                            if (tmpStep.ID == step.ID)
                            {
                                if (tmpStep.Prefix != String.Empty && tmpStep.Prefix.CompareTo(step.Prefix) >= 0)
                                {
                                    Char nextChar = tmpStep.Prefix[0];
                                    nextChar++;
                                    tmpStep.Prefix = new String(nextChar, 1);
                                }
                            }
                        }
                    }
                    else if (previousStep.Type == Step.StepType.AlternativeChild)
                    {
                        step.Type   = Step.StepType.AlternativeChild;
                        step.ID     = previousStep.ID;
                        step.Prefix = previousStep.Prefix;

                        index = this.FindStepIndexByUniqueID(previousStep.UniqueID) + 1;
                        while (true)
                        {
                            if (index == this.steps.Count)
                            {
                                previousStep = (Step)this.steps[index - 1];
                                break;
                            }
                            Step tmpStep = (Step)this.steps[index];
                            if (tmpStep.ID != step.ID || tmpStep.Prefix != step.Prefix)
                            {
                                previousStep = (Step)this.steps[index - 1];
                                break;
                            }
                            index += 1;
                        }

                        step.Prefix  = previousStep.Prefix;
                        step.ChildID = previousStep.ChildID + 1;
                    }
                    break;

                case Step.StepType.Alternative:
                    if (previousStep.Type == Step.StepType.Default)
                    {
                        step.ID   = previousStep.ID;
                        step.Type = Step.StepType.Alternative;

                        index = this.FindStepIndexByUniqueID(previousStep.UniqueID) + 1;
                        while (true)
                        {
                            if (index == this.steps.Count)
                            {
                                previousStep = (Step)this.steps[index - 1];
                                break;
                            }
                            Step tmpStep = (Step)this.steps[index];
                            if (tmpStep.ID != step.ID || tmpStep.Prefix == String.Empty)
                            {
                                previousStep = (Step)this.steps[index - 1];
                                break;
                            }
                            index += 1;
                        }
                        step.Prefix = previousStep.Prefix;
                        if (step.Prefix != String.Empty)
                        {
                            Char nextChar = step.Prefix[0];
                            nextChar++;
                            step.Prefix = new String(nextChar, 1);
                        }
                        else
                        {
                            step.Prefix = "A";
                        }

                        foreach (Step tmpStep in this.steps)
                        {
                            if (tmpStep.ID == step.ID)
                            {
                                if (tmpStep.Prefix != String.Empty && tmpStep.Prefix.CompareTo(step.Prefix) >= 0)
                                {
                                    Char nextChar = tmpStep.Prefix[0];
                                    nextChar++;
                                    tmpStep.Prefix = new String(nextChar, 1);
                                }
                            }
                        }
                    }
                    else if (previousStep.Type == Step.StepType.Alternative)
                    {
                        step.Type    = Step.StepType.AlternativeChild;
                        step.ID      = previousStep.ID;
                        step.Prefix  = previousStep.Prefix;
                        step.ChildID = 1;
                    }
                    break;
                }
            }

            index = this.FindStepIndexByUniqueID(previousStep.UniqueID) + 1;
            if (index == this.steps.Count)
            {
                ret = this.steps.Add(step);
            }
            else
            {
                this.steps.Insert(index, step);
                ret = index;
            }

            return(ret);
        }
Exemple #4
0
        public void HasType([Values(Step.StepType.Jump, Step.StepType.Stitch)] Step.StepType t)
        {
            var st = new Step(t, new Point(1, 2));

            Assert.AreEqual(t, st.Type);
        }