Exemplo n.º 1
0
        public async Task InvokeRequest_MultipleDictionaryValues_Valid()
        {
            string            methodName = nameof(TestRouteClass.AllTypes);
            DefaultRpcInvoker invoker    = this.GetInvoker(methodName);

            bool   a         = true;
            string bb        = "Test";
            object?ccc       = null;
            var    dddd      = new TestComplexParam();
            int    eeeee     = 1;
            var    paramDict = new Dictionary <string, IRpcParameter>
            {
                ["a"]     = JsonBytesRpcParameter.FromRaw(a),
                ["bb"]    = JsonBytesRpcParameter.FromRaw(bb),
                ["ccc"]   = JsonBytesRpcParameter.FromRaw(ccc),
                ["dddd"]  = JsonBytesRpcParameter.FromRaw(dddd),
                ["eeeee"] = JsonBytesRpcParameter.FromRaw(eeeee)
            };
            RpcRequest  stringRequest = new RpcRequest("1", methodName, parameters: new RpcParameters(paramDict));
            RpcResponse?response      = await invoker.InvokeRequestAsync(stringRequest);

            RpcResponse resultResponse = Assert.IsType <RpcResponse>(response);

            Assert.False(resultResponse.HasError);
            var value = Assert.IsType <ValueTuple <bool, string, object, TestComplexParam, int> >(resultResponse.Result);

            Assert.Equal((a, bb, ccc, dddd, eeeee), value);
        }
Exemplo n.º 2
0
        public async Task InvokeRequest_ComplexParam_TwoRequests_NotCached()
        {
            string            methodName = nameof(TestRouteClass.ComplexParam);
            DefaultRpcInvoker invoker    = this.GetInvoker(methodName);

            async Task Test(TestComplexParam param)
            {
                var         rpcParameter  = JsonBytesRpcParameter.FromRaw(param);
                RpcRequest  stringRequest = new RpcRequest("1", methodName, parameters: new RpcParameters(rpcParameter));
                RpcResponse?response      = await invoker.InvokeRequestAsync(stringRequest);

                RpcResponse resultResponse = Assert.IsType <RpcResponse>(response);

                Assert.False(resultResponse.HasError);
                Assert.Equal(param, resultResponse.Result);
            }

            TestComplexParam param1 = new TestComplexParam
            {
                A = "Test",
                B = 5
            };

            await Test(param1);

            TestComplexParam param2 = new TestComplexParam
            {
                A = "Test2",
                B = 6
            };

            await Test(param2);
        }
Exemplo n.º 3
0
        public async Task InvokeRequest_ComplexParam_Valid()
        {
            string            methodName = nameof(TestRouteClass.ComplexParam);
            DefaultRpcInvoker invoker    = this.GetInvoker(methodName);

            TestComplexParam param = new TestComplexParam
            {
                A = "Test",
                B = 5
            };
            var         rpcParameter  = InvokerTests.FromRaw(param);
            RpcRequest  stringRequest = new RpcRequest("1", methodName, parameters: new RpcParameters(rpcParameter));
            RpcResponse?response      = await invoker.InvokeRequestAsync(stringRequest);

            RpcResponse resultResponse = Assert.IsType <RpcResponse>(response);

            Assert.False(resultResponse.HasError);
            Assert.Equal(param, resultResponse.Result);
        }
Exemplo n.º 4
0
 public (bool, string, object, TestComplexParam, int) AllTypes(bool a, string bb, object ccc, TestComplexParam dddd, int eeeee)
 {
     return(a, bb, ccc, dddd, eeeee);
 }
Exemplo n.º 5
0
 public TestComplexParam ComplexParam(TestComplexParam param)
 {
     return(param);
 }