This commit is contained in:
2024-12-30 21:25:35 +01:00
parent fba9aa9349
commit a46961cf80
19 changed files with 406 additions and 11 deletions

View File

@@ -0,0 +1,18 @@
using System.Text.Json;
using Shouldly;
namespace Solar.Api.Tests.Extensions;
public static class HttpClientExtensions
{
public static async Task<T> FetchJson<T>(this HttpClient client, string path) where T : class
{
var response = await client.GetAsync(path);
response.EnsureSuccessStatusCode();
var result = JsonSerializer.Deserialize<T>(await response.Content.ReadAsStringAsync());
result.ShouldNotBeNull();
return result;
}
}