private static IEdmModel GetEdmModel(string template, EdmVocabularyAnnotationSerializationLocation location) { string countAnnotation = @" <Annotation Term=""Org.OData.Capabilities.V1.FilterRestrictions"" > <Record> <PropertyValue Property=""Filterable"" Bool=""false"" /> <PropertyValue Property=""RequiresFilter"" Bool=""false"" /> <PropertyValue Property=""RequiredProperties"" > <Collection> <PropertyPath>Id</PropertyPath> </Collection> </PropertyValue> <PropertyValue Property=""NonFilterableProperties"" > <Collection> <PropertyPath>Emails</PropertyPath> </Collection> </PropertyValue> </Record> </Annotation>"; if (location == EdmVocabularyAnnotationSerializationLocation.OutOfLine) { countAnnotation = string.Format(template, countAnnotation); return(CapabilitiesModelHelper.GetEdmModelOutline(countAnnotation)); } else { return(CapabilitiesModelHelper.GetEdmModelTypeInline(countAnnotation)); } }
private static IEdmModel GetEdmModel(string template, EdmVocabularyAnnotationSerializationLocation location, bool navInLine = false) { string countAnnotation = @" <Annotation Term=""Org.OData.Capabilities.V1.SortRestrictions"" > <Record> <PropertyValue Property=""Sortable"" Bool=""false"" /> <PropertyValue Property=""AscendingOnlyProperties"" > <Collection> <PropertyPath>abc</PropertyPath> </Collection> </PropertyValue> <PropertyValue Property=""DescendingOnlyProperties"" > <Collection> <PropertyPath>rst</PropertyPath> </Collection> </PropertyValue> <PropertyValue Property=""NonSortableProperties"" > <Collection> <PropertyPath>Emails</PropertyPath> </Collection> </PropertyValue> </Record> </Annotation>"; if (location == EdmVocabularyAnnotationSerializationLocation.OutOfLine) { countAnnotation = string.Format(template, countAnnotation); return(CapabilitiesModelHelper.GetEdmModelOutline(countAnnotation)); } else { return(CapabilitiesModelHelper.GetEdmModelTypeInline(countAnnotation)); } }
private static IEdmModel GetEdmModel(string template, EdmVocabularyAnnotationSerializationLocation location) { string countAnnotation = @" <Annotation Term=""Org.OData.Capabilities.V1.UpdateRestrictions"" > <Record> <PropertyValue Property=""Updatable"" Bool=""false"" /> <PropertyValue Property=""NonUpdatableNavigationProperties"" > <Collection> <NavigationPropertyPath>abc</NavigationPropertyPath> <NavigationPropertyPath>RelatedEvents</NavigationPropertyPath> </Collection> </PropertyValue> </Record> </Annotation>"; if (location == EdmVocabularyAnnotationSerializationLocation.OutOfLine) { countAnnotation = string.Format(template, countAnnotation); return(CapabilitiesModelHelper.GetEdmModelOutline(countAnnotation)); } else { return(CapabilitiesModelHelper.GetEdmModelTypeInline(countAnnotation)); } }
public void TargetOnEntitySetReturnsCorrectNavigationRestrictionsValue(EdmVocabularyAnnotationSerializationLocation location) { // Arrange const string outOfLineTemplate = @" <Annotations Target=""NS.Default/Calendars""> {0} </Annotations>"; string navigationAnnotation = @" <Annotation Term=""Org.OData.Capabilities.V1.NavigationRestrictions"" > <Record> <PropertyValue Property=""Navigability"" > <EnumMember>Org.OData.Capabilities.V1.NavigationType/Recursive</EnumMember> </PropertyValue> <PropertyValue Property=""RestrictedProperties"" > <Collection> <Record> <PropertyValue Property=""Navigability"" > <EnumMember>Org.OData.Capabilities.V1.NavigationType/Single</EnumMember> </PropertyValue> <PropertyValue Property=""NavigationProperty"" NavigationPropertyPath=""abc"" /> </Record> <Record> <PropertyValue Property=""Navigability"" > <EnumMember>Org.OData.Capabilities.V1.NavigationType/None</EnumMember> </PropertyValue> <PropertyValue Property=""NavigationProperty"" NavigationPropertyPath=""xyz"" /> </Record> </Collection> </PropertyValue> </Record> </Annotation>"; IEdmModel model; if (location == EdmVocabularyAnnotationSerializationLocation.OutOfLine) { navigationAnnotation = string.Format(outOfLineTemplate, navigationAnnotation); model = CapabilitiesModelHelper.GetEdmModelOutline(navigationAnnotation); } else { model = CapabilitiesModelHelper.GetEdmModelTypeInline(navigationAnnotation); } IEdmEntitySet calendars = model.EntityContainer.FindEntitySet("Calendars"); // Act NavigationRestrictions navigation = new NavigationRestrictions(); bool result = navigation.Load(model, calendars); // Assert Assert.True(result); VerifyNavigationRestrictions(navigation); NavigationPropertyRestriction navRestriction = navigation.RestrictedProperties.Last(); Assert.NotNull(navRestriction.Navigability); Assert.Equal(NavigationType.None, navRestriction.Navigability.Value); Assert.Equal("xyz", navRestriction.NavigationProperty); Assert.True(navigation.IsRestrictedProperty("xyz")); }
private static IEdmModel GetEdmModel(string template, EdmVocabularyAnnotationSerializationLocation location) { string countAnnotation = @"<Annotation Term=""Org.OData.Capabilities.V1.SkipSupported"" Bool=""false"" />"; if (location == EdmVocabularyAnnotationSerializationLocation.OutOfLine) { countAnnotation = string.Format(template, countAnnotation); return(CapabilitiesModelHelper.GetEdmModelOutline(countAnnotation)); } else { return(CapabilitiesModelHelper.GetEdmModelTypeInline(countAnnotation)); } }