public void Annotations_On_NonEntityType_Should_Be_Generated() { var model = new StubEdmModel(); var entity = new StubEdmEntityType("NS1", "Person"); var vt = new StubValueTerm("NS1", "MyValueTerm") { Type = EdmCoreModel.Instance.GetString(true) }; var va1 = new StubValueAnnotation() { Term = vt, Value = new StubStringConstantExpression("Great!!!") }; entity.AddVocabularyAnnotation(va1); model.Add(entity); var entitySet = new StubEdmEntitySet("personSet", null); var va2 = new StubValueAnnotation() { Term = vt, Value = new StubStringConstantExpression("Aha!!!") }; entitySet.AddVocabularyAnnotation(va2); var container = new StubEdmEntityContainer("NS1", "myContainer") { entitySet }; var va3 = new StubValueAnnotation() { Term = vt, Value = new StubStringConstantExpression("Huh??") }; container.AddVocabularyAnnotation(va3); model.Add(container); XElement result = this.generator.GenerateApplicationCsdl(EdmVersion.V40, model); string expected = @" <Schema Namespace='Application.NS1' xmlns='http://docs.oasis-open.org/odata/ns/edm'> <Annotations Target='NS1.Person'> <Annotation Term='NS1.MyValueTerm' String='Great!!!' /> </Annotations> <Annotations Target='NS1.myContainer'> <Annotation Term='NS1.MyValueTerm' String='Huh??' /> </Annotations> <Annotations Target='NS1.myContainer/personSet'> <Annotation Term='NS1.MyValueTerm' String='Aha!!!' /> </Annotations> </Schema>"; AssertHelper.AssertXElementEquals(expected, result); }
public static IEdmModel SimpleValueAnnotationOnContainerAndEntitySet() { StubEdmModel model = new StubEdmModel(); CreateVocabularyDefinitions(model); var person = new StubEdmEntityType("NS1", "Person"); var container = new StubEdmEntityContainer("NS1", "Container"); var personSet = new StubEdmEntitySet("PersonSet", container) { Type = new EdmCollectionType(new EdmEntityTypeReference(person, false)) }; container.Add(personSet); model.Add(container); model.Add(person); var titleValueTerm = model.FindValueTerm("NS1.Title"); var titleValueAnnotation = new StubValueAnnotation() { Term = titleValueTerm, Value = new StubStringConstantExpression("Sir") }; container.AddVocabularyAnnotation(titleValueAnnotation); personSet.AddVocabularyAnnotation(titleValueAnnotation); return model; }
public static IEdmModel MultipleValueAnnotations() { StubEdmModel model = new StubEdmModel(); CreateVocabularyDefinitions(model); var person = new StubEdmEntityType("NS1", "Person") { new StubEdmStructuralProperty("Id") { Type = EdmCoreModel.Instance.GetInt16(false) }, new StubEdmStructuralProperty("FirstName") { Type = EdmCoreModel.Instance.GetString(false) }, new StubEdmStructuralProperty("LastName") { Type = EdmCoreModel.Instance.GetString(false) }, }; var titleValueTerm = model.FindValueTerm("NS1.Title"); var titleValueAnnotation = new StubValueAnnotation() { Term = titleValueTerm, Value = new StubStringConstantExpression("Sir") }; person.AddVocabularyAnnotation(titleValueAnnotation); var displaySizeValueTerm = model.FindValueTerm("NS1.DisplaySize"); var displaySizeValueAnnotation = new StubValueAnnotation() { Term = displaySizeValueTerm, Value = new StubStringConstantExpression("1024") }; person.AddVocabularyAnnotation(displaySizeValueAnnotation); model.Add(person); var container = new StubEdmEntityContainer("NS1", "Container"); var personSet = new StubEdmEntitySet("PersonSet", container) { Type = new EdmCollectionType(new EdmEntityTypeReference(person, false)) }; personSet.AddVocabularyAnnotation(titleValueAnnotation); container.Add(personSet); model.Add(container); return model; }