public void CoreSerializeResponseWhenResponseIsNull() { var jsonRpcSerializer = new JsonRpcSerializer(); Assert.Throws <ArgumentNullException>(() => jsonRpcSerializer.SerializeResponse(null)); }
public void CoreSerializeResponseToStreamWhenStreamIsNull() { var jsonSample = EmbeddedResourceManager.GetString("Assets.v2_core_res.json"); var jsonRpcSerializer = new JsonRpcSerializer(); var jsonRpcMessage = new JsonRpcResponse(0L, 0L); Assert.Throws <ArgumentNullException>(() => jsonRpcSerializer.SerializeResponse(jsonRpcMessage, null)); }
public void SerializeResponseT010() { var jsont = EmbeddedResourceManager.GetString("Assets.v2_spec_01.0_res.json"); var jrs = new JsonRpcSerializer(); var jrm = new JsonRpcResponse(1L, 19L); var jsonr = jrs.SerializeResponse(jrm); JsonRpcSerializerTests.CompareJsonStrings(jsont, jsonr); }
public void V2SpecT010SerializeResponse() { var jsonSample = EmbeddedResourceManager.GetString("Assets.v2_spec_01.0_res.json"); var jsonRpcSerializer = new JsonRpcSerializer(); var jsonRpcMessage = new JsonRpcResponse(19L, 1L); var jsonResult = jsonRpcSerializer.SerializeResponse(jsonRpcMessage); CompareJsonStrings(jsonSample, jsonResult); }
public void V2CoreSerializeResponseWhenIdIsFloat() { var jsonSample = EmbeddedResourceManager.GetString("Assets.v2_core_id_float_res.json"); var jsonRpcSerializer = new JsonRpcSerializer(); var jsonRpcMessage = new JsonRpcResponse(string.Empty, 1D); var jsonResult = jsonRpcSerializer.SerializeResponse(jsonRpcMessage); CompareJsonStrings(jsonSample, jsonResult); }
public void SerializeResponseT010() { var jsont = EmbeddedResourceManager.GetString("Assets.v1_spec_01.0_res.json"); var jrs = new JsonRpcSerializer(compatibilityLevel: JsonRpcCompatibilityLevel.Level1); var jrm = new JsonRpcResponse(1L, "Hello JSON-RPC"); var jsonr = jrs.SerializeResponse(jrm); JsonRpcSerializerTests.CompareJsonStrings(jsont, jsonr); }
public void V2CoreSerializeResponseDataWhenHasDataIsTrueAnsIsNull() { var jsonSample = EmbeddedResourceManager.GetString("Assets.v2_core_error_has_data_true_null.json"); var jsonRpcSerializer = new JsonRpcSerializer(); var jsonRpcError = new JsonRpcError(0L, "m", null); var jsonRpcMessage = new JsonRpcResponse(jsonRpcError, 1L); var jsonResult = jsonRpcSerializer.SerializeResponse(jsonRpcMessage); CompareJsonStrings(jsonSample, jsonResult); }
public void CoreSerializeResponseToStreamWhenResponseIsNull() { var jsonRpcSerializer = new JsonRpcSerializer(); var jsonRpcMessage = new JsonRpcRequest("m", 0L); using (var jsonStream = new MemoryStream()) { Assert.Throws <ArgumentNullException>(() => jsonRpcSerializer.SerializeResponse(null, jsonStream)); } }
public void V1SpecT010SerializeResponse() { var jsonSample = EmbeddedResourceManager.GetString("Assets.v1_spec_01.0_res.json"); var jsonRpcSerializer = new JsonRpcSerializer { CompatibilityLevel = JsonRpcCompatibilityLevel.Level1 }; var jsonRpcMessage = new JsonRpcResponse("Hello JSON-RPC", 1L); var jsonResult = jsonRpcSerializer.SerializeResponse(jsonRpcMessage); CompareJsonStrings(jsonSample, jsonResult); }
public void V1BitcoinT01SerializeResponse() { var jsonSample = EmbeddedResourceManager.GetString("Assets.v1_btc_01_res.json"); var jsonRpcSerializer = new JsonRpcSerializer { CompatibilityLevel = JsonRpcCompatibilityLevel.Level1 }; var jsonRpcMessage = new JsonRpcResponse("000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f", "foo"); var jsonResult = jsonRpcSerializer.SerializeResponse(jsonRpcMessage); CompareJsonStrings(jsonSample, jsonResult); }
public void V1BitcoinT02SerializeResponse() { var jsonSample = EmbeddedResourceManager.GetString("Assets.v1_btc_02_res.json"); var jsonRpcSerializer = new JsonRpcSerializer { CompatibilityLevel = JsonRpcCompatibilityLevel.Level1 }; var jsonRpcMessage = new JsonRpcResponse(new JsonRpcError(-8L, "Block height out of range"), "foo"); var jsonResult = jsonRpcSerializer.SerializeResponse(jsonRpcMessage); CompareJsonStrings(jsonSample, jsonResult); }
public void CoreSerializeResponseToStream() { var jsonSample = EmbeddedResourceManager.GetString("Assets.v2_core_res.json"); var jsonRpcSerializer = new JsonRpcSerializer(); var jsonRpcMessage = new JsonRpcResponse(0L, 0L); using (var jsonStream = new MemoryStream()) { jsonRpcSerializer.SerializeResponse(jsonRpcMessage, jsonStream); var jsonResult = Encoding.UTF8.GetString(jsonStream.ToArray()); CompareJsonStrings(jsonSample, jsonResult); } }
public object SerializeResponseB0E0D0() { return(_serializer.SerializeResponse(_ressb0["res_b0i1e0d0"])); }
public object SuccessSerializeResponse() { return(_serializer.SerializeResponse(_responses["response_success"])); }