public void Deserialize_Empty() { var message = _serializer.Deserialize("{\"msgType\":\"8\"}"); message.Should().BeEquivalentTo(new ExecutionReport { MsgType = MsgTypes.ExecutionReport }); }
private void VerifyResponse(IRestResponse response) { int statusCode = (int)response.StatusCode; if (statusCode < 400 && response.ErrorException != null) { Logger.Error("request has failed: {0}", response.ErrorException); throw new CallfireClientException(response.ErrorMessage, response.ErrorException); } else if (statusCode >= 400) { ErrorMessage message; try { message = JsonSerializer.Deserialize <ErrorMessage>(response); } catch (Exception e) { Logger.Error("deserialization of ErrorMessage has failed: {0}", e); message = new ErrorMessage(statusCode, response.Content, ClientConstants.GENERIC_HELP_LINK); } switch (statusCode) { case 400: throw new BadRequestException(message); case 401: throw new UnauthorizedException(message); case 403: throw new AccessForbiddenException(message); case 404: throw new ResourceNotFoundException(message); case 500: throw new InternalServerErrorException(message); default: throw new CallfireApiException(message); } } }