public void WhenAll() { var control = new ControlComponent(ControlComponent.Match.All); control.When(env => false, (env, next) => TaskHelper.Exception(new Exception())); control.When(env => true, (env, next) => { env.SetValue("branch1", "pass"); return TaskHelper.Completed(); }); control.When(env => false, (env, next) => TaskHelper.Exception(new Exception())); control.When(env => true, (env, next) => { env.SetValue("branch2", "pass"); return TaskHelper.Completed(); }); var environment = OwinFactory.CreateEnvironment(); var pipelineComponent = control as IPipelineComponent; pipelineComponent.Connect(Pipeline.ReturnDone); Task task = pipelineComponent.Execute(environment); task.Wait(); task.IsCanceled.ShouldBeFalse(); task.IsFaulted.ShouldBeFalse(); task.IsCompleted.ShouldBeTrue(); environment.GetValue<string>("branch1") .ShouldEqual("pass"); environment.GetValue<string>("branch2") .ShouldEqual("pass"); }
public void WhenAll() { var control = new ControlComponent(ControlComponent.Match.All); control.When(env => false, (env, next) => TaskHelper.Exception(new Exception())); control.When(env => true, (env, next) => { env.SetValue("branch1", "pass"); return(TaskHelper.Completed()); }); control.When(env => false, (env, next) => TaskHelper.Exception(new Exception())); control.When(env => true, (env, next) => { env.SetValue("branch2", "pass"); return(TaskHelper.Completed()); }); var environment = OwinFactory.CreateEnvironment(); var pipelineComponent = control as IPipelineComponent; pipelineComponent.Connect(Pipeline.ReturnDone); Task task = pipelineComponent.Execute(environment); task.Wait(); task.IsCanceled.ShouldBeFalse(); task.IsFaulted.ShouldBeFalse(); task.IsCompleted.ShouldBeTrue(); environment.GetValue <string>("branch1") .ShouldEqual("pass"); environment.GetValue <string>("branch2") .ShouldEqual("pass"); }
public static IPipeline All(this IPipeline pipeline, Action <ControlComponent> setup) { var controler = new ControlComponent(ControlComponent.Match.All); setup(controler); pipeline.Use(controler); return(pipeline); }
public static void IsGet(this ControlComponent component, string pathRegex, IPipelineComponent handler) { component.When(BuildGetFilter(pathRegex), handler); }
public static void IsGet(this ControlComponent component, string pathRegex, MiddlewareFunc middlewareFunc, SetupAction setup = null) { component.When(BuildGetFilter(pathRegex), middlewareFunc, setup); }
public static IPipeline All(this IPipeline pipeline, Action<ControlComponent> setup) { var controler = new ControlComponent(ControlComponent.Match.All); setup(controler); pipeline.Use(controler); return pipeline; }