using System; using System.Linq; using System.Threading.Tasks; using BTCPayServer.Client; using Xunit; namespace BTCPayServer.Tests; public class AssertEx { public static async Task AssertValidationError(string[] fields, Func act) { var ex = await Assert.ThrowsAsync(act); foreach (var field in fields) { Assert.Contains(field, ex.ValidationErrors.Select(e => e.Path).ToArray()); } return ex; } public static async Task AssertHttpError(int code, Func act) { var ex = await Assert.ThrowsAsync(act); Assert.Equal(code, ex.HttpCode); } public static async Task AssertApiError(int httpStatus, string errorCode, Func act) { var ex = await Assert.ThrowsAsync(act); Assert.Equal(httpStatus, ex.HttpCode); Assert.Equal(errorCode, ex.APIError.Code); } }