public override async Task <object?> GetResultAsync(Type returnType, HttpResponseMessage httpResponseMessage)
    {
        var result = await httpResponseMessage.Content.ReadAsStringAsync();

        var type = returnType.IsGenericType && returnType.GetGenericTypeDefinition() == typeof(Task <>)
            ? returnType.GenericTypeArguments[0]
            : returnType;

        if (httpResponseMessage.IsSuccessStatusCode)
        {
            return(string.IsNullOrWhiteSpace(result)
                ? null
                : _serializer.FromText(type, result));
        }

        var zaabyError = _serializer.FromText <ZaabyError>(result) !;

        throw new ZaabyException(zaabyError.Message, zaabyError.StackTrace)
              {
                  Id        = zaabyError.Id,
                  Code      = zaabyError.Code,
                  ThrowTime = zaabyError.ThrowTime,
                  Source    = zaabyError.Source
              };
    }
    private static void TextGenericNullTest(ITextSerializer serializer)
    {
        TestModel?model            = null;
        var       text             = serializer.ToText(model);
        var       deserializeModel = serializer.FromText <TestModel>(text);

        Assert.Null(deserializeModel);
    }
    private static void TextNonGenericNullTest(ITextSerializer serializer)
    {
        var type             = typeof(TestModel);
        var text             = serializer.ToText(type, null);
        var deserializeModel = serializer.FromText(type, text);

        Assert.Null(deserializeModel);
    }
    private static void TextGenericTest(ITextSerializer serializer)
    {
        var model            = TestModelFactory.Create();
        var text             = serializer.ToText(model);
        var deserializeModel = serializer.FromText <TestModel>(text) !;

        Assert.Equal(
            Tuple.Create(model.Id, model.Age, model.CreateTime, model.Name, model.Gender),
            Tuple.Create(deserializeModel.Id, deserializeModel.Age, deserializeModel.CreateTime,
                         deserializeModel.Name, deserializeModel.Gender));
    }
    public async Task TextFormatterNullAsync(ITextSerializer textSerializer, string mediaType)
    {
        var httpRequestMessage = CreateHttpRequestMessage(
            new StringContent(textSerializer.ToText <List <TestDto> >(null), Encoding.UTF8, mediaType),
            mediaType);

        var response = await _server.CreateClient().SendAsync(httpRequestMessage);

        var result = textSerializer.FromText <List <TestDto> >(await response.Content.ReadAsStringAsync());

        Assert.Null(result);
    }