コード例 #1
0
        public void AddAnnotationWithNoTarget()
        {
            var edmModel   = new EdmModel();
            var annotation = new MutableVocabularyAnnotation();

            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 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");
        }
コード例 #3
0
        public void ValidateDefaultAnnotation()
        {
            EdmModel model = VocabularyTestModelBuilder.SimpleModel();

            var annotation = new MutableVocabularyAnnotation();

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