Example #1
0
        public List<Criterion> BuildCriterionFromOutline(Criterion criterion, List<Criterion> commonCriteria)
        {
            builtCriteria = new List<Criterion>();

            if (criterion.Table != null)
            {
                var count = 0;

                foreach (DataRow dr in criterion.Table.DataRows)
                {
                    builtCriteria.AddRange(criterion.BeforeCriteria.Clone());

                    builtCriteria.AddRange(commonCriteria.Clone());

                    builtCriteria.Add(InsertParametricData(criterion, count));

                    builtCriteria.AddRange(criterion.AfterCriterion.Clone());

                    count++;
                }
            }
            else
                builtCriteria.Add(criterion);

            return builtCriteria;
        }
        public void Setup()
        {
            lines = new List<string>();

            lines.Add("| role | type |");
            lines.Add("| admin | test |");
            lines.Add("|user | dev |");

            var count = 0;

            outline = new Criterion() { Name = "Foo", CriterionType = "Criterion Outline" };

            outline.Table = new Table().Parse(lines, ref count);
        }
Example #3
0
        public List<Criterion> BuildCriterion(Criterion criterion, List<Criterion> criterionCommon)
        {
            var sequence = new List<Criterion>();

            sequence.AddRange(criterion.BeforeCriteria);

            sequence.AddRange(criterionCommon.Clone());

            sequence.Add(criterion);

            sequence.AddRange(criterion.AfterCriterion);

            return sequence;
        }
Example #4
0
        public Criterion InsertParametricData(Criterion criterion, int count)
        {
            var newCriterion = criterion.Clone();

            newCriterion.Name = newCriterion.Name + "_" + count;

            foreach (CriterionStep i in newCriterion.Steps)
                for (int x = 0; x < i.Parameters.Count; x++)
                    if (i.Parameters[x].GetType().Equals(typeof(string)))
                    {
                        if ((i.Parameters[x] as string).StartsWith("<"))
                            i.Parameters[x] = InsertValue(criterion.Table, i.Parameters[x] as string, count);
                    }
                    else
                        i.Parameters[x] = i.Table;

            return newCriterion;
        }
        public void GivenTwoCriteriaWithExclude()
        {
            criteria = new List<Criterion>();

            var criterion1 = new Criterion()
            {
                Name = "SC1",
                Tags = { new Tag("foo") }
            };

            var criterion2 = new Criterion()
            {
                Name = "SC2",
                Tags = { new Tag("foo"), new Tag("bar") }
            };

            criteria.Add(criterion1);
            criteria.Add(criterion2);
        }
Example #6
0
        public static CriterionResult RunCriterion(Criterion criterion, int dataRow, IXmlRpcClient proxy)
        {
            var criterionResult = new CriterionResult() { Criterion = criterion };

            foreach (CriterionStep s in criterion.Steps)
            {
                if(criterion.Table != null && criterion.Table.DataRows.Count > 0)
                    s.SetTestData(criterion.Table, dataRow);

                if (s.Table != null && s.Table.DataRows.Count > 0)
                    s.SetTestData(s.Table);

                criterionResult.StepResults.Add(s.Run(proxy));

                criterionResult.SetResult();

                if (criterionResult.Result.status.Equals("FAIL"))
                    break;
            }

            return criterionResult;
        }
Example #7
0
        public Story AssembleBlocks()
        {
            var story = new Story();

            foreach(Block block in blocks)
            {
                if (block.BlockType.Equals("Story"))
                    story = block.BuildStory();

                else if (block.BlockType.Equals("Before Story"))
                    story.BeforeStories.Add(block.BuildCriterion(ref BeforeCriterion));

                else if (block.BlockType.Equals("After Story"))
                    story.AfterStories.Add(block.BuildCriterion(ref BeforeCriterion));

                else if (block.BlockType.Equals("Criterion Common"))
                    story.CriterionCommon.Add(block.BuildCriterion(ref BeforeCriterion));

                else if (block.BlockType.Equals("Before Criterion"))
                    BeforeCriterion.Add(block.BuildCriterion(ref BeforeCriterion));

                else if (block.BlockType.Equals("Criterion"))
                {
                    currentCriterion = block.BuildCriterion(ref BeforeCriterion);
                    story.Criteria.Add(currentCriterion);
                }

                else if (block.BlockType.Equals("After Criterion"))
                    currentCriterion.AfterCriterion.Add(block.BuildCriterion(ref BeforeCriterion));

                else if (block.BlockType.Equals("Criterion Outline"))
                {
                    currentCriterion = block.BuildCriterionOutline(ref BeforeCriterion);
                    story.Criteria.Add(currentCriterion);
                }
            }
            return story;
        }
Example #8
0
        public Criterion BuildCriterion(ref List<Criterion> beforeCriteria)
        {
            var criterion = new Criterion(this);

            criterion.BeforeCriteria.AddRange(beforeCriteria);

            beforeCriteria.Clear();

            var currentLine = 0;

            if (Lines.Count > 0)
            {
                var matches = LanguageElements.Keywords.Any(t => FirstWord(currentLine).StartsWith(t));

                while (MatchesKeyword(Lines[currentLine]) && currentLine < Lines.Count)
                {
                    var step = new CriterionStep(Lines[currentLine]);

                    if (currentLine < Lines.Count - 1)
                    {
                        currentLine++;

                        if (Lines[currentLine].StartsWith(LanguageElements.TableDelimiter))
                            step.Table = new Table().Parse(Lines, ref currentLine);
                    }
                    else
                    {
                        criterion.Steps.Add(step);
                        break;
                    }

                    criterion.Steps.Add(step);
                }
            }
            return criterion;
        }
Example #9
0
        public Criterion BuildCriterionOutline(ref List<Criterion> beforeCriteria)
        {
            var outline = new Criterion(this);

            outline.BeforeCriteria.AddRange(beforeCriteria);

            beforeCriteria.Clear();

            var currentLine = 0;

            if (Lines.Count > 0)
            {
                while (LanguageElements.Keywords.Any(e => e.Equals(FirstWord(currentLine))))
                {
                    outline.Steps.Add(new CriterionStep(Lines[currentLine]));

                    currentLine++;
                }

                if (Lines[currentLine].StartsWith("Test Data:"))
                {
                    currentLine++;

                    outline.Table = new Table().Parse(Lines, ref currentLine);
                }
            }

            return outline;
        }