public void Should_apply_system_expression_preparation_decorator() { var customExpression1 = System.Linq.Expressions.Expression.Constant("exp1"); var customExpression2 = System.Linq.Expressions.Expression.Constant("exp2"); var callCounter = new int[3]; var decorator = new TestExpressionExecutionDecorator(new DefaultExpressionExecutor(null)); decorator .With((System.Linq.Expressions.Expression x) => { callCounter[0]++; x.ShouldBeSameAs(TestExpressionExecutionDecorator.Step3_Expression); return(customExpression1); }) .With((System.Linq.Expressions.Expression x) => { callCounter[1]++; x.ShouldBeSameAs(customExpression1); return(customExpression2); }) .With((System.Linq.Expressions.Expression x) => { callCounter[2]++; x.ShouldBeSameAs(customExpression2); return(TestExpressionExecutionDecorator.Step3_Expression); }) .Execute(TestExpressionExecutionDecorator.Step0_Expression) .ShouldBeSameAs(TestExpressionExecutionDecorator.Step7_Result); decorator.AssertAllMethodsInvokedExacltyOnce(); callCounter.ShouldAllBe(x => x == 1); }
public void Should_apply_dynamic_object_result_processing_decorator() { var customResult1 = new[] { new DynamicObject("result1") }; var customResult2 = new[] { new DynamicObject("result2") }; var callCounter = new int[3]; var decorator = new TestExpressionExecutionDecorator(new DefaultExpressionExecutor(null)); decorator .With((IEnumerable <DynamicObject> x) => { callCounter[0]++; x.ShouldBeSameAs(TestExpressionExecutionDecorator.Step7_Result); return(customResult1); }) .With((IEnumerable <DynamicObject> x) => { callCounter[1]++; x.ShouldBeSameAs(customResult1); return(customResult2); }) .With((IEnumerable <DynamicObject> x) => { callCounter[2]++; x.ShouldBeSameAs(customResult2); return(TestExpressionExecutionDecorator.Step7_Result); }) .Execute(TestExpressionExecutionDecorator.Step0_Expression) .ShouldBeSameAs(TestExpressionExecutionDecorator.Step7_Result); decorator.AssertAllMethodsInvokedExacltyOnce(); callCounter.ShouldAllBe(x => x == 1); }