public void AddAnnotationWithNoTarget()
        {
            var edmModel   = new EdmModel();
            var annotation = new MutableVocabularyAnnotation();

            this.VerifyThrowsException(typeof(InvalidOperationException), () => edmModel.AddVocabularyAnnotation(annotation));
        }
        public void ConstructibleVocabularySerializingAnnotationsWithNoTerm()
        {
            var stockModel = new EdmModel();
            var customer   = new EdmEntityType("NS1", "Customer");
            var customerId = customer.AddStructuralProperty("CustomerID", EdmCoreModel.Instance.GetString(false));

            customer.AddKeys(customerId);
            stockModel.AddElement(customer);

            var annotation = new MutableVocabularyAnnotation()
            {
                Target = customer,
                Value  = new EdmStringConstant("Hello world2!"),
            };

            stockModel.AddVocabularyAnnotation(annotation);

            var stringWriter = new StringWriter();
            var xmlWriter    = XmlWriter.Create(stringWriter, new XmlWriterSettings()
            {
                Indent = true
            });
            IEnumerable <EdmError> serializationErrors;

            stockModel.TryWriteSchema(xmlWriter, out serializationErrors);
            xmlWriter.Close();

            Assert.AreEqual(1, serializationErrors.Count(), "Error on serialization");
        }
Ejemplo n.º 3
0
        public void ValidateDefaultAnnotation()
        {
            EdmModel model = VocabularyTestModelBuilder.SimpleModel();

            var annotation = new MutableVocabularyAnnotation();

            this.VerifyThrowsException(typeof(InvalidOperationException), () => model.AddVocabularyAnnotation(annotation));
        }