elsa-core/test/component/Elsa.ComponentTests/Helpers/HttpContentExtensions.cs

15 lines
425 B
C#
Raw Normal View History

2020-10-19 20:12:11 +00:00
using System.Net.Http;
using System.Threading.Tasks;
using Newtonsoft.Json;
namespace Elsa.ComponentTests.Helpers
{
public static class HttpContentExtensions
{
public static async Task<T> ReadJsonAsync<T>(this HttpContent content)
{
var json = await content.ReadAsStringAsync();
return JsonConvert.DeserializeObject<T>(json, JsonContent.SerializerSettings)!;
}
}
}