Exemplo n.º 1
0
        public void ExecuteNamedParamsTest()
        {
            Incubator inc = new Incubator();

            inc.Set(new Echo());
            string         id      = "A Value";
            JsonRpcRequest request = new JsonRpcRequest();

            request.Incubator = inc;
            string value = "hello there ".RandomLetters(8);

            request.Params            = JToken.Parse("{{'value': '{0}'}}"._Format(value));
            request.RpcParams.By.Name = request.Params;
            request.Method            = "Send";
            request.Id = id;

            IHttpContext context = GetPostContextWithInput(request.ToJson());

            request           = (JsonRpcRequest)JsonRpcMessage.Parse(context);
            request.Incubator = inc;

            JsonRpcResponse response = request.Execute();

            Expect.IsTrue(response.GetType().Equals(typeof(JsonRpcResponse)));
            Expect.AreEqual(response.Result, value);
            Expect.IsNull(response.Error);
            Expect.AreEqual(request.Id, response.Id);
            Expect.AreEqual(id, response.Id);
        }
Exemplo n.º 2
0
        public void ExecuteParameterWithObjectParamters()
        {
            Incubator inc = new Incubator();

            inc.Set(new Echo());
            EchoData data = new EchoData();

            data.BoolProperty   = true;
            data.StringProperty = "dlhsddfflk";
            data.IntProperty    = 888;

            JsonRpcRequest  request  = JsonRpcRequest.Create <Echo>(inc, "TestObjectParameter", data, "some addditional stuff");
            JsonRpcResponse response = request.Execute();

            Expect.IsNotNull(response.Result);
            OutLine(response.Result.ToString(), ConsoleColor.Cyan);
        }
Exemplo n.º 3
0
        public void ExecuteOrderedParamsTest()
        {
            Incubator inc = new Incubator();

            inc.Set(new Echo());
            string          value       = "hello there ".RandomLetters(8);
            object          id          = "some value";
            string          inputString = "{{'jsonrpc': '2.0', 'method': 'Send', 'id': '{0}', 'params': ['{1}']}}"._Format(id, value);
            IHttpContext    context     = GetPostContextWithInput(inputString);
            IJsonRpcRequest parsed      = JsonRpcMessage.Parse(context);
            JsonRpcRequest  request     = (JsonRpcRequest)parsed;

            request.Incubator = inc;
            JsonRpcResponse response = request.Execute();

            Expect.IsTrue(response.GetType().Equals(typeof(JsonRpcResponse)));
            Expect.AreEqual(value, response.Result);
            Expect.IsNull(response.Error);
            Expect.AreEqual(id, response.Id);
        }