Ejemplo n.º 1
0
        /// <summary>
        /// Adds steps specified by <paramref name="steps"/> parameter to the composite step.<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>
        /// AddSteps(
        ///         _ => Given_numbers(5, 8),
        ///         _ => When_I_add_them(),
        ///         _ => I_should_receive_number(13))
        /// </code>
        /// Expected step signature: <code>void Given_numbers(params int[] numbers) { /* ... */ }</code>
        /// </summary>
        /// <param name="builder">Builder.</param>
        /// <param name="steps">Steps to add, like: <c>AddSteps(_ => Given_numbers(5, 8), _ => When_I_add_them(), _ => I_should_receive_number(13))</c></param>
        public static ICompositeStepBuilder <TContext> AddSteps <TContext>(this ICompositeStepBuilder <TContext> builder, params Expression <Action <TContext> >[] steps)
        {
            var coreBuilder = builder.Integrate();
            var compiler    = new ExtendedStepCompiler <TContext>(coreBuilder.Configuration);

            coreBuilder.AddSteps(steps.Select(compiler.ToStep));
            return(builder);
        }
Ejemplo n.º 2
0
 public ContextualCompositeStepBuilder(ICompositeStepBuilder runner, Func <IDependencyResolver, object> contextResolver)
 {
     _target = runner.Integrate().WithStepContext(contextResolver);
 }
Ejemplo n.º 3
0
 public ContextualCompositeStepBuilder(ICompositeStepBuilder runner, Func <object> contextProvider, bool takeOwnership)
 {
     _target = runner.Integrate().WithStepContext(contextProvider, takeOwnership);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Adds asynchronous step with name specified by <paramref name="name"/> parameter and action specified by <paramref name="step"/> parameter to the composite step.
 /// </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 ICompositeStepBuilder <TContext> AddAsyncStep <TContext>(this ICompositeStepBuilder <TContext> builder, string name, Func <TContext, Task> step)
 {
     builder.Integrate().AddSteps(new[] { CompactStepCompiler.ToAsynchronousStep(name, step) });
     return(builder);
 }
 public IIntegrableStepGroupBuilder AddSteps(IEnumerable <StepDescriptor> steps)
 {
     _internal.Integrate().AddSteps(steps);
     return(this);
 }
Ejemplo n.º 6
0
 private static ExtendedCompositeStepBuilder <TContext> AsExtended <TContext>(this ICompositeStepBuilder <TContext> runner)
 {
     return(runner.Integrate().Enrich(ExtendedCompositeStepBuilder <TContext> .Create));
 }
Ejemplo n.º 7
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">Composite step builder.</param>
 /// <param name="steps">Steps to add.</param>
 /// <returns><paramref name="builder"/> instance.</returns>
 public static ICompositeStepBuilder <NoContext> AddAsyncSteps(this ICompositeStepBuilder <NoContext> builder, params Func <Task>[] steps)
 {
     builder.Integrate().AddSteps(steps.Select(BasicStepCompiler.ToAsynchronousStep));
     return(builder);
 }