public void EdmIfExpression() { var e = new EdmIfExpression(new EdmStringConstant("if"), new EdmStringConstant("then"), new EdmStringConstant("else")); Assert.AreEqual(EdmExpressionKind.If, e.ExpressionKind, "e.ExpressionKind"); Assert.AreEqual("if", ((IEdmStringValue)e.TestExpression).Value, "e.TestExpression"); Assert.AreEqual("then", ((IEdmStringValue)e.TrueExpression).Value, "e.TrueExpression"); Assert.AreEqual("else", ((IEdmStringValue)e.FalseExpression).Value, "e.FalseExpression"); Assert.IsFalse(e.IsBad(), "e good"); try { new EdmIfExpression(null, new EdmStringConstant("then"), new EdmStringConstant("else")); Assert.Fail("exception expected"); } catch (ArgumentNullException) { } try { new EdmIfExpression(new EdmStringConstant("if"), null, new EdmStringConstant("else")); Assert.Fail("exception expected"); } catch (ArgumentNullException) { } try { new EdmIfExpression(new EdmStringConstant("if"), new EdmStringConstant("then"), null); Assert.Fail("exception expected"); } catch (ArgumentNullException) { } var ee = new MutableIfExpression(); Assert.IsNull(ee.TestExpression, "ee.TestExpression"); Assert.IsNull(ee.TrueExpression, "ee.TrueExpression"); Assert.IsNull(ee.FalseExpression, "ee.FalseExpression"); Assert.IsTrue(ee.IsBad(), "Expression is bad."); Assert.AreEqual(3, ee.Errors().Count(), "Expression has no errors"); }
public void EdmIfExpression() { var e = new EdmIfExpression(new EdmStringConstant("if"), new EdmStringConstant("then"), new EdmStringConstant("else")); Assert.AreEqual(EdmExpressionKind.If, e.ExpressionKind, "e.ExpressionKind"); Assert.AreEqual("if", ((IEdmStringValue)e.TestExpression).Value, "e.TestExpression"); Assert.AreEqual("then", ((IEdmStringValue)e.TrueExpression).Value, "e.TrueExpression"); Assert.AreEqual("else", ((IEdmStringValue)e.FalseExpression).Value, "e.FalseExpression"); Assert.IsFalse(e.IsBad(), "e good"); try { new EdmIfExpression(null, new EdmStringConstant("then"), new EdmStringConstant("else")); Assert.Fail("exception expected"); } catch (ArgumentNullException) { } try { new EdmIfExpression(new EdmStringConstant("if"), null, new EdmStringConstant("else")); Assert.Fail("exception expected"); } catch (ArgumentNullException) { } try { new EdmIfExpression(new EdmStringConstant("if"), new EdmStringConstant("then"), null); Assert.Fail("exception expected"); } catch (ArgumentNullException) { } var ee = new MutableIfExpression(); Assert.IsNull(ee.TestExpression, "ee.TestExpression"); Assert.IsNull(ee.TrueExpression, "ee.TrueExpression"); Assert.IsNull(ee.FalseExpression, "ee.FalseExpression"); Assert.IsTrue(ee.IsBad(), "Expression is bad."); Assert.AreEqual(3, ee.Errors().Count(), "Expression has no errors"); }