public void ValueTerm_If_OnEntitySet()
        {
            this.SetupModels();

            var container = new EdmEntityContainer("NS1", "myContainer");
            var set = container.AddEntitySet("personSet", this.baseModel.FindEntityType("NS1.Person"));
            (this.baseModel as EdmModel).AddElement(container);

            IEdmValueTerm termStringValue = this.longDefinitionModel.FindValueTerm("bar.StringValue");
            var ifExpression = new EdmIfExpression(
                new EdmApplyExpression(this.functionsModel.FindOperations("Functions.True").First()),
                new EdmStringConstant("s1"),
                new EdmStringConstant("s2"));
            this.CreateAndAttachValueAnnotation(set, termStringValue, ifExpression);

            string expectedCsdl =
@"<Schema Namespace=""NS1"" xmlns=""http://docs.oasis-open.org/odata/ns/edm"">
    <EntityType Name=""Person"">
        <Key>
            <PropertyRef Name=""Name"" />
        </Key>
        <Property Name=""Name"" Type=""Edm.String"" Nullable=""false"" />
        <Property Name=""Birthday"" Type=""Edm.DateTimeOffset"" Nullable=""false"" />
    </EntityType>
    <EntityContainer Name=""myContainer"">
        <EntitySet Name=""personSet"" EntityType=""NS1.Person"" />
    </EntityContainer>
    <Annotations Target=""NS1.myContainer/personSet"">
        <Annotation Term=""bar.StringValue"">
            <If>
                <Apply Function=""Functions.True"" />
                <String>s1</String>
                <String>s2</String>    
            </If>
        </Annotation>
    </Annotations>
</Schema>";
            this.SerializeAndVerifyAgainst(this.baseModel, expectedCsdl);
        }
        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");
        }