public void Given_Type_Should_ImpliesJson_ReturnValue()
        {
            var result = ContentTypeValidator.ImpliesJson("lorem ipsum");

            result.Should().BeFalse();

            result = ContentTypeValidator.ImpliesJson("text/json");
            result.Should().BeTrue();
        }
Example #2
0
        /// <inheritdoc />
        protected override bool IsValidDataType(string data)
        {
            if (ContentTypeValidator.ImpliesJson(this.ContentType))
            {
                return(false);
            }

            if (ContentTypeValidator.IsText(this.ContentType))
            {
                return(true);
            }

            return(false);
        }
        /// <summary>
        /// Checks whether the content type of the <see cref="CloudEvent{T}"/> instance indicates structured or not.
        /// </summary>
        /// <param name="ce"><see cref="CloudEvent{T}"/> instance.</param>
        /// <returns>Returns <c>True</c>, if the content type indicates structured; otherwise returns <c>False</c>.</returns>
        protected static bool IsStructuredCloudEventContentType(CloudEvent <T> ce)
        {
            if (ContentTypeValidator.IsJson(ce.ContentType))
            {
                return(true);
            }

            if (ContentTypeValidator.HasJsonSuffix(ce.ContentType))
            {
                return(true);
            }

            if (ContentTypeValidator.ImpliesJson(ce.ContentType))
            {
                return(true);
            }

            return(false);
        }
        private static bool IsJson(string contentType)
        {
            if (ContentTypeValidator.IsJson(contentType))
            {
                return(true);
            }

            if (ContentTypeValidator.HasJsonSuffix(contentType))
            {
                return(true);
            }

            if (ContentTypeValidator.ImpliesJson(contentType))
            {
                return(true);
            }

            return(false);
        }