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));
        }
        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));
        }
示例#3
0
        public void InitializeDeepInsertSupportTypeWorksWithCsdl()
        {
            // Arrange
            string annotation = @"
                <Annotation Term=""Org.OData.Capabilities.V1.DeepInsertSupport"" >
                  <Record>
                    <PropertyValue Property=""Supported"" Bool=""false"" />
                    <PropertyValue Property=""ContentIDSupported"" Bool=""true"" />
                  </Record>
                </Annotation>";

            IEdmModel model = CapabilitiesModelHelper.GetEdmModelSetInline(annotation);

            Assert.NotNull(model); // guard

            IEdmEntitySet calendars = model.EntityContainer.FindEntitySet("Calendars");

            Assert.NotNull(calendars); // guard

            // Act
            DeepInsertSupportType deepInsert = model.GetRecord <DeepInsertSupportType>(calendars);

            // Assert
            VerifyDeepInsertSupportType(deepInsert);
        }
        private static IEdmModel GetEdmModel(string template, EdmVocabularyAnnotationSerializationLocation location)
        {
            string countAnnotation = @"
                <Annotation Term=""Org.OData.Capabilities.V1.ExpandRestrictions"" >
                  <Record>
                    <PropertyValue Property=""Expandable"" Bool=""false"" />
                    <PropertyValue Property=""MaxLevels"" Int=""42"" />
                    <PropertyValue Property=""NonExpandableProperties"" >
                      <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));
            }
        }
        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.InsertRestrictions"" >
                  <Record>
                    <PropertyValue Property=""Insertable"" Bool=""false"" />
                    <PropertyValue Property=""NonInsertableProperties"" >
                      <Collection>
                        <PropertyPath>abc/xyz</PropertyPath>
                      </Collection>
                    </PropertyValue>
                    <PropertyValue Property=""NonInsertableNavigationProperties"" >
                      <Collection>
                        <NavigationPropertyPath>abc</NavigationPropertyPath>
                        <NavigationPropertyPath>RelatedEvents</NavigationPropertyPath>
                      </Collection>
                    </PropertyValue>
                    <PropertyValue Property=""MaxLevels"" Int=""8"" />
                    <PropertyValue Property=""CustomQueryOptions"" >
                      <Collection>
                        <Record>
                          <PropertyValue Property=""Name"" String=""primitive name"" />
                          <PropertyValue Property=""Description"" String=""primitive desc"" />
                          <PropertyValue Property=""DocumentationURL"" String=""http://any3"" />
                          <PropertyValue Property=""Required"" Bool=""true"" />
                          <PropertyValue Property=""ExampleValues"">
                            <Collection>
                              <Record>
                                <PropertyValue Property=""Description"" String=""example desc"" />
                                <PropertyValue Property=""Value"" String=""example value"" />
                              </Record>
                            </Collection>
                          </PropertyValue>
                        </Record>
                      </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 annotation = @"
                <Annotation Term=""Org.OData.Capabilities.V1.DeleteRestrictions"" >
                  <Record>
                    <PropertyValue Property=""Deletable"" Bool=""false"" />
                    <PropertyValue Property=""NonDeletableNavigationProperties"" >
                      <Collection>
                        <NavigationPropertyPath>abc</NavigationPropertyPath>
                        <NavigationPropertyPath>RelatedEvents</NavigationPropertyPath>
                      </Collection>
                    </PropertyValue>
                    <PropertyValue Property=""MaxLevels"" Int=""42"" />
                    <PropertyValue Property=""Permissions"">
                      <Collection>
                        <Record>
                          <PropertyValue Property=""SchemeName"" String=""schemeName"" />
                        </Record>
                      </Collection>
                    </PropertyValue>
                    <PropertyValue Property=""CustomQueryOptions"" >
                      <Collection>
                        <Record>
                          <PropertyValue Property=""Name"" String=""odata-debug"" />
                          <PropertyValue Property=""DocumentationURL"" String=""https://debug.html"" />
                      </Record>
                      </Collection>
                    </PropertyValue>
                  </Record>
                </Annotation>";

            if (location == EdmVocabularyAnnotationSerializationLocation.OutOfLine)
            {
                annotation = string.Format(template, annotation);
                return(CapabilitiesModelHelper.GetEdmModelOutline(annotation));
            }
            else
            {
                return(CapabilitiesModelHelper.GetEdmModelTypeInline(annotation));
            }
        }
        private static IEdmModel GetEdmModel(string template, EdmVocabularyAnnotationSerializationLocation location)
        {
            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"" />
                          <PropertyValue Property=""SkipSupported"" Bool=""false"" />
                         </Record>
                         <Record>
                          <PropertyValue Property=""Navigability"" >
                            <EnumMember>Org.OData.Capabilities.V1.NavigationType/None</EnumMember>
                          </PropertyValue>
                          <PropertyValue Property=""NavigationProperty"" NavigationPropertyPath=""xyz"" />
                          <PropertyValue Property=""OptimisticConcurrencyControl"" Bool=""true"" />
                         </Record>
                       </Collection>
                     </PropertyValue>
                   </Record>
                 </Annotation>";

            if (location == EdmVocabularyAnnotationSerializationLocation.OutOfLine)
            {
                navigationAnnotation = string.Format(template, navigationAnnotation);
                return(CapabilitiesModelHelper.GetEdmModelOutline(navigationAnnotation));
            }
            else
            {
                return(CapabilitiesModelHelper.GetEdmModelTypeInline(navigationAnnotation));
            }
        }
        private static IEdmModel GetEdmModel(string template, EdmVocabularyAnnotationSerializationLocation location)
        {
            string countAnnotation = @"
                <Annotation Term=""Org.OData.Capabilities.V1.ReadRestrictions"" >
                  <Record>
                    <PropertyValue Property=""Readable"" Bool=""false"" />
                    <PropertyValue Property=""CustomQueryOptions"" >
                      <Collection>
                        <Record>
                          <PropertyValue Property=""Name"" String=""root query name"" />
                        </Record>
                      </Collection>
                    </PropertyValue>
                    <PropertyValue Property=""ReadByKeyRestrictions"">
                      <Record>
                        <PropertyValue Property=""Readable"" Bool=""true"" />
                        <PropertyValue Property=""CustomHeaders"" >
                          <Collection>
                            <Record>
                              <PropertyValue Property=""Name"" String=""by key head name"" />
                            </Record>
                          </Collection>
                        </PropertyValue>
                      </Record>
                    </PropertyValue>
                  </Record>
                </Annotation>";

            if (location == EdmVocabularyAnnotationSerializationLocation.OutOfLine)
            {
                countAnnotation = string.Format(template, countAnnotation);
                return(CapabilitiesModelHelper.GetEdmModelOutline(countAnnotation));
            }
            else
            {
                return(CapabilitiesModelHelper.GetEdmModelTypeInline(countAnnotation));
            }
        }
示例#10
0
        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=""MaxLevels"" Int=""42"" />
                    <PropertyValue Property=""RequiredProperties"" >
                      <Collection>
                        <PropertyPath>Id</PropertyPath>
                      </Collection>
                    </PropertyValue>
                    <PropertyValue Property=""NonFilterableProperties"" >
                      <Collection>
                        <PropertyPath>Emails</PropertyPath>
                      </Collection>
                    </PropertyValue>
                    <PropertyValue Property=""FilterExpressionRestrictions"" >
                      <Collection>
                        <Record>
                          <PropertyValue Property=""Property"" PropertyPath=""RelatedProperty"" />
                        </Record>
                      </Collection>
                    </PropertyValue>
                  </Record>
                </Annotation>";

            if (location == EdmVocabularyAnnotationSerializationLocation.OutOfLine)
            {
                countAnnotation = string.Format(template, countAnnotation);
                return(CapabilitiesModelHelper.GetEdmModelOutline(countAnnotation));
            }
            else
            {
                return(CapabilitiesModelHelper.GetEdmModelTypeInline(countAnnotation));
            }
        }
        public void TargetWithUnknownEnumMemberDoesnotReturnsNavigationRestrictionsValue()
        {
            // Arrange
            const string navigationAnnotation = @"
              <Annotations Target=""NS.Calendar"" >
                  <Annotation Term=""Org.OData.Capabilities.V1.NavigationRestrictions"">
                    <Record>
                      <PropertyValue Property=""Navigability"" >
                        <EnumMember>Org.OData.Capabilities.V1.NavigationType/Unknown</EnumMember>
                    </PropertyValue>
                    </Record>
                  </Annotation>
              </Annotations>";

            IEdmModel      model    = CapabilitiesModelHelper.GetEdmModelOutline(navigationAnnotation);
            IEdmEntityType calendar = model.SchemaElements.OfType <IEdmEntityType>().First(c => c.Name == "Calendar");

            // Act
            NavigationRestrictionsType navigation = model.GetRecord <NavigationRestrictionsType>(calendar);

            // Assert
            Assert.Null(navigation.Navigability);
            Assert.Null(navigation.RestrictedProperties);
        }
示例#12
0
        public void InitializeCountRestrictionsWorksWithCsdl()
        {
            // Arrange
            string countAnnotation = @"
                <Annotation Term=""Org.OData.Capabilities.V1.CountRestrictions"" >
                  <Record>
                    <PropertyValue Property=""Countable"" Bool=""false"" />
                    <PropertyValue Property=""NonCountableProperties"">
                      <Collection>
                        <PropertyPath>Emails</PropertyPath>
                        <PropertyPath>mij</PropertyPath>
                      </Collection>
                    </PropertyValue>
                    <PropertyValue Property=""NonCountableNavigationProperties"" >
                      <Collection>
                        <NavigationPropertyPath>RelatedEvents</NavigationPropertyPath>
                        <NavigationPropertyPath>abc</NavigationPropertyPath>
                      </Collection>
                    </PropertyValue>
                  </Record>
                </Annotation>";

            IEdmModel model = CapabilitiesModelHelper.GetEdmModelSetInline(countAnnotation);

            Assert.NotNull(model); // guard

            IEdmEntitySet calendars = model.EntityContainer.FindEntitySet("Calendars");

            Assert.NotNull(calendars); // guard

            // Act
            CountRestrictionsType count = model.GetRecord <CountRestrictionsType>(calendars);

            // Assert
            VerifyCountRestrictions(count);
        }
        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>
                    <PropertyValue Property=""MaxLevels"" Int=""8"" />
                    <PropertyValue Property=""Permissions"">
                      <Collection>
                        <Record Type=""Org.OData.Capabilities.V1.PermissionType"">
                          <PropertyValue Property=""SchemeName"" String=""authorizationName"" />
                          <PropertyValue Property=""Scopes"">
                            <Collection>
                              <Record Type=""Org.OData.Capabilities.V1.ScopeType"">
                                <PropertyValue Property=""Scope"" String=""scopeName1"" />
                                <PropertyValue Property=""RestrictedProperties"" String=""p1,p2"" />
                              </Record>
                              <Record Type=""Org.OData.Capabilities.V1.ScopeType"">
                                <PropertyValue Property=""Scope"" String=""scopeName2"" />
                                <PropertyValue Property=""RestrictedProperties"" String=""p3,p4"" />
                              </Record>
                            </Collection>
                          </PropertyValue>
                        </Record>
                      </Collection>
                    </PropertyValue>
                    <PropertyValue Property=""QueryOptions"">
                      <Record>
                        <PropertyValue Property=""ExpandSupported"" Bool=""true"" />
                        <PropertyValue Property=""SelectSupported"" Bool=""true"" />
                        <PropertyValue Property=""ComputeSupported"" Bool=""true"" />
                        <PropertyValue Property=""FilterSupported"" Bool=""true"" />
                        <PropertyValue Property=""SearchSupported"" Bool=""true"" />
                        <PropertyValue Property=""SortSupported"" Bool=""false"" />
                        <PropertyValue Property=""SortSupported"" Bool=""false"" />
                      </Record>
                    </PropertyValue>
                    <PropertyValue Property=""CustomHeaders"">
                      <Collection>
                        <Record>
                          <PropertyValue Property=""Name"" String=""HeadName1"" />
                          <PropertyValue Property=""Description"" String=""Description1"" />
                          <PropertyValue Property=""ComputeSupported"" String=""http://any1"" />
                          <PropertyValue Property=""Required"" Bool=""true"" />
                          <PropertyValue Property=""ExampleValues"">
                            <Collection>
                              <Record>
                                <PropertyValue Property=""Description"" String=""Description23"" />
                                <PropertyValue Property=""Value"" String=""value1"" />
                              </Record>
                            </Collection>
                          </PropertyValue>
                        </Record>
                        <Record>
                          <PropertyValue Property=""Name"" String=""HeadName2"" />
                          <PropertyValue Property=""Description"" String=""Description2"" />
                          <PropertyValue Property=""ComputeSupported"" String=""http://any2"" />
                          <PropertyValue Property=""Required"" Bool=""false"" />
                          <PropertyValue Property=""ExampleValues"">
                            <Collection>
                              <Record>
                                <PropertyValue Property=""Description"" String=""Description23"" />
                                <PropertyValue Property=""Value"" String=""value2"" />
                              </Record>
                            </Collection>
                          </PropertyValue>
                        </Record>
                      </Collection>
                    </PropertyValue>
                    <PropertyValue Property=""CustomQueryOptions"">
                      <Collection>
                        <Record>
                          <PropertyValue Property=""Name"" String=""HeadName1"" />
                          <PropertyValue Property=""Description"" String=""Description1"" />
                          <PropertyValue Property=""ComputeSupported"" String=""http://any3"" />
                          <PropertyValue Property=""Required"" Bool=""true"" />
                          <PropertyValue Property=""ExampleValues"">
                            <Collection>
                              <Record>
                                <PropertyValue Property=""Description"" String=""Description23"" />
                                <PropertyValue Property=""Value"" String=""value3"" />
                              </Record>
                            </Collection>
                          </PropertyValue>
                        </Record>
                        <Record>
                          <PropertyValue Property=""Name"" String=""HeadName2"" />
                          <PropertyValue Property=""Description"" String=""Description2"" />
                          <PropertyValue Property=""ComputeSupported"" String=""http://any4"" />
                          <PropertyValue Property=""Required"" Bool=""false"" />
                          <PropertyValue Property=""ExampleValues"">
                            <Collection>
                              <Record>
                                <PropertyValue Property=""Description"" String=""Description23"" />
                                <PropertyValue Property=""Value"" String=""value4"" />
                              </Record>
                            </Collection>
                          </PropertyValue>
                        </Record>
                      </Collection>
                    </PropertyValue>
                  </Record>
                </Annotation>";

            if (location == EdmVocabularyAnnotationSerializationLocation.OutOfLine)
            {
                countAnnotation = string.Format(template, countAnnotation);
                return(CapabilitiesModelHelper.GetEdmModelOutline(countAnnotation));
            }
            else
            {
                return(CapabilitiesModelHelper.GetEdmModelTypeInline(countAnnotation));
            }
        }