Ejemplo n.º 1
0
        public void CoreSerializeResponseWhenResponseIsNull()
        {
            var jsonRpcSerializer = new JsonRpcSerializer();

            Assert.Throws <ArgumentNullException>(() =>
                                                  jsonRpcSerializer.SerializeResponse(null));
        }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 7
0
        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);
        }
Ejemplo n.º 8
0
        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));
            }
        }
Ejemplo n.º 9
0
        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);
        }
Ejemplo n.º 10
0
        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);
        }
Ejemplo n.º 11
0
        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);
        }
Ejemplo n.º 12
0
        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"]));
 }
Ejemplo n.º 14
0
 public object SuccessSerializeResponse()
 {
     return(_serializer.SerializeResponse(_responses["response_success"]));
 }