public void CanExecutePipelineNoTarget() { var pipeline = new BehaviorPipeline(new ExecuteDelegate((m, n) => m.CreateValueReturn(null))); Action a = CanExecutePipelineNoTarget; pipeline.Execute(new MethodInvocation(this, a.GetMethodInfo())); }
public void WhenExecutingPipelineWithNoTarget_ThenThrowsIfNoBehaviorReturns() { var pipeline = new BehaviorPipeline(); Action a = CanExecutePipelineNoTarget; Assert.Throws <NotImplementedException>(() => pipeline.Execute(new MethodInvocation(this, a.GetMethodInfo()))); }
public void CanExecutePipelineWithTarget() { var pipeline = new BehaviorPipeline(); Action a = CanExecutePipelineWithTarget; pipeline.Execute(MethodInvocation.Create(this, a.GetMethodInfo(), (m, n) => m.CreateReturn())); }
public void WhenExecutingPipelineResultWithNoTarget_ThenThrowsIfNoResult() { var pipeline = new BehaviorPipeline(); Func <object> f = NonVoidMethod; Assert.Throws <NotImplementedException>(() => pipeline.Execute <object>(new MethodInvocation(this, f.GetMethodInfo()))); }
public void CanExecutePipelineResultNoTarget() { var value = new object(); var pipeline = new BehaviorPipeline(new ExecuteDelegate((m, n) => m.CreateValueReturn(value))); Func <object> f = NonVoidMethod; Assert.Same(value, pipeline.Execute <object>(new MethodInvocation(this, f.GetMethodInfo()))); }
public void WhenExecutingPipelineResult_ThenBehaviorCanThrow() { var pipeline = new BehaviorPipeline( new ExecuteHandler((m, n) => m.CreateExceptionReturn(new ArgumentException()))); Func <object?> f = NonVoidMethod; Assert.Throws <ArgumentException>(() => pipeline.Execute <object>(MethodInvocation.Create(this, f.GetMethodInfo()))); }
public void WhenExecutingPipeline_ThenBehaviorCanThrow() { var pipeline = new BehaviorPipeline( new ExecuteHandler((m, n) => m.CreateExceptionReturn(new ArgumentException()))); Action a = WhenInvokingPipeline_ThenBehaviorsCanReturnException; Assert.Throws <ArgumentException>(() => pipeline.Execute(MethodInvocation.Create(this, a.GetMethodInfo()))); }
public void WhenExecutingPipelineResult_ThenBehaviorCanThrow() { var pipeline = new BehaviorPipeline( new ExecuteDelegate((m, n) => m.CreateExceptionReturn(new ArgumentException()))); Func <object> f = NonVoidMethod; Assert.Throws <ArgumentException>(() => pipeline.Execute <object>(new MethodInvocation(this, f.GetMethodInfo()), new ExecuteDelegate((m, n) => throw new NotImplementedException()))); }
public void WhenSkippingBehavior_ThenBehaviorIsNotExecuted() { var pipeline = new BehaviorPipeline(); pipeline.Behaviors.Add(new TestBehavior()); var invocation = MethodInvocation.Create(new object(), typeof(object).GetMethod("ToString") !); invocation.SkipBehavior <TestBehavior>(); Assert.Throws <NotImplementedException>(() => pipeline.Execute <string>(invocation)); }
public override bool Equals(object obj) => pipeline.Execute <bool>(new MethodInvocation(this, MethodBase.GetCurrentMethod(), obj));
public void Add(int value) => pipeline.Execute(new MethodInvocation(this, MethodBase.GetCurrentMethod(), value));
public void Do() => pipeline.Execute(new MethodInvocation(this, MethodBase.GetCurrentMethod()));