Exemple #1
0
        public void it_should_build_a_hierarchical_path()
        {
            var method  = typeof(CrudController).GetMethod("SetRoles");
            var details = _builder.BuildDescriptor().Operations.Cast <OperationInfo <Verb> >().FirstOrDefault(operation => operation.UnderlyingMethod == method);

            details.UrlTemplate.Should().Be("/api/person/{id}/roles");
            details.ProtocolSpecificCommand.Should().Be(Verb.POST);
        }
Exemple #2
0
        public void it_should_describe_Some_method_correctly()
        {
            var method  = typeof(AnotherTestController <TestController>).GetMethod("Some");
            var details = _builder.BuildDescriptor().Operations.Cast <OperationInfo <Verb> >().FirstOrDefault(operation => operation.UnderlyingMethod == method);

            details.Should().NotBeNull();
            details.ProtocolSpecificCommand.Should().Be(Verb.GET);
            details.UrlTemplate.Should().Be("/api/test");
            details.TemplateRegex.ToString().Should().Be("^/api/test$");
            details.Url.ToString().Should().Be("/api/test");
            details.Arguments.Should().HaveCount(method.GetParameters().Length);
        }
Exemple #3
0
        public void it_should_describe_Substract_method_correctly()
        {
            var method  = typeof(TestController).GetMethod("Substract");
            var details = _builder.BuildDescriptor().Operations.Cast <OperationInfo <Verb> >().FirstOrDefault(operation => operation.UnderlyingMethod == method);

            details.Should().NotBeNull();
            details.ProtocolSpecificCommand.Should().Be(Verb.GET);
            details.UrlTemplate.Should().Be("/api/test/sub/{operandA}?operandB={operandB}");
            details.TemplateRegex.ToString().Should().Be("^/api/test/sub/[^/?]+$");
            details.Url.ToString().Should().Be("/api/test/sub");
            details.Arguments.Should().HaveCount(method.GetParameters().Length);
            details.Arguments.First().Parameter.Should().Be(method.GetParameters().First());
            details.Arguments.First().UrlTemplate.Should().Be("/api/test/sub/{operandA}");
            details.Arguments.First().VariableName.Should().Be("operandA");
            details.Arguments.Last().Parameter.Should().Be(method.GetParameters().Last());
            details.Arguments.Last().UrlTemplate.Should().Be("&operandB={operandB}");
            details.Arguments.Last().VariableName.Should().Be("operandB");
        }