Exemple #1
0
        public ISpecElement RunStory(ISpecElement element,IDSLDefinition DSL,string columnseparator)
        {
            _DslRunner = new DSLRunner(DSL);
            try
            {
                if (element.Type != ElementType.Story) return element;
                var result = element.Clone();
                var newchildren = new List<ISpecElement>(result.Children.Where(o => o.Type != ElementType.Scenario));
                foreach (var sc in element.Children.Where(e => e.Type == ElementType.Scenario))
                {
                    var example = GetData(sc.Children.Where(o => o.Type == ElementType.Example).FirstOrDefault(), columnseparator);
                    if (example.Keys.Count() > 0)
                    {
                        for (var j = 0; j < example[example.Keys.First()].Count; j++)
                        {
                            ISpecElement x = sc.Clone();
                            x.Children = x.Children.Where(o => o.Type != ElementType.Example).Select(o => o.Clone()).ToArray();

                            foreach (var n in example.Keys)
                            {
                                x.Description = x.Description.Replace(n, example[n][j]);
                                foreach (var y in x.Children)
                                    y.Description = y.Description.Replace(n, example[n][j]);
                            }
                            newchildren.Add(x);
                        }
                    }
                    else
                    {
                        newchildren.Add(sc);
                    }
                }
                result.Children = newchildren;
                foreach (var q in result.Children)
                    RunScenario(q, _DslRunner.GetNewContext(), columnseparator, true);
                result.Status = true;
                return result;

            }
            catch (Exception ex)
            {
                element.Status = null;
                while (ex.InnerException != null)
                    ex = ex.InnerException;
                element.StatusInfo = ex.GetType().Name + ":" + ex.Message;
            }
            return element;
        }
Exemple #2
0
 public DSLRunner(IDSLDefinition dsldef)
 {
     DslDef = dsldef;
 }