Ejemplo n.º 1
0
            public void Throws_InvalidRequestException_For_Request_With_Object_As_Id()
            {
                // Given
                const string json   = "{\"jsonrpc\": \"2.0\", \"id\": {}, \"method\": \"test\", \"params\": \"bar\"}";
                var          parser = new JsonRpcRequestParser(new JsonSerializer());

                // When
                var exception = Record.Exception(() => parser.Parse(json));

                // Then
                Assert.IsType <InvalidRequestException>(exception);
                Assert.Equal("Invalid id.", exception.Message);
            }
Ejemplo n.º 2
0
            public void Returns_Object_For_Valid_Json()
            {
                // Given
                var json   = "{ \"id\": 1, \"jsonrpc\": \"2.0\", \"method\": \"foo\", \"params\": 1 }";
                var parser = new JsonRpcRequestParser(new JsonSerializer());

                // When
                var result = parser.Parse(json);

                // Then
                Assert.Equal(1L, result.Id);
                Assert.Equal("2.0", result.ProtocolVersion);
                Assert.Equal("foo", result.MethodName);
                Assert.Equal(1L, result.Parameters);
            }