Esempio n. 1
0
        public void CoreSerializeResponsesWhenCollectionIsNull()
        {
            var jsonRpcSerializer = new JsonRpcSerializer();

            Assert.Throws <ArgumentNullException>(() =>
                                                  jsonRpcSerializer.SerializeResponses(null));
        }
Esempio n. 2
0
        public void CoreSerializeResponsesWhenCollectionContainsNull()
        {
            var jsonRpcSerializer = new JsonRpcSerializer();

            var exception = Assert.Throws <JsonRpcException>(() =>
                                                             jsonRpcSerializer.SerializeResponses(new JsonRpcResponse[] { null }));

            Assert.Equal(JsonRpcErrorCodes.InvalidMessage, exception.ErrorCode);
        }
Esempio n. 3
0
        public void CoreSerializeResponsesToStreamWhenStreamIsNull()
        {
            var jsonRpcSerializer = new JsonRpcSerializer();
            var jsonRpcMessage1   = new JsonRpcResponse(0L, 0L);
            var jsonRpcMessage2   = new JsonRpcResponse(0L, 1L);
            var jsonRpcMessages   = new[] { jsonRpcMessage1, jsonRpcMessage2 };

            Assert.Throws <ArgumentNullException>(() =>
                                                  jsonRpcSerializer.SerializeResponses(jsonRpcMessages, null));
        }
Esempio n. 4
0
        public void CoreSerializeResponsesToStreamWhenResponsesIsNull()
        {
            var jsonRpcSerializer = new JsonRpcSerializer();
            var jsonRpcMessage    = new JsonRpcRequest("m", 0L);

            using (var jsonStream = new MemoryStream())
            {
                Assert.Throws <ArgumentNullException>(() =>
                                                      jsonRpcSerializer.SerializeResponses(null, jsonStream));
            }
        }
Esempio n. 5
0
        public void CoreSerializeResponsesToStream()
        {
            var jsonSample        = EmbeddedResourceManager.GetString("Assets.v2_core_batch_res.json");
            var jsonRpcSerializer = new JsonRpcSerializer();
            var jsonRpcMessage1   = new JsonRpcResponse(0L, 0L);
            var jsonRpcMessage2   = new JsonRpcResponse(0L, 1L);
            var jsonRpcMessages   = new[] { jsonRpcMessage1, jsonRpcMessage2 };

            using (var jsonStream = new MemoryStream())
            {
                jsonRpcSerializer.SerializeResponses(jsonRpcMessages, jsonStream);

                var jsonResult = Encoding.UTF8.GetString(jsonStream.ToArray());

                CompareJsonStrings(jsonSample, jsonResult);
            }
        }
Esempio n. 6
0
 public void SerializeResponsesWhenIdIsEmptyAndSuccessIsFalse()
 {
     _serializer.SerializeResponses(_responses["res_nul_err"]);
 }
 public object SerializeResponsesB1E0D0()
 {
     return(_serializer.SerializeResponses(_ressb1["res_b1i1e0d0"]));
 }
Esempio n. 8
0
 public object BatchSuccessSerializeResponse()
 {
     return(_serializer.SerializeResponses(_responseBatches["response_success"]));
 }