Files
Brandyn / Techy fcc1b09210 init
2026-04-04 15:40:51 -05:00

36 lines
969 B
C#

// Copyright Epic Games, Inc. All Rights Reserved.
using System.Net;
using System.Net.Http;
using System.Text.Json;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace Jupiter.Tests.Functional
{
public static class JsonTestUtils
{
public static readonly JsonSerializerOptions DefaultJsonSerializerSettings = ConfigureJsonOptions();
private static JsonSerializerOptions ConfigureJsonOptions()
{
JsonSerializerOptions options = new JsonSerializerOptions();
BaseStartup.ConfigureJsonOptions(options);
return options;
}
}
public static class HttpResponseMessageExtensions
{
public static async Task EnsureSuccessStatusCodeWithMessageAsync(this HttpResponseMessage response)
{
if (response.StatusCode == HttpStatusCode.InternalServerError)
{
Assert.Fail($"Internal server error with message: {await response.Content.ReadAsStringAsync()}");
}
response.EnsureSuccessStatusCode();
}
}
}