Ejemplo n.º 1
0
        public void TargetOnEntitySetReturnsCorrectTopSupportedValue(EdmVocabularyAnnotationSerializationLocation location)
        {
            // Arrange
            const string template = @"
                <Annotations Target=""NS.Default/Calendars"">
                  {0}
                </Annotations>";

            IEdmModel model = GetEdmModel(template, location);

            Assert.NotNull(model); // guard

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

            Assert.NotNull(calendars); // guard

            // Act
            TopSupported top    = new TopSupported();
            bool         result = top.Load(model, calendars);

            // Assert
            Assert.True(result);
            Assert.False(top.IsSupported);
            Assert.NotNull(top.Supported);
            Assert.False(top.Supported.Value);
        }
Ejemplo n.º 2
0
        public void TargetOnEntityTypeReturnsCorrectTopSupportedValue(EdmVocabularyAnnotationSerializationLocation location)
        {
            // Arrange
            const string template = @"
                <Annotations Target=""NS.Calendar"">
                  {0}
                </Annotations>";

            IEdmModel model = GetEdmModel(template, location);

            Assert.NotNull(model); // guard

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

            Assert.NotNull(calendar); // guard

            // Act
            TopSupported top    = new TopSupported();
            bool         result = top.Load(model, calendar);

            // Assert
            Assert.True(result);
            Assert.False(top.IsSupported);
            Assert.NotNull(top.Supported);
            Assert.False(top.Supported.Value);
        }
Ejemplo n.º 3
0
        public void KindPropertyReturnsTopSupportedEnumMember()
        {
            // Arrange & Act
            TopSupported top = new TopSupported();

            // Assert
            Assert.Equal(CapabilitesTermKind.TopSupported, top.Kind);
        }
Ejemplo n.º 4
0
        public void UnknownAnnotatableTargetReturnsDefaultTopSupportedValues()
        {
            // Arrange
            TopSupported  top        = new TopSupported();
            EdmEntityType entityType = new EdmEntityType("NS", "Entity");

            //  Act
            bool result = top.Load(EdmCoreModel.Instance, entityType);

            // Assert
            Assert.False(result);
            Assert.True(top.IsSupported);
            Assert.Null(top.Supported);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Create the $top parameter.
        /// </summary>
        /// <param name="context">The OData context.</param>
        /// <param name="target">The Edm annotation target.</param>
        /// <returns>The created <see cref="OpenApiParameter"/> or null.</returns>
        public static OpenApiParameter CreateTop(this ODataContext context, IEdmVocabularyAnnotatable target)
        {
            Utils.CheckArgumentNull(context, nameof(context));
            Utils.CheckArgumentNull(target, nameof(target));

            TopSupported top = context.Model.GetTopSupported(target);

            if (top == null || top.IsSupported)
            {
                return(new OpenApiParameter
                {
                    Reference = new OpenApiReference {
                        Type = ReferenceType.Parameter, Id = "top"
                    }
                });
            }

            return(null);
        }