public void EdmEnumMemberReferenceExpression()
        {
            var et = new EdmEnumType("NS", "Spicy");
            var em = new EdmEnumMember(et, "Hot", new EdmIntegerConstant(5));
            var e  = new EdmEnumMemberReferenceExpression(em);

            Assert.AreEqual(EdmExpressionKind.EnumMemberReference, e.ExpressionKind, "e.ExpressionKind");
            Assert.AreEqual("Hot", e.ReferencedEnumMember.Name, "e.ReferencedEnumMember");
            Assert.IsFalse(e.IsBad(), "e good");

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

            var ee = new MutableEdmEnumMemberReferenceExpression();

            Assert.IsNull(ee.ReferencedEnumMember, "e.ReferencedEntitySet");
            Assert.IsTrue(ee.IsBad(), "Expression is bad.");
            Assert.AreEqual(1, ee.Errors().Count(), "Expression has errors");
        }
Exemple #2
0
        public static void SetConformanceLevelCapabilitiesAnnotation(this EdmModel model, IEdmEntityContainer container, CapabilitiesConformanceLevelType level)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }
            if (container == null)
            {
                throw new ArgumentNullException("container");
            }

            var target     = container;
            var term       = ConformanceLevelTerm;
            var name       = new EdmEnumTypeReference(ConformanceLevelTypeType, false).ToStringLiteral((long)level);
            var expression = new EdmEnumMemberReferenceExpression(ConformanceLevelTypeType.Members.Single(m => m.Name == name));
            var annotation = new EdmAnnotation(target, term, expression);

            annotation.SetSerializationLocation(model, container.ToSerializationLocation());
            model.AddVocabularyAnnotation(annotation);
        }
Exemple #3
0
        public static void SetPermissionsCoreAnnotation(this EdmModel model, IEdmProperty property, CorePermission value)
        {
            if (model == null)
            {
                throw new ArgumentNullException("model");
            }
            if (property == null)
            {
                throw new ArgumentNullException("property");
            }

            var target     = property;
            var term       = PermissionsTerm;
            var name       = new EdmEnumTypeReference(PermissionType, false).ToStringLiteral((long)value);
            var expression = new EdmEnumMemberReferenceExpression(PermissionType.Members.Single(m => m.Name == name));
            var annotation = new EdmAnnotation(target, term, expression);

            annotation.SetSerializationLocation(model, property.ToSerializationLocation());
            model.AddVocabularyAnnotation(annotation);
        }