コード例 #1
0
        public static void ExecuteActions(this TestCaseContext context, IPipelineActionFactory actionFactory, IEnumerable <ResolvableItemDescription> actionDescriptions, bool suppressExceptionsTilltheEnd)
        {
            IList <Exception> exceptions = null;

            foreach (var actionDescription in actionDescriptions)
            {
                if (actionDescription.Name.StartsWith("#"))
                {
                    context.Logger.LogDebug("Skipping {0}", actionDescription.Name);
                    continue;
                }

                context.Logger.LogDebug("Creating action {0} with parameters {1}", actionDescription.Name, actionDescription.Parameters.Select(_ => _.Key + ": " + JsonConvert.SerializeObject(_.Value)));
                var action = actionFactory.Get(actionDescription.Name, actionDescription.Parameters);
                try
                {
                    action.Execute(context);
                }
                catch (Exception ex)
                {
                    if (suppressExceptionsTilltheEnd)
                    {
                        context.Logger.LogWarning("An exception occurred {message}", ex.Message);
                        if (exceptions == null)
                        {
                            exceptions = new List <Exception>();
                        }
                        exceptions.Add(ex);
                    }
                    else
                    {
                        throw;
                    }
                }
                finally
                {
                    actionFactory.Release(action);
                }
            }

            if (exceptions != null)
            {
                throw new AggregateException(exceptions);
            }
        }
コード例 #2
0
 public UrlBasedActionPipelineProcessor(IPipelineActionFactory actionFactory, IEnumerable <object> actions)
 {
     _actionFactory     = actionFactory;
     ActionDecsriptions = actions.Select(Convert).ToList();
 }