public async Task Full_integration_test()
        {
            await _runner
            .AddAsyncSteps(Async_Task_Step_1)
            .AddSteps(Void_Step_2)
            .AddSteps(Async_Void_Step_3)
            .AddAsyncSteps(_ => Async_Task_Step4())
            .AddSteps(_ => Void_Step5())
            .AddSteps(_ => Async_Void_Step6())
            .AddSteps(Assert_Steps)
            .RunAsync();

            Assert_Steps();
        }
Example #2
0
        /// <summary>
        /// Runs asynchronous test scenario by executing given steps in specified order.<br/>
        /// If given step throws, other are not executed.<br/>
        /// The scenario name is determined from the current scenario test method.<br/>
        /// Scenario labels are determined from <see cref="LabelAttribute"/> attributes applied on scenario method.<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 executed with context, the context instance is provided with lambda parameter.<br/>
        /// Example usage:
        /// <code>
        /// await Runner.RunScenarioAsync(
        ///         _ => 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>
        /// <remarks>This is an asynchronous method and should be awaited.</remarks>
        /// <param name="runner">Runner.</param>
        /// <param name="steps">List of steps to execute in order.</param>
        public static async Task RunScenarioAsync <TContext>(this IBddRunner <TContext> runner, params Expression <Func <TContext, Task> >[] steps)
        {
            try
            {
                var scenario = runner
                               .AddAsyncSteps(steps)
                               .Integrate().Core
                               .WithCapturedScenarioDetails()
                               .Build();

                await scenario.ExecuteAsync();
            }
            catch (ScenarioExecutionException e)
            {
                e.GetOriginal().Throw();
            }
        }