Ejemplo n.º 1
0
 private static BossResponse OAuthFind(PlaceByMultilineAddress request, string consumerKey, string consumerSecret, int retry = 0)
 {
     try
     {
         using (var oAuth = new OAuthClient())
         {
             var json          = oAuth.Get(request.GetUri(), consumerKey, consumerSecret);
             var bossContainer = JsonConvert.DeserializeObject <BossContainer>(json);
             if (bossContainer != null)
             {
                 return(bossContainer.BossResponse);
             }
             throw new InvalidOperationException("Unable to parse BOSS GEO Response. Raw JSON:\r\n" + json);
         }
     }
     catch (ProtocolException ex)
     {
         if (retry < RetryLimit && ex.InnerException is WebException)
         {
             return(OAuthFind(request, consumerKey, consumerSecret, ++retry));
         }
         throw;
     }
     catch (CommunicationException ex)
     {
         if (retry < RetryLimit && ex.Message == "Server Error")
         {
             return(OAuthFind(request, consumerKey, consumerSecret, ++retry));
         }
         throw;
     }
 }
        public void Yahoo_PlaceFinder_PlaceByMultilineAddress_ShouldConstructWithLine1()
        {
            var it = new PlaceByMultilineAddress("line 1");

            it.ShouldNotBeNull();
            it.Line1.ShouldEqual("line 1");
        }
        public void Yahoo_PlaceFinder_PlaceByMultilineAddress_ShouldConstructWithLine1()
        {
            var it = new PlaceByMultilineAddress("line 1");

            it.ShouldNotBeNull();
            it.Line1.ShouldEqual("line 1");
        }
Ejemplo n.º 4
0
 private Response ChannelFindByMultilineAddress(PlaceByMultilineAddress request, int retry = 0)
 {
     try
     {
         return(Channel.FindByMultilineAddress(request.Line1,
                                               request.Line2, request.Line3, request.Locale,
                                               request.Start, request.Count, request.Offset,
                                               request.GetFlagsAsString(), request.GetGFlagsAsString(),
                                               request.AppId));
     }
     catch (ProtocolException ex)
     {
         if (retry < RetryLimit && ex.InnerException is WebException)
         {
             return(ChannelFindByMultilineAddress(request, ++retry));
         }
         throw;
     }
     catch (CommunicationException ex)
     {
         if (retry < RetryLimit && ex.Message == "Server Error")
         {
             return(ChannelFindByMultilineAddress(request, ++retry));
         }
         throw;
     }
 }
Ejemplo n.º 5
0
        public ResultSet Find(PlaceByMultilineAddress request, string consumerKey, string consumerSecret)
        {
            if (request == null) throw new ArgumentNullException("request");
            EnsureContractsAreSatisfied(request);

            var response = OAuthFind(request, consumerKey, consumerSecret);
            return response.PlaceFinder;
        }
Ejemplo n.º 6
0
        public void Yahoo_PlaceFinder_PlaceBy_ShouldPreserveLocale()
        {
            var it = new PlaceByMultilineAddress("line 1")
            {
                Locale = "locale"
            };

            it.ShouldNotBeNull();
            it.Locale.ShouldEqual("locale");
        }
Ejemplo n.º 7
0
        public void Yahoo_PlaceFinder_PlaceBy_ShouldPreserveLocale()
        {
            var it = new PlaceByMultilineAddress("line 1")
            {
                Locale = "locale"
            };

            it.ShouldNotBeNull();
            it.Locale.ShouldEqual("locale");
        }
Ejemplo n.º 8
0
        public void Yahoo_PlaceFinder_PlaceBy_ShouldSerializeFlags()
        {
            var request = new PlaceByMultilineAddress("line 1");

            request.Flags.Add(Flag.Airport);
            request.Flags.Add(Flag.TelephoneAreaCode);
            var flags = request.GetFlagsAsString();

            flags.ShouldEqual("QR");
        }
Ejemplo n.º 9
0
        public ResultSet Find(PlaceByMultilineAddress request, string consumerKey, string consumerSecret)
        {
            if (request == null)
            {
                throw new ArgumentNullException("request");
            }
            EnsureContractsAreSatisfied(request);

            var response = OAuthFind(request, consumerKey, consumerSecret);

            return(response.PlaceFinder);
        }
Ejemplo n.º 10
0
        public void Yahoo_PlaceFinder_PlaceFinderClient_FindByMultilineAddress_ShouldReturn1Result_ForYahooExample1()
        {
            using (var client = new PlaceFinderClient())
            {
                var request = new PlaceByMultilineAddress("701 First Ave.");

                var results = client.Find(request);
                results.ShouldNotBeNull();
                results.Results.ShouldNotBeNull();
                results.Results.Count.ShouldEqual(1);
            }
        }
Ejemplo n.º 11
0
        internal static Uri GetUri(this PlaceByMultilineAddress request)
        {
            const string template = "line1={line1}&line2={line2}&line3={line3}";

            var urlBuilder = new StringBuilder(GetBaseUrl(request, template));

            urlBuilder.Replace("{line1}", request.Line1);
            urlBuilder.Replace("{line2}", request.Line2);
            urlBuilder.Replace("{line3}", request.Line3);

            return(new Uri(urlBuilder.ToString()));
        }
Ejemplo n.º 12
0
        public ResultSet Find(PlaceByMultilineAddress request)
        {
            if (request == null)
            {
                throw new ArgumentNullException("request");
            }
            EnsureContractsAreSatisfied(request);

            var response = ChannelFindByMultilineAddress(request);

            return(response.ResultSet);
        }
Ejemplo n.º 13
0
        public void Yahoo_PlaceFinder_PlaceFinderClient_FindByMultilineAddress_ShouldReturn1Result_ForYahooExample1()
        {
            using (var client = new PlaceFinderClient())
            {
                var request = new PlaceByMultilineAddress("701 First Ave.");

                var results = client.Find(request, ConsumerKey, ConsumerSecret);
                results.ShouldNotBeNull();
                results.Results.ShouldNotBeNull();
                results.Count.ShouldBeInRange(1, int.MaxValue);
            }
        }
        public void Yahoo_PlaceFinder_PlaceByMultilineAddress_ShouldAllowLinesToBeChanged_AfterConstruction()
        {
            var it = new PlaceByMultilineAddress("line 1", "line 2", "line 3")
            {
                Line1 = "other line 1",
                Line2 = "other line 2",
                Line3 = "other line 3",
            };

            it.ShouldNotBeNull();
            it.Line1.ShouldEqual("other line 1");
            it.Line2.ShouldEqual("other line 2");
            it.Line3.ShouldEqual("other line 3");
        }
        public void Yahoo_PlaceFinder_PlaceByMultilineAddress_ShouldAllowLinesToBeChanged_AfterConstruction()
        {
            var it = new PlaceByMultilineAddress("line 1", "line 2", "line 3")
            {
                Line1 = "other line 1",
                Line2 = "other line 2",
                Line3 = "other line 3",
            };

            it.ShouldNotBeNull();
            it.Line1.ShouldEqual("other line 1");
            it.Line2.ShouldEqual("other line 2");
            it.Line3.ShouldEqual("other line 3");
        }
Ejemplo n.º 16
0
        public void Yahoo_PlaceFinder_PlaceFinderClient_FindByMultilineAddress_ShouldReturn1Result_ForYahooExample1()
        {
            using (var client = new PlaceFinderClient())
            {
                var request = new PlaceByMultilineAddress("701 First Ave.");

                var results = client.Find(request);
                results.ShouldNotBeNull();
                results.Results.ShouldNotBeNull();
                results.Results.Count.ShouldEqual(1);
            }
        }
        public void Yahoo_PlaceFinder_PlaceFinderClient_FindByMultilineAddress_ShouldReturn1Result_ForYahooExample1()
        {
            using (var client = new PlaceFinderClient())
            {
                var request = new PlaceByMultilineAddress("701 First Ave.");

                var results = client.Find(request, ConsumerKey, ConsumerSecret);
                results.ShouldNotBeNull();
                results.Results.ShouldNotBeNull();
                results.Count.ShouldBeInRange(1, int.MaxValue);
            }
        }
Ejemplo n.º 18
0
 private static BossResponse OAuthFind(PlaceByMultilineAddress request, string consumerKey, string consumerSecret, int retry = 0)
 {
     try
     {
         using (var oAuth = new OAuthClient())
         {
             var json = oAuth.Get(request.GetUri(), consumerKey, consumerSecret);
             var bossContainer = JsonConvert.DeserializeObject<BossContainer>(json);
             if (bossContainer != null) return bossContainer.BossResponse;
             throw new InvalidOperationException("Unable to parse BOSS GEO Response. Raw JSON:\r\n" + json);
         }
     }
     catch (ProtocolException ex)
     {
         if (retry < RetryLimit && ex.InnerException is WebException)
             return OAuthFind(request, consumerKey, consumerSecret, ++retry);
         throw;
     }
     catch (CommunicationException ex)
     {
         if (retry < RetryLimit && ex.Message == "Server Error")
             return OAuthFind(request, consumerKey, consumerSecret, ++retry);
         throw;
     }
 }
Ejemplo n.º 19
0
 public void Yahoo_PlaceFinder_PlaceBy_ShouldSerializeFlags()
 {
     var request = new PlaceByMultilineAddress("line 1");
     request.Flags.Add(Flag.Airport);
     request.Flags.Add(Flag.TelephoneAreaCode);
     var flags = request.GetFlagsAsString();
     flags.ShouldEqual("QR");
 }