public void TestSendingSingleFullyPopulatedLookup() { var sender = new RequestCapturingSender(); var serializer = new FakeSerializer(null); var client = new Client(sender, serializer); var lookup = new Lookup { InputId = "1234", Addressee = "0", Street = "1", Secondary = "2", Street2 = "3", Urbanization = "4", City = "5", State = "6", ZipCode = "7", Lastline = "8", MaxCandidates = 9, MatchStrategy = "10" }; client.Send(lookup); Assert.AreEqual("?input_id=1234&street=1&street2=3&secondary=2&city=5&state=6&zipcode=7&" + "lastline=8&addressee=0&urbanization=4&match=10&candidates=9", sender.Request.GetUrl()); }
private static void AssertHeadersSetCorrectly(bool includeInvalid, bool standardizeOnly) { var sender = new RequestCapturingSender(); var client = new Client("http://localhost/", sender, new FakeSerializer(new byte[0])); var batch = new Batch(); batch.Add(new Lookup()); batch.StandardizeOnly = standardizeOnly; batch.IncludeInvalid = includeInvalid; client.Send(batch); var request = sender.Request; var headers = request.Headers; if (includeInvalid) { Assert.AreEqual("true", headers["X-Include-Invalid"]); Assert.IsFalse(headers.ContainsKey("X-Standardize-Only")); } else if (standardizeOnly) { Assert.AreEqual("true", headers["X-Standardize-Only"]); Assert.IsFalse(headers.ContainsKey("X-Include-Invalid")); } else { Assert.IsFalse(headers.ContainsKey("X-Standardize-Only")); Assert.IsFalse(headers.ContainsKey("X-Include-Invalid")); } }
public void TestEmptyBatchNotSent() { var sender = new RequestCapturingSender(); var client = new Client(sender, null); client.Send(new Batch()); Assert.Null(sender.Request); }
public async Task TestEmptyBatchNotSentAsync() { var sender = new RequestCapturingSender(); var client = new Client(sender, null); await client.SendAsync(new Batch()); Assert.Null(sender.Request); }
public void TestSendingSingleFreeformLookup() { var sender = new RequestCapturingSender(); var serializer = new FakeSerializer(null); var client = new Client(sender, serializer); client.Send(new Lookup("freeform")); Assert.AreEqual("?street=freeform", sender.Request.GetUrl()); }
public void TestSendingSingleZipOnlyLookup() { var sender = new RequestCapturingSender(); var serializer = new FakeSerializer(null); var client = new Client(sender, serializer); client.Send(new Lookup("1")); Assert.AreEqual("?zipcode=1", sender.Request.GetUrl()); }
public async Task TestSendingSingleFreeformLookupAsync() { var sender = new RequestCapturingSender(); var serializer = new FakeSerializer(null); var client = new Client("http://localhost/", sender, serializer); await client.SendAsync(new Lookup("freeform")); Assert.AreEqual("http://localhost/?street=freeform", sender.Request.GetUrl()); }
public async Task TestSendingSingleZipOnlyLookupAsync() { var sender = new RequestCapturingSender(); var serializer = new FakeSerializer(null); var client = new Client("http://localhost/", sender, serializer); await client.SendAsync(new Lookup("1")); Assert.AreEqual("http://localhost/?zipcode=1", sender.Request.GetUrl()); }
public void TestEmptyBatchNotSent() { var sender = new RequestCapturingSender(); var serializer = new FakeSerializer(null); var client = new Client("http://localhost/", sender, serializer); var batch = new Batch(); client.Send(batch); Assert.Null(sender.Request); }
public async Task TestEmptyBatchNotSentAsync() { var sender = new RequestCapturingSender(); var serializer = new FakeSerializer(null); var client = new Client(sender, serializer); var batch = new Batch(); await client.SendAsync(batch); Assert.Null(sender.Request); }
public async Task TestSuccessfullySendsBatchOfLookupsAsync() { var sender = new RequestCapturingSender(); var expectedPayload = Encoding.ASCII.GetBytes("Hello, world!"); var serializer = new FakeSerializer(expectedPayload); var client = new Client("http://localhost/", sender, serializer); var batch = new Batch { new Lookup(), new Lookup() }; await client.SendAsync(batch); Assert.AreEqual(expectedPayload, sender.Request.Payload); }
public void TestSuccessfullySendsBatchOfAddressLookups() { var sender = new RequestCapturingSender(); var expectedPayload = Encoding.ASCII.GetBytes("Hello World!"); var serializer = new FakeSerializer(expectedPayload); var client = new Client(sender, serializer); var batch = new Batch { new Lookup(), new Lookup() }; client.Send(batch); Assert.AreEqual(expectedPayload, sender.Request.Payload); }
public async Task TestSendingSingleFullyPopulatedLookupAsync() { var sender = new RequestCapturingSender(); var serializer = new FakeSerializer(null); var client = new Client("http://localhost/", sender, serializer); var lookup = new Lookup(); lookup.City = "1"; lookup.State = "2"; lookup.ZipCode = "3"; await client.SendAsync(lookup); Assert.AreEqual("http://localhost/?city=1&state=2&zipcode=3", sender.Request.GetUrl()); }
public void TestSendingSingleFullyPopulatedLookup() { var sender = new RequestCapturingSender(); var serializer = new FakeSerializer(null); var client = new Client(sender, serializer); var lookup = new Lookup { City = "1", State = "2", ZipCode = "3" }; client.Send(lookup); Assert.AreEqual("?city=1&state=2&zipcode=3", sender.Request.GetUrl()); }
public void TestAcceptsLookupsWithEnoughInfo() { var capturingSender = new RequestCapturingSender(); var serializer = new FakeSerializer(null); var client = new Client(capturingSender, serializer); var lookup = new Lookup(); lookup.Country = "0"; lookup.Freeform = "1"; client.Send(lookup); lookup.Freeform = null; lookup.Address1 = "1"; lookup.PostalCode = "2"; client.Send(lookup); lookup.PostalCode = null; lookup.Locality = "3"; lookup.AdministrativeArea = "4"; client.Send(lookup); }
public async Task TestSendingSingleFullyPopulatedLookupAsync() { var sender = new RequestCapturingSender(); var serializer = new FakeSerializer(null); var client = new Client("http://localhost/", sender, serializer); var lookup = new Lookup { Addressee = "0", Street = "1", Secondary = "2", Street2 = "3", Urbanization = "4", City = "5", State = "6", ZipCode = "7", Lastline = "8", MaxCandidates = 9 }; await client.SendAsync(lookup); Assert.AreEqual("http://localhost/?street=1&street2=3&secondary=2&city=5&state=6&zipcode=7&lastline=8&addressee=0&urbanization=4&candidates=9", sender.Request.GetUrl()); }
public void Setup() { this.capturingSender = new RequestCapturingSender(); this.urlSender = new URLPrefixSender("http://localhost/", this.capturingSender); }