/// <summary>
        /// Adds asynchronous step with name specified by <paramref name="name"/> parameter and action specified by <paramref name="step"/> parameter to the scenario.
        /// </summary>
        /// <typeparam name="TContext">Scenario context, if specified.</typeparam>
        /// <param name="builder">Builder.</param>
        /// <param name="name">Step name to be rendered.</param>
        /// <param name="step">Step action</param>
        /// <returns>Builder.</returns>
        public static IScenarioRunner <TContext> AddAsyncStep <TContext>(this IScenarioBuilder <TContext> builder, string name, Func <TContext, Task> step)
        {
            var integration = builder.Integrate();

            integration.Core.AddSteps(new[] { CompactStepCompiler.ToAsynchronousStep(name, step) });
            return(integration);
        }
Beispiel #2
0
        /// <summary>
        /// Adds asynchronous steps specified by <paramref name="steps"/> to the scenario, where steps names are inferred directly from provided action names.<br/>
        /// Example usage:
        /// <code>
        /// AddAsyncSteps(
        ///         Given_numbers_5_and_8,
        ///         When_I_add_them,
        ///         I_should_receive_number_13)
        /// </code>
        /// Expected step signature: <code>Task Given_numbers_5_and_8() { /* ... */ }</code>
        /// </summary>
        /// <param name="builder">Builder.</param>
        /// <param name="steps">Steps to add, like: <c>AddAsyncSteps(Given_numbers_5_and_8, When_I_add_them, I_should_receive_number_13)</c></param>
        public static IScenarioRunner <NoContext> AddAsyncSteps(this IScenarioBuilder <NoContext> builder, params Func <Task>[] steps)
        {
            var integration = builder.Integrate();

            integration.Core.AddSteps(steps.Select(BasicStepCompiler.ToAsynchronousStep));
            return(integration);
        }
        /// <summary>
        /// Adds asynchronous steps specified by <paramref name="steps"/> parameter to the scenario.<br/>
        /// The step name is determined from lambda parameter name reflecting action type keyword, corresponding action name and passed list of parameters to called method.<br/>
        /// If scenario is defined with context, the context instance is provided with lambda parameter.<br/>
        /// Example usage:
        /// <code>
        /// AddAsyncSteps(
        ///         _ => Given_numbers(5, 8),
        ///         _ => When_I_add_them(),
        ///         _ => I_should_receive_number(13))
        /// </code>
        /// Expected step signature: <code>Task Given_numbers(params int[] numbers) { /* ... */ }</code>
        /// </summary>
        /// <param name="builder">Builder.</param>
        /// <param name="steps">Steps to add, like: <c>AddAsyncSteps(_ => Given_numbers(5, 8), _ => When_I_add_them(), _ => I_should_receive_number(13))</c></param>
        public static IScenarioRunner <TContext> AddAsyncSteps <TContext>(this IScenarioBuilder <TContext> builder, params Expression <Func <TContext, Task> >[] steps)
        {
            var integration = builder.Integrate();
            var compiler    = new ExtendedStepCompiler <TContext>(integration.Core.Configuration);

            integration.Core.AddSteps(steps.Select(compiler.ToStep));
            return(integration);
        }
Beispiel #4
0
 private static ExtendedScenarioBuilder <TContext> AsExtended <TContext>(this IScenarioBuilder <TContext> runner)
 {
     return(runner.Integrate().Enrich(ExtendedScenarioBuilder <TContext> .Create));
 }
Beispiel #5
0
 /// <summary>
 /// Adds step with name specified by <paramref name="name"/> parameter and action specified by <paramref name="step"/> parameter to the scenario.
 /// </summary>
 /// <typeparam name="TContext">Scenario context, if specified.</typeparam>
 /// <param name="builder">Builder.</param>
 /// <param name="name">Step name to be rendered.</param>
 /// <param name="step">Step action</param>
 /// <returns>Builder.</returns>
 public static IScenarioBuilder <TContext> AddStep <TContext>(this IScenarioBuilder <TContext> builder, string name, Action <TContext> step)
 {
     builder.Integrate().AddSteps(new[] { CompactStepCompiler.ToSynchronousStep(name, step) });
     return(builder);
 }
Beispiel #6
0
 /// <summary>
 /// Adds steps specified by <paramref name="steps"/> parameter.<br/>
 /// The steps would be executed in specified order.<br/>
 /// If given step throws, other are not executed.<br/>
 /// The step name is determined from corresponding action name.<br/>
 /// Example usage:
 /// <code>
 /// builder.AddAsyncSteps(
 ///     Given_the_user_is_about_to_login,
 ///     Given_the_user_entered_valid_login,
 ///     Given_the_user_entered_valid_password,
 ///     When_the_user_clicks_login_button,
 ///     Then_the_login_operation_should_be_successful,
 ///     Then_a_welcome_message_containing_user_name_should_be_returned);
 /// </code>
 /// Expected step signature:
 /// <code>
 /// async Task Given_the_user_is_about_to_login() { /* ... */ }
 /// </code>
 /// </summary>
 /// <param name="builder">Scenario builder.</param>
 /// <param name="steps">Steps to add.</param>
 /// <returns><paramref name="builder"/> instance.</returns>
 public static IScenarioBuilder <NoContext> AddAsyncSteps(this IScenarioBuilder <NoContext> builder, params Func <Task>[] steps)
 {
     builder.Integrate().AddSteps(steps.Select(BasicStepCompiler.ToAsynchronousStep));
     return(builder);
 }