diff --git a/Refit.Tests/RestServiceExceptions.cs b/Refit.Tests/RestServiceExceptions.cs index fabf5f0b1..0fd771665 100644 --- a/Refit.Tests/RestServiceExceptions.cs +++ b/Refit.Tests/RestServiceExceptions.cs @@ -39,6 +39,24 @@ public interface IRoundTripNotString Task GetValue(int value); } +public interface IRoundTrippingLeadingWhitespace +{ + [Get("/{ **path}")] + Task GetValue(string path); +} + +public interface IRoundTrippingTrailingWhitespace +{ + [Get("/{** path}")] + Task GetValue(string path); +} + +public interface IInvalidParamSubstitution +{ + [Get("/{/path}")] + Task GetValue(string path); +} + public interface IUrlNoMatchingParameters { [Get("/{value}")] @@ -125,6 +143,27 @@ public void RoundTripParameterNotStringShouldThrow() AssertExceptionContains("has round-tripping parameter", exception); } + [Fact] + public void RoundTripWithLeadingWhitespaceShouldThrow() + { + var exception = Assert.Throws(() => RestService.For("https://api.github.com")); + AssertExceptionContains("has parameter **path, but no method parameter matches", exception); + } + + [Fact] + public void RoundTripWithTrailingWhitespaceShouldThrow() + { + var exception = Assert.Throws(() => RestService.For("https://api.github.com")); + AssertExceptionContains("has parameter ** path, but no method parameter matches", exception); + } + + [Fact] + public void InvalidParamSubstitutionShouldNotThrow() + { + var service = RestService.For("https://api.github.com"); + Assert.NotNull(service); + } + [Fact] public void UrlNoMatchingParameterShouldThrow() {