Skip to content

Commit

Permalink
feat: add fragment exception test and updated ParamSub test
Browse files Browse the repository at this point in the history
  • Loading branch information
TimothyMakkison committed Nov 3, 2024
1 parent f846723 commit 6630664
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion Refit.Tests/RestServiceExceptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ public interface IInvalidParamSubstitution
Task<string> GetValue(string path);
}

public interface IInvalidFragmentParamSubstitution
{
[Get("/{#path}")]
Task<string> GetValue(string path);
}

public interface IUrlNoMatchingParameters
{
[Get("/{value}")]
Expand Down Expand Up @@ -158,10 +164,19 @@ public void RoundTripWithTrailingWhitespaceShouldThrow()
}

[Fact]
public void InvalidParamSubstitutionShouldNotThrow()
public async Task InvalidParamSubstitutionShouldThrow()
{
var service = RestService.For<IInvalidParamSubstitution>("https://api.github.com");
Assert.NotNull(service);

await Assert.ThrowsAsync<ApiException>(() => service.GetValue("throws"));
}

[Fact]
public void InvalidFragmentParamSubstitutionShouldThrow()
{
var exception = Assert.Throws<ArgumentException>(() => RestService.For<IInvalidFragmentParamSubstitution>("https://api.github.com"));
AssertExceptionContains("but no method parameter matches", exception);
}

[Fact]
Expand Down

0 comments on commit 6630664

Please sign in to comment.