public void AnnotatableTargetOnEntitySetReturnsCorrectPropertyValue() { // Arrange const string searchAnnotation = @" <Annotations Target=""NS.Default/Calendars"" > <Annotation Term=""Org.OData.Capabilities.V1.SearchRestrictions""> <Record> <PropertyValue Property=""Searchable"" Bool=""false"" /> <PropertyValue Property=""UnsupportedExpressions""> <EnumMember>Org.OData.Capabilities.V1.SearchExpressions/group</EnumMember> </PropertyValue > </Record> </Annotation> </Annotations>"; IEdmModel model = CapabilitiesModelHelper.GetModelOutline(searchAnnotation); IEdmEntitySet calendars = model.EntityContainer.FindEntitySet("Calendars"); // Act SearchRestrictionsType search = model.GetRecord <SearchRestrictionsType>(calendars); // Assert Assert.NotNull(search); Assert.False(search.Searchable); Assert.NotNull(search.UnsupportedExpressions); Assert.Equal(SearchExpressions.group, search.UnsupportedExpressions.Value); Assert.False(search.IsUnsupportedExpressions(SearchExpressions.AND)); Assert.True(search.IsUnsupportedExpressions(SearchExpressions.group)); }
public void AnnotatableTargetOnEntityTypeReturnsCorrectPropertyValue() { // Arrange const string searchAnnotation = @" <Annotations Target=""NS.Calendar"" > <Annotation Term=""Org.OData.Capabilities.V1.SearchRestrictions""> <Record> <PropertyValue Property=""Searchable"" Bool=""false"" /> <PropertyValue Property=""UnsupportedExpressions""> <EnumMember>Org.OData.Capabilities.V1.SearchExpressions/phrase</EnumMember> </PropertyValue > </Record> </Annotation> </Annotations>"; IEdmModel model = CapabilitiesModelHelper.GetModelOutline(searchAnnotation); IEdmEntityType calendar = model.SchemaElements.OfType <IEdmEntityType>().First(c => c.Name == "Calendar"); // Act SearchRestrictionsType search = model.GetRecord <SearchRestrictionsType>(calendar); // Assert Assert.NotNull(search); Assert.False(search.Searchable); Assert.NotNull(search.UnsupportedExpressions); Assert.Equal(SearchExpressions.phrase, search.UnsupportedExpressions.Value); Assert.False(search.IsUnsupportedExpressions(SearchExpressions.AND)); Assert.True(search.IsUnsupportedExpressions(SearchExpressions.phrase)); }