Exemplo n.º 1
0
        private ISender BuildSender()
        {
            if (this.httpSender != null)
            {
                return(this.httpSender);
            }

            ISender sender = new NativeSender(this.maxTimeout, this.proxy);

            sender = new StatusCodeSender(sender);

            if (this.signer != null)
            {
                sender = new SigningSender(this.signer, sender);
            }

            sender = new URLPrefixSender(this.urlPrefix, sender);

            if (this.maxRetries > 0)
            {
                sender = new RetrySender(this.maxRetries, sender);
            }

            return(sender);
        }
        public async Task TestResponseReturnedCorrectlyAsync()
        {
            var expectedResponse = new Response(200, null);
            var mockSender       = new MockSender(expectedResponse);
            var sender           = new SigningSender(this.signer, mockSender);
            var result           = await sender.SendAsync(new Request());

            Assert.AreEqual(expectedResponse, result);
        }
Exemplo n.º 3
0
        public void TestResponseReturnedCorrectly()
        {
            var expectedResponse = new Response(200, null);
            var mockSender       = new MockSender(expectedResponse);
            var sender           = new SigningSender(this.signer, mockSender);

            Assert.AreEqual(
                expectedResponse,
                sender.Send(new Request()));
        }
Exemplo n.º 4
0
        public void TestResponseReturnedCorrectly()
        {
            var signer           = new StaticCredentials("id", "secret");
            var expectedResponse = new Response(200, null);
            var mockSender       = new MockSender(expectedResponse);
            var sender           = new SigningSender(signer, mockSender);

            var actualResponse = sender.Send(new Request("http://localhost/"));

            Assert.AreEqual(expectedResponse, actualResponse);
        }
Exemplo n.º 5
0
        public void TestSigningOfRequest()
        {
            var signer     = new StaticCredentials("id", "secret");
            var mockSender = new MockSender(null);
            var sender     = new SigningSender(signer, mockSender);

            sender.Send(new Request("http://localhost/"));

            var url = mockSender.Request.GetUrl();

            Assert.AreEqual("http://localhost/?auth-id=id&auth-token=secret", url);
        }
Exemplo n.º 6
0
        public void TestSigningOfRequest()
        {
            var mockSender      = new MockSender(null);
            var urlPrefixSender = new URLPrefixSender("http://localhost/", mockSender);
            var sender          = new SigningSender(this.signer, urlPrefixSender);

            sender.Send(new Request());

            Assert.AreEqual(
                "http://localhost/?auth-id=id&auth-token=secret",
                mockSender.Request.GetUrl());
        }