public void test_THAT_andalso_with_nested_andalso_IS_translated_to_caml_properly() { // arrange var leftEqOperation = MockRepository.GenerateStub <EqOperation>(null, null, null); var rightEqOperation = MockRepository.GenerateStub <EqOperation>(null, null, null); var resultBuilder = new OperationResultBuilder(); var leftOperation = new AndAlsoOperation(resultBuilder, leftEqOperation, rightEqOperation); leftEqOperation.Stub(o => o.ToResult()).Return(xelementResult("Eq1")); rightEqOperation.Stub(o => o.ToResult()).Return(xelementResult("Eq2")); var operation = new AndAlsoOperation(resultBuilder, leftOperation, rightEqOperation); // act string caml = operation.ToResult().ToString(); // assert string expected = @"<And> <And> <Eq1 /> <Eq2 /> </And> <Eq2 /> </And>"; Assert.That(caml, Is.EqualTo(expected).Using(new CamlComparer())); }
public override IOperation GetOperation(LambdaExpression expr) { if (!this.IsValid(expr)) { throw new NonSupportedExpressionException(expr); } var leftOperation = this.GetLeftOperation(expr); var rightOperation = this.GetRightOperation(expr); var operation = new AndAlsoOperation(this.OperationResultBuilder, leftOperation, rightOperation); return operation; }
public void test_THAT_and_also_operation_IS_converted_to_expression_correctly() { var op11 = new FieldRefOperand("Status"); var op12 = new BooleanValueOperand(true); var op1 = new EqOperation(null, op11, op12); var op21 = new FieldRefOperand("Status"); var op22 = new BooleanValueOperand(false); var op2 = new EqOperation(null, op21, op22); var op = new AndAlsoOperation(null, op1, op2); var expr = op.ToExpression(); Assert.That(expr.ToString(), Is.EqualTo("(Convert(x.get_Item(\"Status\")) AndAlso Not(Convert(x.get_Item(\"Status\"))))")); }