コード例 #1
0
        public void GetQueryStringParametersWhenCoordinateTest()
        {
            var request = new PlusCodeGeocodeRequest
            {
                Key     = "abc",
                Address = new Entities.Maps.Geocoding.PlusCode.Request.Location(new Coordinate(1, 1))
            };

            var queryStringParameters = request.GetQueryStringParameters();

            Assert.IsNotNull(queryStringParameters);

            var key         = queryStringParameters.SingleOrDefault(x => x.Key == "key");
            var keyExpected = request.Key;

            Assert.IsNotNull(key);
            Assert.AreEqual(keyExpected, key.Value);

            var language         = queryStringParameters.SingleOrDefault(x => x.Key == "language");
            var languageExpected = request.Language.ToCode();

            Assert.IsNotNull(language);
            Assert.AreEqual(languageExpected, language.Value);

            var address         = queryStringParameters.SingleOrDefault(x => x.Key == "address");
            var addressExpected = request.Address.ToString();

            Assert.IsNotNull(address);
            Assert.AreEqual(addressExpected, address.Value);
        }
コード例 #2
0
        public void GetQueryStringParametersWhenKeyIsNullTest()
        {
            var request = new PlusCodeGeocodeRequest
            {
                Address = new Entities.Maps.Geocoding.PlusCode.Request.Location(new Coordinate(1, 1))
            };

            Assert.DoesNotThrow(() => request.GetQueryStringParameters());
        }
コード例 #3
0
        public void GetQueryStringParametersTest()
        {
            var request = new PlusCodeGeocodeRequest
            {
                Key     = "abc",
                PlaceId = "abc"
            };

            Assert.DoesNotThrow(() => request.GetQueryStringParameters());
        }
コード例 #4
0
        public void GetQueryStringParametersWhenAddressIsNullTest()
        {
            var request = new PlusCodeGeocodeRequest
            {
                Key = "key"
            };

            var exception = Assert.Throws <ArgumentException>(() =>
            {
                var parameters = request.GetQueryStringParameters();
                Assert.IsNull(parameters);
            });

            Assert.IsNotNull(exception);
            Assert.AreEqual(exception.Message, "Address is required");
        }
コード例 #5
0
        public void GetQueryStringParametersWhenPlaceIdAndLocationAndAddressAndGlobalCodeIsNullTest()
        {
            var request = new PlusCodeGeocodeRequest
            {
                Key = "abc"
            };

            var exception = Assert.Throws <ArgumentException>(() =>
            {
                var parameters = request.GetQueryStringParameters();
                Assert.IsNull(parameters);
            });

            Assert.IsNotNull(exception);
            Assert.AreEqual(exception.Message, "PlaceId, Location, Address or GlobalCode is required");
        }
コード例 #6
0
        public void GetQueryStringParametersWhenLocalCodeAndLocalityTest()
        {
            var request = new PlusCodeGeocodeRequest
            {
                Key     = "abc",
                Address = new Entities.Maps.Geocoding.PlusCode.Request.Location(new LocalCodeAndLocality("local_code", "locality"))
            };

            var queryStringParameters = request.GetQueryStringParameters();

            Assert.IsNotNull(queryStringParameters);

            var address         = queryStringParameters.SingleOrDefault(x => x.Key == "address");
            var addressExpected = request.Address.ToString();

            Assert.IsNotNull(address);
            Assert.AreEqual(addressExpected, address.Value);
        }
コード例 #7
0
        public void GetQueryStringParametersWhenEmailTest()
        {
            var request = new PlusCodeGeocodeRequest
            {
                Key     = "abc",
                Address = new Entities.Maps.Geocoding.PlusCode.Request.Location(new Coordinate(1, 1)),
                Email   = "email"
            };

            var queryStringParameters = request.GetQueryStringParameters();

            Assert.IsNotNull(queryStringParameters);

            var email         = queryStringParameters.SingleOrDefault(x => x.Key == "email");
            var emailExpected = request.Email;

            Assert.IsNotNull(email);
            Assert.AreEqual(emailExpected, email.Value);
        }
コード例 #8
0
        public void GetQueryStringParametersWhenUseEncryptedKeyTest()
        {
            var request = new PlusCodeGeocodeRequest
            {
                Key             = "abc",
                Address         = new Entities.Maps.Geocoding.PlusCode.Request.Location(new Coordinate(1, 1)),
                UseEncryptedKey = true
            };

            var queryStringParameters = request.GetQueryStringParameters();

            Assert.IsNotNull(queryStringParameters);

            var key         = queryStringParameters.SingleOrDefault(x => x.Key == "ekey");
            var keyExpected = request.Key;

            Assert.IsNotNull(key);
            Assert.AreEqual(keyExpected, key.Value);
        }