From 6630664860bc97f922f49fa9e20dd7d06eb25d85 Mon Sep 17 00:00:00 2001 From: Timothy Makkison Date: Fri, 1 Nov 2024 15:24:50 +0000 Subject: [PATCH] feat: add fragment exception test and updated ParamSub test --- Refit.Tests/RestServiceExceptions.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Refit.Tests/RestServiceExceptions.cs b/Refit.Tests/RestServiceExceptions.cs index 0fd771665..3554c418b 100644 --- a/Refit.Tests/RestServiceExceptions.cs +++ b/Refit.Tests/RestServiceExceptions.cs @@ -57,6 +57,12 @@ public interface IInvalidParamSubstitution Task GetValue(string path); } +public interface IInvalidFragmentParamSubstitution +{ + [Get("/{#path}")] + Task GetValue(string path); +} + public interface IUrlNoMatchingParameters { [Get("/{value}")] @@ -158,10 +164,19 @@ public void RoundTripWithTrailingWhitespaceShouldThrow() } [Fact] - public void InvalidParamSubstitutionShouldNotThrow() + public async Task InvalidParamSubstitutionShouldThrow() { var service = RestService.For("https://api.github.com"); Assert.NotNull(service); + + await Assert.ThrowsAsync(() => service.GetValue("throws")); + } + + [Fact] + public void InvalidFragmentParamSubstitutionShouldThrow() + { + var exception = Assert.Throws(() => RestService.For("https://api.github.com")); + AssertExceptionContains("but no method parameter matches", exception); } [Fact]