public void EdmLabeledExpressionReferenceExpressionTest()
        {
            var label = new EdmLabeledExpression("Label", new EdmStringConstant("foo"));
            var e = new EdmLabeledExpressionReferenceExpression(label);
            Assert.AreEqual(EdmExpressionKind.LabeledExpressionReference, e.ExpressionKind, "e.ExpressionKind");
            Assert.AreEqual("Label", e.ReferencedLabeledExpression.Name, "e.ReferencedLabeledExpression");
            Assert.IsFalse(e.IsBad(), "e good");
            this.VerifyThrowsException(typeof(InvalidOperationException), () => e.ReferencedLabeledExpression = label);

            e = new EdmLabeledExpressionReferenceExpression();
            e.ReferencedLabeledExpression = label;
            Assert.AreEqual(EdmExpressionKind.LabeledExpressionReference, e.ExpressionKind, "e.ExpressionKind");
            Assert.AreEqual("Label", e.ReferencedLabeledExpression.Name, "e.ReferencedLabeledExpression");
            Assert.IsFalse(e.IsBad(), "e good");
            this.VerifyThrowsException(typeof(InvalidOperationException), () => e.ReferencedLabeledExpression = label);

            this.VerifyThrowsException(typeof(ArgumentNullException), () => new EdmLabeledExpressionReferenceExpression(null));

            var ee = new MutableEdmLabeledExpressionReferenceExpression();
            Assert.IsNull(ee.ReferencedLabeledExpression, "e.ReferencedLabeledExpression");
            Assert.IsTrue(ee.IsBad(), "Expression is bad.");
            Assert.AreEqual(1, ee.Errors().Count(), "Expression has errors");
        }
        public void EdmLabeledExpressionReferenceExpression()
        {
            var e = new EdmLabeledExpressionReferenceExpression(new EdmLabeledExpression("qq", EdmNullExpression.Instance));
            Assert.IsFalse(e.IsBad(), "Expression not bad.");
            Assert.AreEqual(EdmExpressionKind.LabeledExpressionReference, e.ExpressionKind, "e.ExpressionKind");
            Assert.AreEqual("qq", ((EdmLabeledExpression)e.ReferencedLabeledExpression).Name, "((EdmLabeledExpression)e.ReferencedLabeledExpression).Name");

            try
            {
                e.ReferencedLabeledExpression = new EdmLabeledExpression("qqq", EdmNullExpression.Instance);
                Assert.Fail("exception expected");
            }
            catch (InvalidOperationException)
            {
            }

            e = new EdmLabeledExpressionReferenceExpression();
            Assert.IsTrue(e.IsBad(), "Expression not bad.");
            Assert.AreEqual(1, e.Errors().Count(), "Expression has errors");

            try
            {
                e.ReferencedLabeledExpression = null;
                Assert.Fail("exception expected");
            }
            catch (ArgumentNullException)
            {
            }

            e.ReferencedLabeledExpression = new EdmLabeledExpression("qqq", EdmNullExpression.Instance);
            Assert.IsFalse(e.IsBad(), "Expression not bad.");

            try
            {
                e.ReferencedLabeledExpression = new EdmLabeledExpression("qqq", EdmNullExpression.Instance);
                Assert.Fail("exception expected");
            }
            catch (InvalidOperationException)
            {
            }
        }