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

            this.VerifyThrowsException(typeof(InvalidOperationException), () => edmModel.AddVocabularyAnnotation(annotation));
        }
Пример #2
0
        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 MutableValueAnnotation()
            {
                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.TryWriteCsdl(xmlWriter, out serializationErrors);
            xmlWriter.Close();

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

            var valueAnnotation = new MutableValueAnnotation();

            this.VerifyThrowsException(typeof(InvalidOperationException), () => model.AddVocabularyAnnotation(valueAnnotation));
        }
 public void AddAnnotationWithNoTarget()
 {
     var edmModel = new EdmModel();
     var annotation = new MutableValueAnnotation();
     this.VerifyThrowsException(typeof(InvalidOperationException), () => edmModel.AddVocabularyAnnotation(annotation));
 }