Example #1
0
        public void EdmSingletonAnnotationTests() 
        {
            EdmModel model = new EdmModel();

            EdmStructuralProperty customerProperty = new EdmStructuralProperty(customerType, "Name", EdmCoreModel.Instance.GetString(false));
            customerType.AddProperty(customerProperty);
            model.AddElement(this.customerType);

            EdmSingleton vipCustomer = new EdmSingleton(this.entityContainer, "VIP", this.customerType);

            EdmTerm term = new EdmTerm(myNamespace, "SingletonAnnotation", EdmPrimitiveTypeKind.String);
            var annotation = new EdmAnnotation(vipCustomer, term, new EdmStringConstant("Singleton Annotation"));
            model.AddVocabularyAnnotation(annotation);

            var singletonAnnotation = vipCustomer.VocabularyAnnotations(model).Single();
            Assert.Equal(vipCustomer, singletonAnnotation.Target);
            Assert.Equal("SingletonAnnotation", singletonAnnotation.Term.Name);

            singletonAnnotation = model.FindDeclaredVocabularyAnnotations(vipCustomer).Single();
            Assert.Equal(vipCustomer, singletonAnnotation.Target);
            Assert.Equal("SingletonAnnotation", singletonAnnotation.Term.Name);

            EdmTerm propertyTerm = new EdmTerm(myNamespace, "SingletonPropertyAnnotation", EdmPrimitiveTypeKind.String);
            var propertyAnnotation = new EdmAnnotation(customerProperty, propertyTerm, new EdmStringConstant("Singleton Property Annotation"));
            model.AddVocabularyAnnotation(propertyAnnotation);

            var singletonPropertyAnnotation = customerProperty.VocabularyAnnotations(model).Single();
            Assert.Equal(customerProperty, singletonPropertyAnnotation.Target);
            Assert.Equal("SingletonPropertyAnnotation", singletonPropertyAnnotation.Term.Name);
        }
        public void AmbiguousValueTermTest()
        {
            EdmModel model = new EdmModel();

            IEdmValueTerm term1 = new EdmTerm("Foo", "Bar", EdmPrimitiveTypeKind.Byte);
            IEdmValueTerm term2 = new EdmTerm("Foo",  "Bar", EdmPrimitiveTypeKind.Decimal);
            IEdmValueTerm term3 = new EdmTerm("Foo",  "Bar", EdmCoreModel.Instance.GetPrimitive(EdmPrimitiveTypeKind.Double, false));

            Assert.AreEqual(EdmTermKind.Value, term1.TermKind, "EdmTermKind is correct.");

            model.AddElement(term1);
            Assert.AreEqual(term1, model.FindValueTerm("Foo.Bar"), "Correct item.");

            model.AddElement(term2);
            model.AddElement(term3);

            IEdmValueTerm ambiguous = model.FindValueTerm("Foo.Bar");
            Assert.IsTrue(ambiguous.IsBad(), "Ambiguous binding is bad");

            Assert.AreEqual(EdmSchemaElementKind.ValueTerm, ambiguous.SchemaElementKind, "Correct schema element kind.");
            Assert.AreEqual("Foo", ambiguous.Namespace, "Correct Namespace");
            Assert.AreEqual("Bar", ambiguous.Name, "Correct Name");
            Assert.AreEqual(EdmTermKind.Value, ambiguous.TermKind, "Correct term kind.");
            Assert.IsTrue(ambiguous.Type.IsBad(), "Type is bad.");
        }
Example #3
0
        private static void EnumMemberExpressionDemo()
        {
            Console.WriteLine("EnumMemberExpressionDemo");

            var model = new EdmModel();
            var personType = new EdmEntityType("TestNS", "Person");
            model.AddElement(personType);
            var pid = personType.AddStructuralProperty("Id", EdmPrimitiveTypeKind.Int32, false);
            personType.AddKeys(pid);
            personType.AddStructuralProperty("Name", EdmPrimitiveTypeKind.String);
            var colorType = new EdmEnumType("TestNS2", "Color", true);
            model.AddElement(colorType);
            colorType.AddMember("Cyan", new EdmIntegerConstant(1));
            colorType.AddMember("Blue", new EdmIntegerConstant(2));
            var outColorTerm = new EdmTerm("TestNS", "OutColor", new EdmEnumTypeReference(colorType, true));
            model.AddElement(outColorTerm);
            var exp = new EdmEnumMemberExpression(
                new EdmEnumMember(colorType, "Blue", new EdmIntegerConstant(2))
            );

            var annotation = new EdmAnnotation(personType, outColorTerm, exp);
            annotation.SetSerializationLocation(model, EdmVocabularyAnnotationSerializationLocation.Inline);
            model.SetVocabularyAnnotation(annotation);

            ShowModel(model);

            var ann = model.FindVocabularyAnnotations<IEdmValueAnnotation>(personType, "TestNS.OutColor").First();
            var memberExp = (IEdmEnumMemberExpression)ann.Value;
            foreach (var member in memberExp.EnumMembers)
            {
                Console.WriteLine(member.Name);
            }
        }
        public void EnsureDuplicateTermAndFunctionReturnTrue()
        {
            EdmModel model = new EdmModel();
            var edmFunction = new EdmFunction("n.s", "GetStuff", EdmCoreModel.Instance.GetString(true), false /*isBound*/, null /*entitySetPath*/, false /*isComposable*/);
            model.AddElement(edmFunction);

            EdmModel otherModel = new EdmModel();
            var edmTerm = new EdmTerm("n.s", "GetStuff", EdmPrimitiveTypeKind.Int32);
            otherModel.AddElement(edmTerm);
            model.AddReferencedModel(otherModel);

            model.OperationOrNameExistsInReferencedModel(edmFunction, edmFunction.FullName()).Should().BeTrue();
        }
        public static IEdmModel InterfaceCriticalPropertyValueMustNotBeNullOnlyModel()
        {
            var model = new EdmModel();
            var valueTerm = new EdmTerm("DefaultNamespace", "Note", EdmCoreModel.Instance.GetString(true));
            model.AddElement(valueTerm);

            var valueAnnotation = new MutableValueAnnotation()
            {
                Target = valueTerm
            };
            model.AddVocabularyAnnotation(valueAnnotation);

            return model;
        }
        public static IEdmModel EdmValueKindInterfaceCriticalKindValueUnexpectedOnlyModel()
        {
            var model = new EdmModel();
            var valueTerm = new EdmTerm("DefaultNamespace", "Note", EdmCoreModel.Instance.GetString(true));
            model.AddElement(valueTerm);

            var badString = new CustomStringConstant("foo", EdmExpressionKind.StringConstant, (EdmValueKind)123);

            var valueAnnotation = new EdmAnnotation(
                valueTerm,
                valueTerm,
                badString);
            model.AddVocabularyAnnotation(valueAnnotation);

            return model;
        }
        public static IEdmModel InterfaceCriticalPropertyValueMustNotBeNullUsingCollectionTypeModel()
        {
            var model = new EdmModel();

            var badType = new CustomCollectionType(null, EdmTypeKind.Collection);
            var badTypeRef = new EdmCollectionTypeReference(badType);
            var valueTerm = new EdmTerm("NS", "Note", badTypeRef);
            model.AddElement(valueTerm);
            
            return model;
        }
        public static IEdmModel InterfaceCriticalPropertyValueMustNotBeNullUsingEnumValueNullMemberModel()
        {
            var model = new EdmModel();

            var enumType = new EdmEnumType("NS", "Enum");
            var enumMember = new CustomEnumMember(enumType, "foo", null);
            var enumTypeRef = new EdmEnumTypeReference(enumType, true);
            enumType.AddMember(new EdmEnumMember(enumType, "bar", new EdmEnumValue(enumTypeRef, enumMember)));
            var valueTerm = new EdmTerm("NS", "Note", enumTypeRef);
            model.AddElement(valueTerm);

            return model;
        }
        public static IEdmModel InterfaceCriticalKindValueMismatchOnlyUsingCollectionTypeReferenceModel()
        {
            var model = new EdmModel();

            var badType = new CustomCollectionType(new EdmStringTypeReference(EdmCoreModel.Instance.GetPrimitiveType(EdmPrimitiveTypeKind.String), false), EdmTypeKind.Enum);
            var badTypeRef = new EdmCollectionTypeReference(badType);
            var valueTerm = new EdmTerm("NS", "Note", badTypeRef);
            model.AddElement(valueTerm);

            return model;
        }
        public static IEdmModel InterfaceCriticalKindValueMismatchOnlyUsingEnumTypeReferenceModel()
        {
            var model = new EdmModel();

            var badType = new CustomEnumType("NS", "Enum", EdmTypeKind.Complex);
            var badTypeRef = new EdmEnumTypeReference(badType, true);
            var valueTerm = new EdmTerm("NS", "Note", badTypeRef);
            model.AddElement(valueTerm);

            return model;
        }
        public static IEdmModel InterfaceCriticalPropertyValueMustNotBeNullUsingEnumTypeReferenceModel()
        {
            var model = new EdmModel();

            var badType = new CustomEnumType("NS", "Enum", (IEdmPrimitiveType)null);
            var badTypeRef = new EdmEnumTypeReference(badType, true);
            var valueTerm = new EdmTerm("NS", "Note", badTypeRef);
            model.AddElement(valueTerm);

            return model;
        }
        public static IEdmModel InterfaceCriticalKindValueUnexpectedWithOtherErrorsModel()
        {
            var model = new EdmModel();
            var valueTerm = new EdmTerm("DefaultNamespace", "Note", EdmCoreModel.Instance.GetString(true));
            model.AddElement(valueTerm);
            model.AddElement(valueTerm);

            var entity = new EdmEntityType("DefaultNamespace", "foo");
            model.AddElement(entity);

            var entityContainer = new EdmEntityContainer("DefaultNamespace", "container");
            model.AddElement(entityContainer);

            var badString = new CustomStringConstant("foo", EdmExpressionKind.None, EdmValueKind.String);

            var valueAnnotation = new EdmAnnotation(
                valueTerm,
                valueTerm,
                badString);
            model.AddVocabularyAnnotation(valueAnnotation);

            var valueAnnotation2 = new EdmAnnotation(
                valueTerm,
                valueTerm,
                new EdmStringConstant("foo"));
            model.AddVocabularyAnnotation(valueAnnotation2);

            return model;
        }
Example #13
0
        private EdmModel BuildBasicModelWithValueTerm(IEdmTypeReference valueKindType)
        {
            var model = new EdmModel();
            var container = new EdmEntityContainer("foo", "Container");
            model.AddElement(container);

            var valueTerm = new EdmTerm("foo", "ValueTerm", valueKindType);
            model.AddElement(valueTerm);

            return model;
        }
        public static IEdmModel ValueAnnotationValidDefaultDurationConstantModel()
        {
            var model = new EdmModel();
            var valueTerm = new EdmTerm("DefaultNamespace", "Note", EdmCoreModel.Instance.GetDuration(true));
            model.AddElement(valueTerm);

            var valueAnnotation = new EdmAnnotation(
                valueTerm,
                valueTerm,
                new EdmDurationConstant(new TimeSpan()));

            valueAnnotation.SetSerializationLocation(model, EdmVocabularyAnnotationSerializationLocation.OutOfLine);
            model.AddVocabularyAnnotation(valueAnnotation);

            return model;
        }
        private void AddStockVocabularies(IEdmModel edmModel, EdmModel stockModel)
        {
            foreach (var valueTypeTerm in edmModel.SchemaElements.OfType<IEdmValueTerm>())
            {
                var stockValueTerm = new EdmTerm(valueTypeTerm.Namespace, valueTypeTerm.Name, this.ConvertToStockTypeReference(valueTypeTerm.Type, stockModel));
                stockModel.AddElement(stockValueTerm);
            }

            foreach (var edmAnnotation in edmModel.VocabularyAnnotations.OfType<IEdmValueAnnotation>())
            {
                var stockAnnotation = new EdmAnnotation(
                    this.ConvertToStockVocabularyAnnotatable(edmAnnotation.Target, stockModel),
                    stockModel.FindValueTerm(((IEdmSchemaElement)edmAnnotation.Term).FullName()),
                    edmAnnotation.Qualifier,
                    this.ConvertToStockExpression(edmAnnotation.Value, stockModel)
                    // TODO: Do we need FullName()?  
                    // TODO: FullName() is Namespace.Name, but should it be NamespaceUri.Name? 
                    // TODO: FullName() on Annotation.Term returns Vocabulary0.TermName. Vocabulary0 is the using Alias. Is this correct? 
                    // TODO: Namepsace on Annotation.Term returns Vocabulary0, which is the using Alias. Is this correct?
                );
                stockModel.AddVocabularyAnnotation(stockAnnotation);
            }
        }
        public static IEdmModel InvalidPropertyTypeUsingIsTypeOnOutOfLineAnnotationModel()
        {
            var model = new EdmModel();

            var friendName = new EdmTerm("NS", "FriendName", EdmCoreModel.Instance.GetString(true));
            model.AddElement(friendName);

            var valueAnnotation = new EdmAnnotation(
                friendName,
                friendName,
                new EdmIsTypeExpression(new EdmStringConstant("foo"), EdmCoreModel.Instance.GetString(true)));
            valueAnnotation.SetSerializationLocation(model, EdmVocabularyAnnotationSerializationLocation.OutOfLine);
            model.AddVocabularyAnnotation(valueAnnotation);

            return model;
        }
        public static IEdmModel InvalidPropertyTypeUsingIsTypeOnInlineAnnotationModel()
        {
            var model = new EdmModel();

            var bike = new EdmComplexType("NS", "Bike");
            bike.AddStructuralProperty("Color", EdmCoreModel.Instance.GetString(true));
            model.AddElement(bike);

            var car = new EdmComplexType("NS", "Car");
            var carExpensive = car.AddStructuralProperty("Expensive", new EdmComplexTypeReference(bike, true));
            model.AddElement(car);

            var carTerm = new EdmTerm("NS", "CarTerm", new EdmComplexTypeReference(car, true));
            model.AddElement(carTerm);

            var valueAnnotation = new EdmAnnotation(
                car,
                carTerm,
                new EdmRecordExpression(
                    new EdmPropertyConstructor(carExpensive.Name, new EdmIsTypeExpression(new EdmStringConstant("foo"), EdmCoreModel.Instance.GetString(true)))));
            valueAnnotation.SetSerializationLocation(model, EdmVocabularyAnnotationSerializationLocation.Inline);
            model.AddVocabularyAnnotation(valueAnnotation);

            return model;
        }
        public static IEdmModel CastResultTrueEvaluationModel()
        {
            var model = new EdmModel();

            var address = new EdmComplexType("NS", "Address");
            address.AddStructuralProperty("StreetNumber", EdmCoreModel.Instance.GetInt32(true));
            address.AddStructuralProperty("StreetName", EdmCoreModel.Instance.GetString(true));
            model.AddElement(address);

            var friend = new EdmEntityType("NS", "Friend");
            var friendName = friend.AddStructuralProperty("Name", EdmCoreModel.Instance.GetString(false));
            friend.AddKeys(friendName);
            var friendAddress = friend.AddStructuralProperty("Address", new EdmComplexTypeReference(address, true));
            model.AddElement(friend);

            var addressRecord = new EdmRecordExpression(new EdmPropertyConstructor[] { 
                new EdmPropertyConstructor("StreetNumber", new EdmIntegerConstant(3)), 
                new EdmPropertyConstructor("StreetName", new EdmStringConstant("에O詰 갂คำŚёæ")) 
            });

            var friendAddressCast = new EdmCastExpression(addressRecord, new EdmComplexTypeReference(address, true));

            var friendTerm = new EdmTerm("NS", "FriendTerm", new EdmEntityTypeReference(friend, true));
            model.AddElement(friendTerm);

            var valueAnnotation = new EdmAnnotation(
                friend,
                friendTerm,
                new EdmRecordExpression(
                    new EdmPropertyConstructor(friendName.Name, new EdmStringConstant("foo")),
                    new EdmPropertyConstructor(friendAddress.Name, friendAddressCast)));

            valueAnnotation.SetSerializationLocation(model, EdmVocabularyAnnotationSerializationLocation.OutOfLine);
            model.AddVocabularyAnnotation(valueAnnotation);

            return model;
        }
        public static IEdmModel CastNullableToNonNullableOnInlineAnnotationModel()
        {
            var model = new EdmModel();

            var address = new EdmComplexType("NS", "Address");
            address.AddStructuralProperty("StreetNumber", EdmCoreModel.Instance.GetInt32(true));
            address.AddStructuralProperty("StreetName", EdmCoreModel.Instance.GetString(true));
            model.AddElement(address);

            var friend = new EdmComplexType("NS", "Friend");
            friend.AddStructuralProperty("Name", EdmCoreModel.Instance.GetString(true));
            friend.AddStructuralProperty("NickNames", EdmCoreModel.GetCollection(EdmCoreModel.Instance.GetString(true)));
            friend.AddStructuralProperty("Address", new EdmComplexTypeReference(address, true));
            model.AddElement(friend);

            var friendInfo = new EdmTerm("NS", "FriendInfo", EdmCoreModel.GetCollection(new EdmComplexTypeReference(friend, true)));
            model.AddElement(friendInfo);

            var valueAnnotationCast = new EdmCastExpression(new EdmCollectionExpression(new EdmStringConstant("foo"), new EdmStringConstant("bar")), new EdmComplexTypeReference(friend, true));
            var valueAnnotation = new EdmAnnotation(
                friendInfo,
                friendInfo,
                valueAnnotationCast);
            valueAnnotation.SetSerializationLocation(model, EdmVocabularyAnnotationSerializationLocation.Inline);
            model.AddVocabularyAnnotation(valueAnnotation);

            return model;
        }
        public static IEdmModel IsTypeResultTrueEvaluationModel()
        {
            var model = new EdmModel();

            var booleanFlag = new EdmComplexType("NS", "BooleanFlag");
            var flag = booleanFlag.AddStructuralProperty("Flag", EdmCoreModel.Instance.GetBoolean(true));
            model.AddElement(booleanFlag);

            var booleanFlagTerm = new EdmTerm("NS", "BooleanFlagTerm", new EdmComplexTypeReference(booleanFlag, true));
            model.AddElement(booleanFlagTerm);

            var valueAnnotation = new EdmAnnotation(
                booleanFlag,
                booleanFlagTerm,
                new EdmRecordExpression(
                    new EdmPropertyConstructor(flag.Name, new EdmIsTypeExpression(new EdmStringConstant("foo"), EdmCoreModel.Instance.GetString(true)))));
            valueAnnotation.SetSerializationLocation(model, EdmVocabularyAnnotationSerializationLocation.OutOfLine);
            model.AddVocabularyAnnotation(valueAnnotation);

            return model;
        }
        public static EdmModel ValueTermWithAnnotationModel()
        {
            EdmModel model = new EdmModel();

            EdmTerm note = new EdmTerm("DefaultNamespace", "Note", EdmCoreModel.Instance.GetString(true));
            model.AddElement(note);

            var annotationElement =
                new XElement("{http://foo}Annotation", 1);
            var annotation = new EdmStringConstant(EdmCoreModel.Instance.GetString(false), annotationElement.ToString());
            annotation.SetIsSerializedAsElement(model, true);
            model.SetAnnotationValue(note, "http://foo", "Annotation", annotation);

            return model;
        }
        public static EdmModel OutOfLineValueAnnotationWithAnnotationModel()
        {
            EdmModel model = new EdmModel();

            EdmComplexType simpleType = new EdmComplexType("DefaultNamespace", "SimpleType");
            simpleType.AddStructuralProperty("Data", EdmCoreModel.Instance.GetString(true));
            model.AddElement(simpleType);

            EdmTerm note = new EdmTerm("DefaultNamespace", "Note", EdmCoreModel.Instance.GetString(true));
            model.AddElement(note);
            
            EdmAnnotation valueAnnotation = new EdmAnnotation(
                simpleType,
                note,
                new EdmStringConstant("ComplexTypeNote"));
            valueAnnotation.SetSerializationLocation(model, EdmVocabularyAnnotationSerializationLocation.OutOfLine);
            model.AddVocabularyAnnotation(valueAnnotation);
            
            XElement annotationElement =
                new XElement("{http://foo}Annotation", "1");
            var annotation = new EdmStringConstant(EdmCoreModel.Instance.GetString(false), annotationElement.ToString());
            annotation.SetIsSerializedAsElement(model, true);
            model.SetAnnotationValue(valueAnnotation, "http://foo", "Annotation", annotation);

            return model;
        }
        public static IEdmModel AllInterfaceCriticalModel()
        {
            var model = new EdmModel();
            var valueTerm = new EdmTerm("DefaultNamespace", "Note", EdmCoreModel.Instance.GetString(true));
            model.AddElement(valueTerm);

            var badString = new CustomStringConstant("foo", EdmExpressionKind.None, EdmValueKind.Integer);

            var valueAnnotation = new EdmAnnotation(
                valueTerm,
                valueTerm,
                badString);
            model.AddVocabularyAnnotation(valueAnnotation);

            var mutableValueAnnotationueAnnotation = new MutableValueAnnotation()
            {
                Target = valueTerm
            };

            model.AddVocabularyAnnotation(mutableValueAnnotationueAnnotation);
            
            var customEntity = new CustomEntityType(new List<IEdmProperty>() { null });
            model.AddElement(customEntity);

            var entity = new EdmEntityType("DefaultNamespace", "bar");
            var entity2 = new EdmEntityType("DefaultNamespace", "bar2");
            var navProperty = new StubEdmNavigationProperty("Nav")
            {
                DeclaringType = entity,
                Type = new EdmEntityTypeReference(entity2, false)
            };

            navProperty.Partner = navProperty;
            entity.AddProperty(navProperty);
            model.AddElement(entity);
            model.AddElement(entity2);

            return model;
        }
        public static IEdmModel InterfaceCriticalKindValueMismatchOnlyUsingStringTypeReferenceModel()
        {
            var model = new EdmModel();

            var badTypeRef = new EdmStringTypeReference(EdmCoreModel.Instance.GetPrimitiveType(EdmPrimitiveTypeKind.Double), true);
            var valueTerm = new EdmTerm("NS", "Note", badTypeRef);
            model.AddElement(valueTerm);

            return model;
        }
        public static IEdmModel IsTypeResultFalseEvaluationModel()
        {
            var model = new EdmModel();

            var booleanFlag = new EdmTerm("NS", "BooleanFlag", EdmCoreModel.Instance.GetBoolean(true));
            model.AddElement(booleanFlag);

            var valueAnnotation = new EdmAnnotation(
                booleanFlag,
                booleanFlag,
                new EdmIsTypeExpression(new EdmIntegerConstant(32), EdmCoreModel.Instance.GetString(true)));
            valueAnnotation.SetSerializationLocation(model, EdmVocabularyAnnotationSerializationLocation.OutOfLine);
            model.AddVocabularyAnnotation(valueAnnotation);

            return model;
        }
Example #26
0
        private static void CustomTermDemo()
        {
            Console.WriteLine("CustomTermDemo");

            var model = new EdmModel();
            var term = new EdmTerm("ns", "ErrorCodes",
                new EdmCollectionTypeReference(new EdmCollectionType(EdmCoreModel.Instance.GetString(false))));
            model.AddElement(term);
            var entity1 = new EdmEntityType("ns", "entity1");
            entity1.AddKeys(entity1.AddStructuralProperty("id", EdmPrimitiveTypeKind.Guid));
            model.AddElement(entity1);
            var container = new EdmEntityContainer("ns", "default");
            model.AddElement(container);
            var e1 = container.AddSingleton("E1", entity1);

            var annotation = new EdmAnnotation(e1, term,
                new EdmCollectionExpression(
                    new EdmStringConstant("Entity Not Found"),
                    new EdmStringConstant("Deleting link failed")));

            model.AddVocabularyAnnotation(annotation);

            ShowModel(model);
        }
        public static IEdmModel ValueAnnotationInvalidTypeReferenceDurationConstantModel()
        {
            var model = new EdmModel();
            var valueTerm = new EdmTerm("DefaultNamespace", "Note", EdmCoreModel.Instance.GetDuration(true));
            model.AddElement(valueTerm);

            var valueAnnotation = new EdmAnnotation(
                valueTerm,
                valueTerm,
                new EdmDurationConstant(EdmCoreModel.Instance.GetDateTimeOffset(false), new TimeSpan(1, 99, 99, 99, 999)));

            valueAnnotation.SetSerializationLocation(model, EdmVocabularyAnnotationSerializationLocation.OutOfLine);
            model.AddVocabularyAnnotation(valueAnnotation);

            return model;
        }
        public static IEdmModel InterfaceCriticalPropertyValueMustNotBeNullUsingEntityReferenceTypeModel()
        {
            var model = new EdmModel();
            var badTypeRef = new EdmEntityReferenceTypeReference(new CustomEntityReferenceType(null), true);
            var valueTerm = new EdmTerm("NS", "Note", badTypeRef);
            model.AddElement(valueTerm);

            return model;
        }
        public void Term_Definition_Collection()
        {
            this.SetupModels();

            var definitionModel = new EdmModel();
            var collectionOfInt16 = new EdmCollectionTypeReference(new EdmCollectionType(EdmCoreModel.Instance.GetInt16(false /*isNullable*/)));
            var valueTermInt16 = new EdmTerm("NS2", "CollectionOfInt16", collectionOfInt16);
            definitionModel.AddElement(valueTermInt16);

            var collectionOfPerson = new EdmCollectionTypeReference(new EdmCollectionType(new EdmEntityTypeReference(this.baseModel.FindEntityType("NS1.Person"), true)));
            var valueTermPerson = new EdmTerm("NS2", "CollectionOfPerson", collectionOfPerson);
            definitionModel.AddElement(valueTermPerson);

            string expectedCsdl =
@"<Schema Namespace=""NS2"" xmlns=""http://docs.oasis-open.org/odata/ns/edm"">
    <Term Name=""CollectionOfInt16"" Type=""Collection(Edm.Int16)"" Nullable=""false"" />
    <Term Name=""CollectionOfPerson"" Type=""Collection(NS1.Person)"" />
</Schema>";
            this.SerializeAndVerifyAgainst(definitionModel, expectedCsdl);
        }
        public static IEdmModel InterfaceCriticalPropertyValueMustNotBeNullUsingBinaryValueModel()
        {
            var model = new EdmModel();

            var valueTerm = new EdmTerm("NS", "Note", EdmCoreModel.Instance.GetBinary(true));
            model.AddElement(valueTerm);

            var badValue = new CustomBinaryConstant(null);
            var valueAnnotation = new EdmAnnotation(
                valueTerm,
                valueTerm,
                badValue);
            model.AddVocabularyAnnotation(valueAnnotation);

            return model;
        }