public void SetUpHttpClient() { this._mockHttp = new MockHttpMessageHandler(); EndpointConfiguration config = this.GetEndpointConfiguration(); config.EndpointUri = new Uri(ENDPOINT_URI); config.Version = XApiVersion.Parse(VERSION); config.HttpClient = this._mockHttp.ToHttpClient(); this._client = XApiClientFactory.Create(config); }
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { if (reader.TokenType == JsonToken.Null) { return(null); } else if (reader.TokenType == JsonToken.String) { try { return(XApiVersion.Parse((string)reader.Value)); } catch (Exception ex) { throw new JsonSerializationException($"Error parsing version string: {reader.Value}", ex); } } else { throw new JsonSerializationException($"Unexpected token or value when parsing version. Token: {reader.TokenType}, Value: {reader.Value}"); } }