Esempio n. 1
0
        public void RpcProxyServiceMakeCallMethodNotAuthorized(IRpcHttpClient client,
                                                               IRpcHttpClientProvider clientProvider,
                                                               RpcProxyService proxyService)
        {
            var response = new HttpResponseMessage(HttpStatusCode.Accepted)
            {
                Content = new StreamContent(new ErrorResponseMessage(JsonRpcErrorCode.UnauthorizedAccess, "Not Authorized").SerializeToStream())
            };

            client.SendAsync(Arg.Any <HttpRequestMessage>()).Returns(response);

            clientProvider.GetHttpClient(Arg.Any <string>(), Arg.Any <string>()).Returns(client);

            var bytes = new byte[] { 0, 1, 1, 0 };

            Assert.Throws <AggregateException>(() => proxyService.MakeCallNoReturn("SomeNamespace", "SomeClass", "SomeMethod", bytes, false, false));
        }
Esempio n. 2
0
        public void RpcProxyServiceMakeCallNoReturn(IRpcHttpClient client,
                                                    IRpcHttpClientProvider clientProvider,
                                                    RpcProxyService proxyService)
        {
            var response = new HttpResponseMessage(HttpStatusCode.Accepted)
            {
                Content = new StreamContent(new EmptyResponseMessage("2.0", "1").SerializeToStream())
            };

            client.SendAsync(Arg.Any <HttpRequestMessage>()).Returns(response);

            clientProvider.GetHttpClient(Arg.Any <string>(), Arg.Any <string>()).Returns(client);

            var bytes = new byte[] { 0, 1, 1, 0 };

            proxyService.MakeCallNoReturn("SomeNamespace", "SomeClass", "SomeMethod", bytes, false, false);

            client.Received().SendAsync(Arg.Is <HttpRequestMessage>(message => ValidateSomeClassSomeMethod(message)));
        }
Esempio n. 3
0
        public void RpcProxyServiceMakeCallReturnValueCompressResponse(IRpcHttpClient client,
                                                                       IRpcHttpClientProvider clientProvider,
                                                                       RpcProxyService proxyService)
        {
            var response = new HttpResponseMessage(HttpStatusCode.Accepted)
            {
                Content = new StreamContent(new ResponseMessage <int>(10, "2.0", "1").SerializeToStream("gzip"))
            };

            response.Content.Headers.Add("Content-Encoding", "gzip");

            client.SendAsync(Arg.Any <HttpRequestMessage>()).Returns(response);

            clientProvider.GetHttpClient(Arg.Any <string>(), Arg.Any <string>()).Returns(client);

            var bytes = new byte[] { 0, 1, 1, 0 };

            var intValue = proxyService.MakeCallWithReturn <int>("SomeNamespace", "SomeClass", "SomeMethod", bytes, false, true);

            Assert.Equal(10, intValue);

            client.Received().SendAsync(Arg.Is <HttpRequestMessage>(message => ValidateSomeClassSomeMethod(message)));
        }
Esempio n. 4
0
 public virtual void ReturnHttpClient(string @namespace, string className, IRpcHttpClient client)
 {
 }