Beispiel #1
0
        public async Task GetHierarchy_UsLocation_USA_047613959N_122320833W()
        {
            var request = new HierarchyRequest()
            {
                GeoNameId = 5789123,
                Style     = Style.FULL
            };
            var response = await GeoNameService.GetHierarchy(request);

            response.ShouldNotBeNull();
            response.Items.ShouldNotBeNull();
            response.Items.Length.ShouldEqual(6);
            response.ShouldBeType <GeoNameResponse>();

            var toponymResponse = response as GeoNameResponse;

            toponymResponse.ShouldNotBeNull();
            toponymResponse.Items.Length.ShouldEqual(6);

            toponymResponse.Items[0].TopynymId.ShouldEqual(6295630);
            toponymResponse.Items[1].TopynymId.ShouldEqual(6255149);
            toponymResponse.Items[2].TopynymId.ShouldEqual(6252001);
            toponymResponse.Items[3].TopynymId.ShouldEqual(5815135);
            toponymResponse.Items[4].TopynymId.ShouldEqual(5799783);
            toponymResponse.Items[5].TopynymId.ShouldEqual(5789123);
        }
Beispiel #2
0
        public async Task GetHierarchy_EuropeanLocation_047300000N_09000000E()
        {
            var request = new HierarchyRequest()
            {
                GeoNameId = 7910950,
                Style     = Style.FULL
            };
            var response = await GeoNameService.GetHierarchy(request);

            response.ShouldNotBeNull();
            response.Items.ShouldNotBeNull();
            response.Items.Length.ShouldEqual(8);
            response.ShouldBeType <GeoNameResponse>();

            var toponymResponse = response as GeoNameResponse;

            toponymResponse.ShouldNotBeNull();
            toponymResponse.Items.Length.ShouldEqual(8);

            toponymResponse.Items[0].TopynymId.ShouldEqual(6295630);
            toponymResponse.Items[1].TopynymId.ShouldEqual(6255148);
            toponymResponse.Items[2].TopynymId.ShouldEqual(2658434);
            toponymResponse.Items[3].TopynymId.ShouldEqual(2658821);
            toponymResponse.Items[4].TopynymId.ShouldEqual(7285001);
            toponymResponse.Items[5].TopynymId.ShouldEqual(7286562);
            toponymResponse.Items[6].TopynymId.ShouldEqual(6559633);
            toponymResponse.Items[7].TopynymId.ShouldEqual(7910950);
        }
 public async Task <TreeResult> Hierarchy([FromUri] HierarchyRequest request)
 {
     if (request == null)
     {
         return(null);
     }
     return(await this.ServiceImpl.Hierarchy(request.Id, request.Cc, request.DeepLevel));
 }
Beispiel #4
0
        public async Task GetHierarchy_NoUserName()
        {
            var request = new HierarchyRequest()
            {
                UserName  = "",
                GeoNameId = 7910950,
                Style     = Style.FULL
            };
            var response = await GeoNameService.GetHierarchy(request);

            response.ShouldNotBeNull();
            response.Items.ShouldBeNull();
            response.ShouldBeType <ErrorResponse>();

            var errorResponse = response as ErrorResponse;

            errorResponse.ShouldNotBeNull();
            errorResponse.Exception.ShouldNotBeNull();
            errorResponse.Exception.Message.ShouldNotBeNull();
            errorResponse.Exception.ErrorCode.ShouldEqual(10);
        }
Beispiel #5
0
 public static Task <IGeoNameResponse> Execute(this HierarchyRequest request, int maxTries = 1)
 {
     return(GeoNameService.GetHierarchy(request, maxTries));
 }
Beispiel #6
0
 public static async Task <IGeoNameResponse> GetHierarchy(HierarchyRequest request, int maxTries = 1)
 {
     return(await GetQueryResponseAsync(C_Svc_Hierarchy, request, CreateHierarchyQueryResponse, maxTries, 0));
 }