예제 #1
0
        public void CanExecutePipelineNoTarget()
        {
            var pipeline = new BehaviorPipeline(new ExecuteDelegate((m, n) => m.CreateValueReturn(null)));

            Action a = CanExecutePipelineNoTarget;

            pipeline.Execute(new MethodInvocation(this, a.GetMethodInfo()));
        }
예제 #2
0
        public void WhenExecutingPipelineWithNoTarget_ThenThrowsIfNoBehaviorReturns()
        {
            var pipeline = new BehaviorPipeline();

            Action a = CanExecutePipelineNoTarget;

            Assert.Throws <NotImplementedException>(() => pipeline.Execute(new MethodInvocation(this, a.GetMethodInfo())));
        }
예제 #3
0
        public void CanExecutePipelineWithTarget()
        {
            var pipeline = new BehaviorPipeline();

            Action a = CanExecutePipelineWithTarget;

            pipeline.Execute(MethodInvocation.Create(this, a.GetMethodInfo(), (m, n) => m.CreateReturn()));
        }
예제 #4
0
        public void WhenExecutingPipelineResultWithNoTarget_ThenThrowsIfNoResult()
        {
            var pipeline = new BehaviorPipeline();

            Func <object> f = NonVoidMethod;

            Assert.Throws <NotImplementedException>(()
                                                    => pipeline.Execute <object>(new MethodInvocation(this, f.GetMethodInfo())));
        }
예제 #5
0
        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())));
        }
예제 #6
0
        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())));
        }
예제 #7
0
        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())));
        }
예제 #8
0
        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())));
        }
예제 #9
0
        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));
        }
예제 #10
0
 public override bool Equals(object obj) => pipeline.Execute <bool>(new MethodInvocation(this, MethodBase.GetCurrentMethod(), obj));
예제 #11
0
 public void Add(int value) => pipeline.Execute(new MethodInvocation(this, MethodBase.GetCurrentMethod(), value));
예제 #12
0
 public void Do() => pipeline.Execute(new MethodInvocation(this, MethodBase.GetCurrentMethod()));