Exemple #1
0
        public void GetUriTest()
        {
            var request = new AddressGeocodeRequest
            {
                Key     = "abc",
                Address = "abc"
            };

            var uri = request.GetUri();

            Assert.IsNotNull(uri);
            Assert.AreEqual($"/maps/api/geocode/json?key={request.Key}&language={request.Language.ToCode()}&address={Uri.EscapeDataString(request.Address)}", uri.PathAndQuery);
        }
        public void GetUriWhenComponentsTest()
        {
            var request = new AddressGeocodeRequest
            {
                Key        = "abc",
                Components = new []
                {
                    new KeyValuePair <Component, string>(Component.Administrative_Area, "abc"),
                    new KeyValuePair <Component, string>(Component.Locality, "def")
                }
            };

            var uri = request.GetUri();

            Assert.IsNotNull(uri);
            Assert.AreEqual($"/maps/api/geocode/json?key={request.Key}&language={request.Language.ToCode()}&components={Uri.EscapeDataString(string.Join("|", request.Components.Select(x => $"{x.Key.ToString().ToLower()}:{x.Value}")))}", uri.PathAndQuery);
        }
Exemple #3
0
        public void GetUriWhenBoundsTest()
        {
            var request = new AddressGeocodeRequest
            {
                Key     = "abc",
                Address = "abc",
                Bounds  = new ViewPort
                {
                    SouthWest = new Entities.Common.Location(1, 1),
                    NorthEast = new Entities.Common.Location(1, 1)
                }
            };

            var uri = request.GetUri();

            Assert.IsNotNull(uri);
            Assert.AreEqual($"/maps/api/geocode/json?key={request.Key}&language={request.Language.ToCode()}&address={Uri.EscapeDataString(request.Address)}&bounds={Uri.EscapeDataString(request.Bounds.NorthEast.ToString())}{Uri.EscapeDataString("|")}{Uri.EscapeDataString(request.Bounds.SouthWest.ToString())}", uri.PathAndQuery);
        }