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 void TestLicensesNotAdded() { var mockSender = new MockSender(null); var urlPrefixSender = new URLPrefixSender("http://localhost/", mockSender); var sender = new LicenseSender(new List <string>(), urlPrefixSender); sender.Send(new Request()); Assert.False(mockSender.Request.GetUrl().Contains("license=")); }
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()); }
public void TestAddingLicenses() { var licenses = new List <string> { "one", "two", "three" }; var mockSender = new MockSender(null); var urlPrefixSender = new URLPrefixSender("http://localhost/", mockSender); var sender = new LicenseSender(licenses, urlPrefixSender); sender.Send(new Request()); Assert.AreEqual("license=one%2Ctwo%2Cthree", mockSender.Request.GetUrl().Split("?")[1]); }
public void TestAddingHeaders() { var headers = new Dictionary <string, string> { ["Test1"] = "value1", ["Test2"] = "value2" }; var mockSender = new MockSender(null); var urlPrefixSender = new URLPrefixSender("http://localhost/", mockSender); var sender = new CustomHeaderSender(headers, urlPrefixSender); sender.Send(new Request()); Assert.AreEqual("value1", mockSender.Request.Headers["Test1"]); Assert.AreEqual("value2", mockSender.Request.Headers["Test2"]); }