public override IEnumerable <CellResult> Execute(StepValues values, ISpecContext context)
        {
            var runner = _fixture.Runner;

            var cmd = runner.NewCommand();

            cmd.CommandText = _sql;
            cmd.CommandType = _commandType;

            foreach (var parameter in Parameters)
            {
                parameter.AddParameter(cmd, values);
            }

            foreach (var externalParameter in External)
            {
                externalParameter.AddParameter(cmd, context);
            }

            var returnResult = Execution.Execute(cmd, runner, values, context);

            if (returnResult != null)
            {
                yield return(returnResult);
            }

            foreach (var cell in Parameters.Where(x => x.IsChecked()))
            {
                yield return(cell.ToResult(values, cmd));
            }
        }
        public void AfterEach(ISpecContext context)
        {
            SpecContext ctx = (SpecContext)context;

            if (TestRailRunContext.Current != null)
            {
                foreach (int testCaseId in TestCaseParser.ParseTestCaseIds(ctx.Specification.name))
                {
                    var addResultRequest = new AddResultRequest
                    {
                        status_id = (int)(ctx.Counts.Exceptions > 0 || ctx.Counts.Wrongs > 0
                                                        ? TestResultStatus.Failed
                                                        : TestResultStatus.Passed),
                        case_id = testCaseId,
                        run_id  = TestRailRunContext.Current.RunId
                    };

                    try
                    {
                        var response = _client.AddTestCaseTestRunResult(addResultRequest);
                        context.Reporting.Log("TestRail", $"<div>{response}</div>");
                    }
                    catch (Exception ex)
                    {
                        context.Reporting.Log("TestRail", $"<div>{ex}</div>");
                    }
                }
            }
        }
        public CellResult ProcessStep(StepValues step, ISpecContext context, object target)
        {
            var actual = step.Get(_property.Name);
            _property.SetValue(target, actual);

            return CellResult.Ok(_property.Name);
        }
        public void Start(ISpecContext context)
        {
            _records.Clear();
            Errors = new BusErrors();

            _context = context;
        }
            public void BeforeExecution(ISpecContext context)
            {
                context.State.Store(_parent);
                _parent._currentContext = context;

                _parent.beforeEach(context);
            }
        public override IEnumerable<CellResult> Execute(StepValues values, ISpecContext context)
        {
            var element = _config.Finder(SearchContext);
            StoryTellerAssert.Fail(element == null, "Could not find an element w/ description: " + _config.Description);

            return execute(element, values);
        }
Exemple #7
0
        public override IEnumerable <CellResult> Execute(StepValues values, ISpecContext context)
        {
            var value = values.Get(_cell.Key);

            context.State.CurrentObject.SetValue(Members, value);

            return(Enumerable.Empty <CellResult>());
        }
Exemple #8
0
        public void Start(ISpecContext context, BusErrors errors)
        {
            _errors  = errors;
            _report  = new TransportLoggingReport();
            _context = context;

            _context.Reporting.Log(_report);
        }
Exemple #9
0
 public void BeforeExecution(ISpecContext context)
 {
     _inner.BeforeExecution(context);
     foreach (var extension in _extensions)
     {
         extension.BeforeEach(context);
     }
 }
Exemple #10
0
 public void AfterExecution(ISpecContext context)
 {
     _inner.AfterExecution(context);
     foreach (var extension in _extensions)
     {
         extension.AfterEach(context);
     }
 }
Exemple #11
0
        public virtual void AfterExecution(ISpecContext context)
        {
            var reporter = new RequestReporter(_system);

            reporter.Append(Services.GetInstance <IRequestHistoryCache>().RecentReports().ToArray());

            context.Reporting.Log(reporter);
        }
        public CellResult ProcessStep(StepValues step, ISpecContext context, object target)
        {
            var actual = step.Get(_property.Name);

            _property.SetValue(target, actual);

            return(CellResult.Ok(_property.Name));
        }
Exemple #13
0
 protected override Task<StepResult> executeAsync(ISpecContext context)
 {
     return _grammar.PerformTestAsync(Values, context).ContinueWith(t =>
     {
         return t.IsFaulted 
             ? new StepResult(Values.id, t.Exception) 
             : new StepResult(Values.id, t.Result ? ResultStatus.success : ResultStatus.failed);
     });
 }
        protected override StepResult execute(ISpecContext context)
        {
            var result = new StepResult(_values.id, ResultStatus.error)
            {
                error = Message
            };

            return result;
        }
        public override IEnumerable <CellResult> Execute(StepValues values, ISpecContext context)
        {
            var input   = (TInput)values.Get(_key);
            var @object = _creator(input);

            context.State.CurrentObject = @object;

            return(new[] { CellResult.Ok(_key) });
        }
Exemple #16
0
        protected override StepResult execute(ISpecContext context)
        {
            var result = new StepResult(_values.id, ResultStatus.error)
            {
                error = Message
            };

            return(result);
        }
        public override IEnumerable<CellResult> Execute(StepValues values, ISpecContext context)
        {
            _target.BeforeLine();

            var results = _properties.Select(x => x.ProcessStep(values, context, _target)).ToArray();

            _target.AfterLine();

            return results;
        }
        public Task <StepValues[]> Fetch(ISpecContext context)
        {
            return(Task.Factory.StartNew(() => _source(context).Select(x =>
            {
                var values = new StepValues("actual");
                _matches.Each(a => values.Store(a.Name, a.GetValue(x)));

                return values;
            }).ToArray()));
        }
        public override IEnumerable <CellResult> Execute(StepValues values, ISpecContext context)
        {
            var input = values.Get(_key).As <TInput>();

            var @object = context.State.CurrentObject.As <TObject>();

            _configure(@object, @input);

            return(Enumerable.Empty <CellResult>());
        }
        public Task <StepValues[]> Fetch(ISpecContext context)
        {
            return(Task.Factory.StartNew(() => _source(context).Select(x =>
            {
                var values = new StepValues("actual");
                values.Store(_key, x);

                return values;
            }).ToArray()));
        }
        public override IEnumerable <CellResult> Execute(StepValues values, ISpecContext context)
        {
            _target.BeforeLine();

            var results = _properties.Select(x => x.ProcessStep(values, context, _target)).ToArray();

            _target.AfterLine();

            return(results);
        }
Exemple #22
0
        Task <StepValues[]> ISetComparison.Fetch(ISpecContext context)
        {
            return(Task.Factory.StartNew(() =>
            {
                var token = _parent.JObject.SelectToken(_path);
                StoryTellerAssert.Fail(token == null, $"Could not find a JSON array at {_path}\n\nJson: \n\n_parent.JObject.ToString()");

                return token.Children().Select(createActualValues).ToArray();
            }));
        }
Exemple #23
0
        protected override StepResult execute(ISpecContext context)
        {
            var cellResults = _grammar.Execute(Values, context);

            var result = new StepResult(Values.id, ResultStatus.ok)
            {
                cells = cellResults.ToArray()
            };

            return result;
        }
        public Task<StepValues[]> Fetch(ISpecContext context)
        {
            return Task.Factory.StartNew(() => _source(context).Select(x =>
            {
                var values = new StepValues("actual");
                values.Store(_key, x);

                return values;

            }).ToArray());
        }
        public void AddParameter(DbCommand command, ISpecContext context)
        {
            var value = _source(context);
            var param = command.CreateParameter();

            param.ParameterName = _name;
            param.Direction     = ParameterDirection.Input;
            param.Value         = value;

            command.Parameters.Add(param);
        }
Exemple #26
0
        protected override StepResult execute(ISpecContext context)
        {
            var cellResults = _grammar.Execute(Values, context);

            var result = new StepResult(Values.id, ResultStatus.ok)
            {
                cells = cellResults.ToArray()
            };

            return(result);
        }
Exemple #27
0
        public static CommandRunner RetrieveOrBuildCommandRunner(this ISpecContext context, ISqlDialect dialect)
        {
            var connectionString = context.ConnectionString();

            if (connectionString.IsEmpty())
            {
                throw new InvalidOperationException($"No connection string is known. Use {nameof(ISpecContext)}.{nameof(SpecContextExtensions.ConnectionString)}(connection string) in your system bootstrapping");
            }

            return(context.State.RetrieveOrAdd(() => new CommandRunner(connectionString, dialect)));
        }
        protected override async Task <StepResult> executeAsync(ISpecContext context)
        {
            var cellResults = await _grammar.ExecuteAsync(Values, context).ConfigureAwait(false);

            var result = new StepResult(Values.id, ResultStatus.ok)
            {
                cells = cellResults.ToArray()
            };

            return(result);
        }
            public void AfterExecution(ISpecContext context)
            {
                var reports = _parent._messageLogger.BuildReports();

                foreach (var report in reports)
                {
                    context.Reporting.Log(report);
                }


                _parent.afterEach(context);
            }
Exemple #30
0
 public void AddTracing(ISpecContext context)
 {
     _runtimes.Each((name, runtime) =>
     {
         var provider = new MessageContextualInfoProvider(runtime.Get <IMessagingSession>())
         {
             ShortTitle = name,
             Title      = name + " Messaging"
         };
         context.Reporting.Log(provider);
     });
 }
Exemple #31
0
        public override IEnumerable <CellResult> Execute(StepValues values, ISpecContext context)
        {
            var file = context.State.Retrieve <CsvFile>();

            var section = context.State.Retrieve <Section>();

            var data = _cells.Select(x => x.CsvValue(section, values)).Where(x => x != null).ToArray();

            file.WriteValues(data);

            return(values.Errors);
        }
        public object Convert(string raw, ISpecContext context)
        {
            raw.ShouldBe(_raw);

            var ex = _returnedValue as Exception;

            if (ex != null)
            {
                throw ex;
            }

            return(_returnedValue);
        }
Exemple #33
0
        public override IEnumerable <CellResult> Execute(StepValues values, ISpecContext context)
        {
            var actual   = _accessor.GetValue(context.State.CurrentObject);
            var expected = values.Get(_cell.Key);

            if (expected.Equals(actual))
            {
                yield return(CellResult.Success(_cell.Key));
            }
            else
            {
                yield return(CellResult.Failure(_cell.Key, actual.ToString()));
            }
        }
        public void AddLogs(ISpecContext context)
        {
            _nodes.Each(node =>
            {
                var session = node.Runtime.Get <IMessagingSession>();

                var provider = new MessageContextualInfoProvider(session)
                {
                    Title = node.Id, ShortTitle = node.Id
                };

                context.Reporting.Log(node.Id, provider.ToHtml(), node.Id);
            });
        }
Exemple #35
0
        public void BeforeEach(ISpecContext context)
        {
            Server.SendCloseMessage();
            Server.ClearAll();

            launchPage();

            var reduxContext = new ReduxSpecContext(context);

            Server.CurrentContext = reduxContext;

            context.State.Store(reduxContext);
            context.State.Store(Server);

            Server.WaitForConnection(15.Seconds()).Wait();
        }
        public override IEnumerable <CellResult> Execute(StepValues values, ISpecContext context)
        {
            var runner = context.Service <CommandRunner>();
            var cmd    = runner.NewCommand();

            cmd.CommandText = _sql;
            cmd.CommandType = _commandType;

            foreach (var parameter in Parameters)
            {
                parameter.AddParameter(cmd, values);
            }

            Execution.Execute(cmd, runner, values, context);

            return(Parameters.Where(x => x.IsChecked()).Select(x => x.ToResult(values, cmd)));
        }
        public override IEnumerable<CellResult> Execute(StepValues values, ISpecContext context)
        {
            var element = _config.Finder(SearchContext);
            StoryTellerAssert.Fail(element == null, "Could not find an element w/ description: " + _config.Description);

            try
            {
                return execute(element, values);
            }
            catch (Exception ex)
            {
                // TODO: Use exception metadata with and add a custom exception formatter to show exception metadata
                //       See: https://github.com/storyteller/Storyteller/issues/400
                // ex.Data.Add("Gesture Description", _config.Description);
                throw new Exception("Gesture failed. [Description: {0}]".ToFormat(_config.Description), ex);
            }
        }
Exemple #38
0
 public void DoDelayedConversions(ISpecContext context)
 {
     _delayeds.Each(x =>
     {
         try
         {
             var converted = x.Converter.Convert(x.Raw, context);
             if (converted == null)
             {
                 LogError(x.Key, "The converter was not able to create a value. Check the formatting.");
             }
             else
             {
                 Store(x.Key, converted);
             }
         }
         catch (Exception ex)
         {
             LogError(x.Key, ex);
         }
     });
 }
        public object Convert(string raw, ISpecContext context)
        {
            ConversionHappened = true;

            return raw;
        }
 public void LineComplete(ISpecContext context, ILineExecution line)
 {
     var progress = new SpecProgress(context.Specification.id, context.Counts.Clone(), ++_step, _total);
     _observer.SendProgress(progress);
 }
 public object Convert(string raw, ISpecContext context)
 {
     return Players.FirstOrDefault(x => x.FullName() == raw);
 }
 public abstract IEnumerable<CellResult> Execute(StepValues values, ISpecContext context);
 public void LineComplete(ISpecContext context, ILineExecution line)
 {
     // nothing
 }
 protected override void afterEach(IContainer scope, ISpecContext context)
 {
     AfterEachWasCalled++;
     LastScope = scope;
     LastContext = context;
 }
Exemple #45
0
 protected override StepResult execute(ISpecContext context)
 {
     var test = _grammar.PerformTest(Values, context);
     return new StepResult(Values.id, test ? ResultStatus.success : ResultStatus.failed);
 }
Exemple #46
0
 public bool PerformTest(StepValues values, ISpecContext context)
 {
     return _test(context);
 }
Exemple #47
0
 public object Convert(string raw, ISpecContext context)
 {
     return new Color {Name = raw};
 }
 public CellResult ProcessStep(StepValues step, ISpecContext context, object target)
 {
     object actual = _property.GetValue(target, null);
     return _cell.Check(step, actual);
 }
        public object Convert(string raw, ISpecContext context)
        {
            raw.ShouldBe(_raw);

            var ex = _returnedValue as Exception;
            if (ex != null) throw ex;

            return _returnedValue;
        }
 protected abstract StepResult execute(ISpecContext context);
 public ContextualNavigationLogger(ISpecContext context)
 {
     _context = context;
 }
        public override IEnumerable<CellResult> Execute(StepValues values, ISpecContext context)
        {
            _action(context);

            yield break;
        }
 public object Convert(string raw, ISpecContext context)
 {
     throw new Exception("You shall not pass!");
 }