Ejemplo n.º 1
0
        public void ParseAsync_RandomInput()
        {
            var address = "My name is Bond, James Bond (but is that sentence really random ?).";

            var exception = Assert.ThrowsException <AggregateException>(() =>
            {
                using (IAddressParser parser = new GoogleAddressParser(ApiKey))
                {
                    parser.ParseAsync(address).Wait();
                }
            });

            Assert.IsInstanceOfType(exception.InnerException, typeof(AddressNotFoundException));
        }
Ejemplo n.º 2
0
        public void ParseAsync_WrongApiKey()
        {
            var address = "Champ de Mars, 5 Avenue Anatole France, 75007 Paris";

            var exception = Assert.ThrowsException <AggregateException>(() =>
            {
                using (IAddressParser parser = new GoogleAddressParser("abcdefghijklmnopqrstuvwxyz"))
                {
                    parser.ParseAsync(address).Wait();
                }
            });

            Assert.IsInstanceOfType(exception.InnerException, typeof(InvalidApiKeyException));
        }
Ejemplo n.º 3
0
        public void ParseAsync_NoDataLoss()
        {
            var address = "3947 W CLAREMONT ST PHOENIX 85019-1415";

            using (IAddressParser parser = new GoogleAddressParser(ApiKey))
            {
                var result = parser.ParseAsync(address).Result.FirstOrDefault();
                Assert.AreEqual(result.StreetNumber, "3947", true);
                Assert.AreEqual(result.Street, "West Claremont Street", true);
                Assert.AreEqual(result.Locality, "Phoenix", true);
                Assert.AreEqual(result.PostalCode, "85019", true);
                Assert.AreEqual(result.PostalCodeSuffix, "1415", true);
            }
        }