Esempio n. 1
0
        private async Task <CompositeStepContext> InvokeStepMethodAsync()
        {
            CompositeStepContext result;
            var ctx = AsyncStepSynchronizationContext.InstallNew();

            try
            {
                result = await _stepInvocation.Invoke(Context, PrepareParameters());

                VerifyParameters();
            }
            catch (Exception e)
            {
                if (ScenarioExecutionException.TryWrap(e, out var wrapped))
                {
                    throw wrapped;
                }
                throw;
            }
            finally
            {
                UpdateNameDetails();
                ctx.RestoreOriginal();
                await ctx.WaitForTasksAsync();
            }
            return(result);
        }
Esempio n. 2
0
        private async Task RunStepAsync()
        {
            IStepResultDescriptor result;
            var ctx = AsyncStepSynchronizationContext.InstallNew();

            try
            {
                var args = PrepareArguments();
                result = await _invocation.Invoke(Context, args);

                VerifyArguments();
            }
            catch (Exception e)
            {
                if (ScenarioExecutionException.TryWrap(e, out var wrapped))
                {
                    throw wrapped;
                }
                throw;
            }
            finally
            {
                UpdateNameDetails();
                ctx.RestoreOriginal();
                await ctx.WaitForTasksAsync();
            }

            await InvokeSubStepsAsync(result);
        }
Esempio n. 3
0
        private async Task TimeMeasuredInvokeAsync()
        {
            var watch = ExecutionTimeWatch.StartNew();
            var ctx   = AsyncStepSynchronizationContext.InstallNew();

            try
            {
                try
                {
                    await _stepInvocation.Invoke(_scenarioContext, PrepareParameters());
                }
                finally
                {
                    ctx.RestoreOriginal();
                    await ctx.WaitForTasksAsync();
                }
            }
            finally
            {
                _result.SetExecutionTime(watch.GetTime());
            }
        }