public void Should_apply_all_custom_strategies_and_return_expected_result() { var decorator = new TestExpressionExecutionDecorator(new DefaultExpressionExecutor(null)); decorator .Execute(TestExpressionExecutionDecorator.Step0_Expression) .ShouldBeSameAs(TestExpressionExecutionDecorator.Step7_Result); decorator.AssertAllMethodsInvokedExacltyOnce(); }
public void Should_replace_expression_transformation_decorator() { var callCounter = new int[1]; var decorator = new TestExpressionExecutionDecorator(new DefaultExpressionExecutor(null)); decorator .With(new Func <Expression, System.Linq.Expressions.Expression>(x => throw ShouldHaveBeenReplacedException)) .With(new Func <Expression, System.Linq.Expressions.Expression>(x => throw ShouldHaveBeenReplacedException)) .With((Expression x) => { callCounter[0]++; x.ShouldBeSameAs(TestExpressionExecutionDecorator.Step1_Expression); return(TestExpressionExecutionDecorator.Step2_Expression); }) .Execute(TestExpressionExecutionDecorator.Step0_Expression) .ShouldBeSameAs(TestExpressionExecutionDecorator.Step7_Result); decorator.AssertAllMethodsInvokedExacltyOnce(skip: 1); callCounter.ShouldAllBe(x => x == 1); }
public void Should_replace_result_to_dynamic_object_projection_decorator() { var callCounter = new int[1]; var decorator = new TestExpressionExecutionDecorator(new DefaultExpressionExecutor(null)); decorator .With(new Func <object, IEnumerable <DynamicObject> >(x => throw ShouldHaveBeenReplacedException)) .With(new Func <object, IEnumerable <DynamicObject> >(x => throw ShouldHaveBeenReplacedException)) .With((object x) => { callCounter[0]++; x.ShouldBeSameAs(TestExpressionExecutionDecorator.Step5_Result); return(TestExpressionExecutionDecorator.Step6_Result); }) .Execute(TestExpressionExecutionDecorator.Step0_Expression) .ShouldBeSameAs(TestExpressionExecutionDecorator.Step7_Result); decorator.AssertAllMethodsInvokedExacltyOnce(skip: 5); callCounter.ShouldAllBe(x => x == 1); }