Ejemplo n.º 1
0
 public void should_set_the_name_for_output_types()
 {
     Spec.GetEndpoint <OutputTypeDescriptions.GetHandler>().Response.Body.Description[0].Name.ShouldEqual("GetResponse");
     Spec.GetEndpoint <OutputTypeDescriptions.PostHandler>().Response.Body.Description[0].Name.ShouldEqual("PostResponse");
     Spec.GetEndpoint <OutputTypeDescriptions.PutHandler>().Response.Body.Description[0].Name.ShouldEqual("PutResponse");
     Spec.GetEndpoint <OutputTypeDescriptions.DeleteHandler>().Response.Body.Description[0].Name.ShouldEqual("DeleteResponse");
 }
Ejemplo n.º 2
0
        public void should_set_input_type_collection_name_to_the_xml_type_name()
        {
            var request = Spec.GetEndpoint <InputTypeDescriptions.OverridenCollectionPostHandler>().Request;

            request.Comments.ShouldBeNull();
            request.Body.Description[0].Name.ShouldEqual("NewCollectionName");
        }
Ejemplo n.º 3
0
 public void should_hide_parameters_marked_with_the_hide_sttribute()
 {
     Spec.GetEndpoint <Querystrings.ImplicitGetHandler>().QuerystringParameters.Any(x => x.Name == "HiddenParameter").ShouldBeFalse();
     Spec.GetEndpoint <Querystrings.ImplicitDeleteHandler>().QuerystringParameters.Any(x => x.Name == "HiddenParameter").ShouldBeFalse();
     Spec.GetEndpoint <Querystrings.ExplicitPostHandler>().QuerystringParameters.Any(x => x.Name == "HiddenParameter").ShouldBeFalse();
     Spec.GetEndpoint <Querystrings.ExplicitPutHandler>().QuerystringParameters.Any(x => x.Name == "HiddenParameter").ShouldBeFalse();
 }
Ejemplo n.º 4
0
        public void should_set_endpoint_status_codes_on_handlers_and_actions()
        {
            var endpoint = Spec.GetEndpoint <StatusCodeDescriptions.StatusCodesGetHandler>();

            endpoint.StatusCodes.Count.ShouldEqual(4);

            var statusCode = endpoint.StatusCodes[0];

            statusCode.Code.ShouldEqual(410);
            statusCode.Name.ShouldEqual("410 error on handler");
            statusCode.Comments.ShouldEqual("410 error on action description");

            statusCode = endpoint.StatusCodes[1];
            statusCode.Code.ShouldEqual(411);
            statusCode.Name.ShouldEqual("411 error on handler");
            statusCode.Comments.ShouldBeNull();

            statusCode = endpoint.StatusCodes[2];
            statusCode.Code.ShouldEqual(412);
            statusCode.Name.ShouldEqual("412 error on action");
            statusCode.Comments.ShouldEqual("412 error on action description");

            statusCode = endpoint.StatusCodes[3];
            statusCode.Code.ShouldEqual(413);
            statusCode.Name.ShouldEqual("413 error on action");
            statusCode.Comments.ShouldBeNull();
        }
Ejemplo n.º 5
0
        public void should_set_output_type_name_to_the_xml_type_name()
        {
            var response = Spec.GetEndpoint <OutputTypeDescriptions.OverridenRequestPostHandler>().Response;

            response.Comments.ShouldBeNull();
            response.Body.Description[0].Name.ShouldEqual("NewItemName");
        }
Ejemplo n.º 6
0
        public void should_not_set_endpoint_headers_when_none_are_set_on_handlers_or_actions()
        {
            var endpoint = Spec.GetEndpoint <MimeTypeDescriptions.NoMimeTypesGetHandler>();

            endpoint.Request.MimeTypes.Count.ShouldEqual(0);
            endpoint.Response.MimeTypes.Count.ShouldEqual(0);
        }
Ejemplo n.º 7
0
 public void should_exclude_auto_bound_properties()
 {
     Spec.GetEndpoint <Querystrings.ImplicitGetHandler>().QuerystringParameters.Any(x => x.Name == "ContentType").ShouldBeFalse();
     Spec.GetEndpoint <Querystrings.ImplicitDeleteHandler>().QuerystringParameters.Any(x => x.Name == "ContentType").ShouldBeFalse();
     Spec.GetEndpoint <Querystrings.ExplicitPostHandler>().QuerystringParameters.Any(x => x.Name == "ContentType").ShouldBeFalse();
     Spec.GetEndpoint <Querystrings.ExplicitPutHandler>().QuerystringParameters.Any(x => x.Name == "ContentType").ShouldBeFalse();
 }
Ejemplo n.º 8
0
        public void should_set_endpoint_headers_on_handlers_and_actions()
        {
            var endpoint = Spec.GetEndpoint <HeaderDescriptions.HeadersGetHandler>();

            endpoint.Headers.Count.ShouldEqual(4);

            var header = endpoint.Headers[0];

            header.Type.ShouldEqual("Request");
            header.Name.ShouldEqual("accept");
            header.Comments.ShouldEqual("This is an endpoint description.");
            header.Optional.ShouldBeTrue();

            header = endpoint.Headers[1];
            header.Type.ShouldEqual("Request");
            header.Name.ShouldEqual("api-key");
            header.Comments.ShouldEqual("This is a handler description.");
            header.Optional.ShouldBeTrue();

            header = endpoint.Headers[2];
            header.Type.ShouldEqual("Response");
            header.Name.ShouldEqual("content-length");
            header.Comments.ShouldBeNull();
            header.Optional.ShouldBeFalse();

            header = endpoint.Headers[3];
            header.Type.ShouldEqual("Response");
            header.Name.ShouldEqual("content-type");
            header.Comments.ShouldBeNull();
            header.Optional.ShouldBeFalse();
        }
Ejemplo n.º 9
0
        public void should_set_post_input_type_description()
        {
            var request = Spec.GetEndpoint <InputTypeDescriptions.PostHandler>().Request;

            request.Comments.ShouldEqual("Some post request description");
            request.Body.Description[0].IsComplexType.ShouldEqual(true);
        }
Ejemplo n.º 10
0
        public void should_order_querystring_options_by_name_or_value()
        {
            var options = Spec.GetEndpoint <Querystrings.OptionGetHandler>()
                          .GetQuerystring <Querystrings.OptionRequest>(x => x.Options).Options;

            options.Options[0].Value.ShouldEqual("Option1");
            options.Options[1].Value.ShouldEqual("Option3");
        }
Ejemplo n.º 11
0
        public void should_generate_id_based_on_the_url()
        {
            const string url      = "/endpointdescriptions/nodescription";
            var          endpoint = Spec.GetEndpoint <EndpointDescriptions.NoDescriptionGetHandler>();

            endpoint.Id.ShouldEqual($"{url}:GET".Hash());
            endpoint.Url.ShouldEqual(url);
        }
Ejemplo n.º 12
0
        public void should_set_output_type_collection_name_to_the_xml_type_name()
        {
            var response = Spec.GetEndpoint <OutputTypeDescriptions.OverridenCollectionPostHandler>().Response;

            response.Comments.ShouldBeNull();
            response.Body.Description[0].Name.ShouldEqual("NewCollectionName");
            response.Body.Description[0].IsArray.ShouldEqual(true);
        }
Ejemplo n.º 13
0
        public void should_set_input_type_default_collection_name_and_datatype()
        {
            var request = Spec.GetEndpoint <InputTypeDescriptions.CollectionPostHandler>().Request;

            request.Comments.ShouldBeNull();
            request.Body.Description[0].Name.ShouldEqual("ArrayOfRequestItem");
            request.Body.Description[0].IsArray.ShouldEqual(true);
        }
Ejemplo n.º 14
0
        public void should_set_output_type_default_collection_name_of_inherited_collection_and_datatype()
        {
            var response = Spec.GetEndpoint <OutputTypeDescriptions.InheritedCollectionPostHandler>().Response;

            response.Comments.ShouldBeNull();
            response.Body.Description[0].Name.ShouldEqual("ArrayOfResponseItem");
            response.Body.Description[0].IsArray.ShouldEqual(true);
        }
        public void should_set_get_output_type_description()
        {
            var response = Spec.GetEndpoint <OutputTypeDescriptions.GetHandler>().Response;

            response.Name.ShouldEqual("GetResponse");
            response.Comments.ShouldEqual("Some get response description");
            response.IsArray.ShouldBeFalse();
        }
        public void should_set_post_input_type_description()
        {
            var request = Spec.GetEndpoint <InputTypeDescriptions.PostHandler>().Request;

            request.Name.ShouldEqual("PostRequest");
            request.Comments.ShouldEqual("Some post request description");
            request.IsArray.ShouldBeFalse();
        }
Ejemplo n.º 17
0
        public void should_order_url_paramaters_options_by_name_or_value()
        {
            var options = Spec.GetEndpoint <UrlParameters.OptionGetHandler>()
                          .GetUrlParameter <UrlParameters.OptionRequest>(x => x.Options).Options;

            options[0].Value.ShouldEqual("Option1");
            options[1].Value.ShouldEqual("Option3");
        }
Ejemplo n.º 18
0
        public void should_enumerate_url_parameters_ordered_by_position_in_the_url()
        {
            var parameters = Spec.GetEndpoint <UrlParameters.GetHandler>().UrlParameters;

            parameters.Count.ShouldEqual(2);
            parameters[0].Name.ShouldEqual("WidgetId");
            parameters[1].Name.ShouldEqual("Revision");
        }
Ejemplo n.º 19
0
        public void should_set_comments_default_when_there_is_no_comments_attribute()
        {
            var parameter = Spec.GetEndpoint <Querystrings.ImplicitGetHandler>()
                            .GetQuerystring <Querystrings.Request>(x => x.Sort);

            parameter.Name.ShouldEqual("Sort");
            parameter.Comments.ShouldBeNull();
            parameter.Options.ShouldBeNull();
        }
Ejemplo n.º 20
0
        public void should_set_handler_description_for_delete_endpoint()
        {
            var endpoint = Spec.GetEndpoint <EndpointDescriptions.HandlerDescription.DeleteHandler>();

            endpoint.Name.ShouldEqual("Some delete handler name");
            endpoint.Comments.ShouldEqual("Some delete handler description");
            endpoint.Method.ShouldEqual("DELETE");
            endpoint.Url.ShouldEqual("/endpointdescriptions/handlerdescription/delete/{Id}");
        }
Ejemplo n.º 21
0
        public void should_not_set_handler_description_for_endpoint_with_no_description()
        {
            var endpoint = Spec.GetEndpoint <EndpointDescriptions.NoDescriptionGetHandler>();

            endpoint.Name.ShouldBeNull();
            endpoint.Comments.ShouldBeNull();
            endpoint.Method.ShouldEqual("GET");
            endpoint.Url.ShouldEqual("/endpointdescriptions/nodescription");
        }
        public void should_set_output_type_name_to_the_xml_type_name()
        {
            var response = Spec.GetEndpoint <OutputTypeDescriptions.OverridenRequestPostHandler>().Response;

            response.Name.ShouldEqual("NewItemName");
            response.Comments.ShouldBeNull();
            response.Type.ShouldEqual(typeof(OutputTypeDescriptions.OverridenResponseItem).GetHash());
            response.IsArray.ShouldBeFalse();
        }
        public void should_set_output_type_default_collection_name_of_inherited_collection_and_datatype_should_be_a_hash_of_the_element_type_and_action()
        {
            var response = Spec.GetEndpoint <OutputTypeDescriptions.InheritedCollectionPostHandler>().Response;

            response.Name.ShouldEqual("ArrayOfResponseItem");
            response.Comments.ShouldBeNull();
            response.Type.ShouldEqual(typeof(OutputTypeDescriptions.ResponseItem).GetHash());
            response.IsArray.ShouldBeTrue();
        }
Ejemplo n.º 24
0
        public void should_set_url_paramaters_option_description_to_default_when_not_specified()
        {
            var option = Spec.GetEndpoint <UrlParameters.OptionGetHandler>()
                         .GetUrlParameter <UrlParameters.OptionRequest>(x => x.Options).Options[1];

            option.Name.ShouldEqual("Option3");
            option.Value.ShouldEqual("Option3");
            option.Comments.ShouldBeNull();
        }
Ejemplo n.º 25
0
        public void should_get_url_paramaters_option_description()
        {
            var option = Spec.GetEndpoint <UrlParameters.OptionGetHandler>()
                         .GetUrlParameter <UrlParameters.OptionRequest>(x => x.Options).Options[0];

            option.Name.ShouldEqual("Option 1");
            option.Value.ShouldEqual("Option1");
            option.Comments.ShouldEqual("Option 1 description.");
        }
Ejemplo n.º 26
0
        public void should_set_embedded_markdown_action_description()
        {
            var endpoint = Spec.GetEndpoint <EndpointDescriptions.ActionDescription.EmbeddedDescriptionGetHandler>();

            endpoint.Name.ShouldBeNull();
            endpoint.Comments.ShouldEqual("<p><strong>An embedded action markdown description</strong></p>");
            endpoint.Method.ShouldEqual("GET");
            endpoint.Url.ShouldEqual("/endpointdescriptions/actiondescription/embeddeddescription");
        }
Ejemplo n.º 27
0
        public void should_indicate_when_the_parameter_is_required()
        {
            var endpoint = Spec.GetEndpoint <Querystrings.ImplicitGetHandler>();

            endpoint.GetQuerystring <Querystrings.Request>(x => x.NotRequiredParameter).Required.ShouldBeFalse();
            endpoint.GetQuerystring <Querystrings.Request>(x => x.NullableId).Required.ShouldBeFalse();
            endpoint.GetQuerystring <Querystrings.Request>(x => x.Sort).Required.ShouldBeTrue();
            endpoint.GetQuerystring <Querystrings.Request>(x => x.Revisions).Required.ShouldBeTrue();
        }
Ejemplo n.º 28
0
        public void should_set_comments_when_there_is_a_comments_attribute()
        {
            var parameter = Spec.GetEndpoint <Querystrings.ImplicitGetHandler>()
                            .GetQuerystring <Querystrings.Request>(x => x.Revisions);

            parameter.Name.ShouldEqual("Revisions");
            parameter.Comments.ShouldEqual("These are the revision numbers.");
            parameter.Options.ShouldBeNull();
        }
Ejemplo n.º 29
0
        public void should_get_querystring_option_description()
        {
            var option = Spec.GetEndpoint <Querystrings.OptionGetHandler>()
                         .GetQuerystring <Querystrings.OptionRequest>(x => x.Options).Options.Options[0];

            option.Name.ShouldEqual("Option 1");
            option.Value.ShouldEqual("Option1");
            option.Comments.ShouldEqual("Option 1 description.");
        }
Ejemplo n.º 30
0
        public void should_set_querystring_option_description_to_default_when_not_specified()
        {
            var option = Spec.GetEndpoint <Querystrings.OptionGetHandler>()
                         .GetQuerystring <Querystrings.OptionRequest>(x => x.Options).Options.Options[1];

            option.Name.ShouldEqual("Option3");
            option.Value.ShouldEqual("Option3");
            option.Comments.ShouldBeNull();
        }