Enhanced easy to catch test coverage

This commit is contained in:
2025-07-29 08:38:40 +02:00
parent a0d0607ec8
commit 50b8efbb46
5 changed files with 268 additions and 11 deletions

View File

@@ -165,6 +165,34 @@ namespace Cloudflare.Core.Tests.CloudflareClientTests
}
}
[DataTestMethod]
[DataRow(HttpStatusCode.Unauthorized)]
[DataRow(HttpStatusCode.Forbidden)]
public async Task ShouldThrowAuthenticationExceptionOnStatusCodeWithoutErrors(HttpStatusCode statusCode)
{
// Arrange
_httpHandlerMock.Responses.Enqueue(new HttpResponseMessage
{
StatusCode = statusCode,
Content = new StringContent(@"{""success"": false, ""errors"": null, ""messages"": []}", Encoding.UTF8, MediaTypeNames.Application.Json),
});
var client = GetClient();
try
{
// Act
await client.GetAsync<TestClass>("foo");
Assert.Fail();
}
catch (AuthenticationException ex)
{
// Assert
Assert.IsNull(ex.InnerException);
Assert.AreEqual(string.Empty, ex.Message);
}
}
[DataTestMethod]
[DataRow(HttpStatusCode.Unauthorized)]
[DataRow(HttpStatusCode.Forbidden)]