Exemplo n.º 1
0
        public void TextSearchFakeTextSearchTest()
        {
            var request = new TextSearchRequest()
            {
                GenerateDocument = true,
                DocumentFormat   = DocumentType.Rtf,
                SaveToFolder     = new Folder(TestingFolder),
                SearchTerms      = new[] { new TextSearchRequest.SearchTerm()
                                           {
                                               Text = TestingString
                                           } }
            };
            var response = new TextSearchResponse();

            TestTextSearchService.ExecuteExtention(request, response, Controller);
            if (!response.Success)
            {
                throw new AssertFailedException("Response Contained Error", response.Exception);
            }
            if (response.ResponseItems.Any(r => r.Exception != null))
            {
                var ex = response.ResponseItems.First(r => r.Exception != null).Exception;
                throw new AssertFailedException(ex.DisplayString(), ex);
            }
        }
            public void OnSearchResult(Java.Lang.Object results)
            {
                TextSearchResponse ResultWrapper = (TextSearchResponse)results;
                IList <Site>       SiteList;

                if (ResultWrapper == null || ResultWrapper.TotalCount <= 0 || (SiteList = ResultWrapper.Sites) == null ||
                    SiteList.Count <= 0)
                {
                    ResultTextView.Text = "Result is Empty!";
                    return;
                }

                System.Text.StringBuilder ResultText = new System.Text.StringBuilder();
                ResultText.AppendLine("Success");
                int              count = 1;
                AddressDetail    addressDetail;
                Coordinate       location;
                Poi              poi;
                CoordinateBounds viewport;

                foreach (Site site in SiteList)
                {
                    addressDetail = site.Address;
                    location      = site.Location;
                    poi           = site.Poi;
                    viewport      = site.Viewport;
                    string item = "[{0}] siteId: '{1}', name: {2}, formatAddress: {3}, country: {4}, countryCode: {5}, location: {6}, poiTypes: {7}, viewport: {8} ";
                    ResultText.Append(string.Format(item,
                                                    (count++).ToString(), site.SiteId, site.Name, site.FormatAddress,
                                                    (addressDetail == null ? "" : addressDetail.Country),
                                                    (addressDetail == null ? "" : addressDetail.CountryCode),
                                                    (location == null ? "" : (location.Lat + "," + location.Lng)),
                                                    (poi == null ? "" : string.Join(",", poi.PoiTypes.ToArray())),
                                                    (viewport == null ? "" : "northeast{lat=" + viewport.Northeast.Lat + ", lng=" + viewport.Northeast.Lng + "},"
                                                     + "southwest{lat=" + viewport.Southwest.Lat + ", lng=" + viewport.Southwest.Lng + "}")));
                    if ((poi != null))
                    {
                        Gson   gson       = new Gson();
                        string jsonString = gson.ToJson(poi.GetChildrenNodes());
                        ResultText.Append(string.Format("childrenNode: {0} \n\n", jsonString));
                    }
                }
                ResultTextView.Text = ResultText.ToString();
                Log.Debug(KeywordSearchActivity.TAG, "OnTextSearchResult: " + ResultText.ToString());
            }
Exemplo n.º 3
0
            public void OnSearchResult(Java.Lang.Object resultObject)
            {
                TextSearchResponse textSearchResponse = (TextSearchResponse)resultObject;

                addSitesToResultTextView(textSearchResponse.Sites);
            }