diff --git a/build.cake b/build.cake index 8c8ae7f..f78b2b6 100644 --- a/build.cake +++ b/build.cake @@ -9,7 +9,7 @@ var target = Argument("target", "Default"); var configuration = Argument("configuration", "Release"); var solution = "./Anywhere.ArcGIS.sln"; -var version = "1.11.0"; +var version = "1.11.1"; var versionSuffix = Environment.GetEnvironmentVariable("VERSION_SUFFIX"); ////////////////////////////////////////////////////////////////////// diff --git a/src/Anywhere.ArcGIS/Anywhere.ArcGIS.csproj b/src/Anywhere.ArcGIS/Anywhere.ArcGIS.csproj index 3d806bf..d76b852 100644 --- a/src/Anywhere.ArcGIS/Anywhere.ArcGIS.csproj +++ b/src/Anywhere.ArcGIS/Anywhere.ArcGIS.csproj @@ -15,7 +15,7 @@ https://github.com/davetimmins/Anywhere.ArcGIS git ArcGIS ArcGISServer ArcGISOnline Esri REST netstandard anywhere GIS Mapping Map Location GeoLocation OAuth - 1.11.0 + 1.11.1 LICENSE @@ -24,18 +24,17 @@ - + all runtime; build; native; contentfiles; analyzers - + - diff --git a/src/Anywhere.ArcGIS/PortalGatewayBase.cs b/src/Anywhere.ArcGIS/PortalGatewayBase.cs index 425d2f2..35f1883 100644 --- a/src/Anywhere.ArcGIS/PortalGatewayBase.cs +++ b/src/Anywhere.ArcGIS/PortalGatewayBase.cs @@ -677,15 +677,7 @@ protected async Task Get(TRequest requestObject, CancellationTok var endpoint = requestObject.Endpoint; var url = endpoint.BuildAbsoluteUrl(RootUrl) + AsRequestQueryString(Serializer, requestObject); - - if (url.Length > MaximumGetRequestLength) - { - _logger.DebugFormat("Url length {0} is greater than maximum configured {1}, switching to POST.", url.Length, MaximumGetRequestLength); - return await Post(requestObject, ct).ConfigureAwait(false); - } - - requestObject.BeforeRequest?.Invoke(); - + var token = await CheckGenerateToken(ct).ConfigureAwait(false); if (ct.IsCancellationRequested) { @@ -700,6 +692,7 @@ protected async Task Get(TRequest requestObject, CancellationTok if (token != null && !string.IsNullOrWhiteSpace(token.Value) && !url.Contains("token=")) { url += (url.Contains("?") ? "&" : "?") + "token=" + token.Value; + requestObject.Token = token.Value; _httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(token.Value); if (token.AlwaysUseSsl) { @@ -712,7 +705,15 @@ protected async Task Get(TRequest requestObject, CancellationTok { throw new HttpRequestException(string.Format("Not a valid url: {0}", url)); } + + if (url.Length > MaximumGetRequestLength) + { + _logger.DebugFormat("Url length {0} is greater than maximum configured {1}, switching to POST.", url.Length, MaximumGetRequestLength); + return await Post(requestObject, ct).ConfigureAwait(false); + } + _logger.DebugFormat("GET {0}", uri.AbsoluteUri); + requestObject.BeforeRequest?.Invoke(); if (CancelPendingRequests) { diff --git a/tests/Anywhere.ArcGIS.Test.Integration/Anywhere.ArcGIS.Test.Integration.csproj b/tests/Anywhere.ArcGIS.Test.Integration/Anywhere.ArcGIS.Test.Integration.csproj index 6ec7be9..fcaa842 100644 --- a/tests/Anywhere.ArcGIS.Test.Integration/Anywhere.ArcGIS.Test.Integration.csproj +++ b/tests/Anywhere.ArcGIS.Test.Integration/Anywhere.ArcGIS.Test.Integration.csproj @@ -5,12 +5,15 @@ - - - - - - + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/tests/Anywhere.ArcGIS.Test.Integration/ArcGISGatewayTests.cs b/tests/Anywhere.ArcGIS.Test.Integration/ArcGISGatewayTests.cs index 4c1aaf1..2445ee8 100644 --- a/tests/Anywhere.ArcGIS.Test.Integration/ArcGISGatewayTests.cs +++ b/tests/Anywhere.ArcGIS.Test.Integration/ArcGISGatewayTests.cs @@ -56,7 +56,7 @@ public async Task CanPingServer(string rootUrl) var gateway = new PortalGateway(rootUrl); var endpoint = new ArcGISServerEndpoint("/"); - var response = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var response = await IntegrationTestFixture.TestPolicy.Execute(() => { return gateway.Ping(endpoint); }); @@ -72,7 +72,7 @@ public async Task CanGetServerInfo(string rootUrl) { var gateway = new PortalGateway(rootUrl); - var response = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var response = await IntegrationTestFixture.TestPolicy.Execute(() => { return gateway.Info(); }); @@ -88,7 +88,7 @@ public async Task CanGetServerInfo(string rootUrl) public async Task CanDescribeSite(string rootUrl) { var gateway = new PortalGateway(rootUrl); - var response = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var response = await IntegrationTestFixture.TestPolicy.Execute(() => { return gateway.DescribeSite(); }); @@ -98,7 +98,7 @@ public async Task CanDescribeSite(string rootUrl) foreach (var resource in response.ArcGISServerEndpoints.Where(e => e.RelativeUrl.EndsWith("server", StringComparison.OrdinalIgnoreCase) && !e.RelativeUrl.EndsWith("searchserver", StringComparison.OrdinalIgnoreCase))) { - var ping = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var ping = await IntegrationTestFixture.TestPolicy.Execute(() => { return gateway.Ping(resource); }); @@ -112,7 +112,7 @@ public async Task CanDescribeSite(string rootUrl) public async Task CanDescribeSiteServices(string rootUrl) { var gateway = new PortalGateway(rootUrl); - var siteResponse = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var siteResponse = await IntegrationTestFixture.TestPolicy.Execute(() => { return gateway.DescribeSite(); }); @@ -120,7 +120,7 @@ public async Task CanDescribeSiteServices(string rootUrl) Assert.NotNull(siteResponse); Assert.True(siteResponse.Version > 0); - var response = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var response = await IntegrationTestFixture.TestPolicy.Execute(() => { return gateway.DescribeServices(siteResponse); }); @@ -138,7 +138,7 @@ public async Task CanGetServiceTileInfo(string rootUrl, string serviceId) { var gateway = new PortalGateway(rootUrl); - var response = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var response = await IntegrationTestFixture.TestPolicy.Execute(() => { return gateway.DescribeService(serviceId.AsEndpoint()); }); @@ -163,7 +163,7 @@ public async Task CanGetServiceTileInfo(string rootUrl, string serviceId) public async Task CanDescribeLayer(string rootUrl, string layerUrl) { var gateway = new PortalGateway(rootUrl); - var layerResponse = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var layerResponse = await IntegrationTestFixture.TestPolicy.Execute(() => { return gateway.DescribeLayer(layerUrl.AsEndpoint()); }); @@ -178,7 +178,7 @@ public async Task CanDescribeLayer(string rootUrl, string layerUrl) public async Task CanDescribeLegend(string rootUrl, string mapUrl) { var gateway = new PortalGateway(rootUrl); - var layerResponse = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var layerResponse = await IntegrationTestFixture.TestPolicy.Execute(() => { return gateway.DescribeLegends(mapUrl.AsEndpoint()); }); @@ -202,7 +202,7 @@ public async Task CanDescribeLegend2(string rootUrl, string mapUrl, int? dpi, in request.Size.Add(size.Value); request.Size.Add(size.Value); } - var layerResponse = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var layerResponse = await IntegrationTestFixture.TestPolicy.Execute(() => { return gateway.DescribeLegends(request); }); @@ -225,7 +225,7 @@ public async Task GatewayDoesAutoPost() var query = new Query(@"/Earthquakes/EarthquakesFromLastSevenDays/MapServer/0") { Where = longWhere + "'" }; - var result = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var result = await IntegrationTestFixture.TestPolicy.Execute(() => { return gateway.Query(query); }); @@ -244,7 +244,7 @@ public async Task GatewayDoesAutoPostForMaximumGetRequestLength() var query = new Query(@"/Earthquakes/EarthquakesFromLastSevenDays/MapServer/0".AsEndpoint()); - var result = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var result = await IntegrationTestFixture.TestPolicy.Execute(() => { return gateway.Query(query); }); @@ -280,7 +280,7 @@ private async Task QueryCanGetBatchFeatures(string rootUrl, string relativeUr ReturnGeometry = returnGeometry }; - var result = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var result = await IntegrationTestFixture.TestPolicy.Execute(() => { return gateway.BatchQuery(query); }); @@ -309,7 +309,7 @@ public async Task QueryCanReturnPointFeatures(string rootUrl, string relativeUrl var gateway = new PortalGateway(rootUrl); var query = new Query(relativeUrl); - var result = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var result = await IntegrationTestFixture.TestPolicy.Execute(() => { return gateway.Query(query); }); @@ -329,7 +329,7 @@ public async Task QueryCanReturnDifferentGeometryTypes() var gateway = new ArcGISGateway(); var queryPoint = new Query(@"Earthquakes/EarthquakesFromLastSevenDays/MapServer/0".AsEndpoint()) { Where = "magnitude > 2.5" }; - var resultPoint = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var resultPoint = await IntegrationTestFixture.TestPolicy.Execute(() => { return gateway.QueryAsPost(queryPoint); }); @@ -338,7 +338,7 @@ public async Task QueryCanReturnDifferentGeometryTypes() Assert.True(resultPoint.Features.All(i => i.Geometry != null)); var queryPolyline = new Query(@"Hydrography/Watershed173811/MapServer/1".AsEndpoint()) { OutFields = new List { "lengthkm" } }; - var resultPolyline = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var resultPolyline = await IntegrationTestFixture.TestPolicy.Execute(() => { return gateway.Query(queryPolyline); }); @@ -349,7 +349,7 @@ public async Task QueryCanReturnDifferentGeometryTypes() gateway = new ArcGISGateway(); var queryPolygon = new Query(@"/Hydrography/Watershed173811/MapServer/0") { Where = "areasqkm = 0.012", OutFields = new List { "areasqkm" } }; - var resultPolygon = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var resultPolygon = await IntegrationTestFixture.TestPolicy.Execute(() => { return gateway.QueryAsPost(queryPolygon); }); @@ -364,7 +364,7 @@ public async Task QueryCanReturnNoGeometry() var gateway = new ArcGISGateway(); var queryPoint = new Query(@"Earthquakes/EarthquakesFromLastSevenDays/MapServer/0".AsEndpoint()) { ReturnGeometry = false }; - var resultPoint = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var resultPoint = await IntegrationTestFixture.TestPolicy.Execute(() => { return gateway.Query(queryPoint); }); @@ -373,7 +373,7 @@ public async Task QueryCanReturnNoGeometry() Assert.True(resultPoint.Features.All(i => i.Geometry == null)); var queryPolyline = new Query(@"Hydrography/Watershed173811/MapServer/1") { OutFields = new List { "lengthkm" }, ReturnGeometry = false }; - var resultPolyline = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var resultPolyline = await IntegrationTestFixture.TestPolicy.Execute(() => { return gateway.QueryAsPost(queryPolyline); }); @@ -393,7 +393,7 @@ public async Task QueryCanUseWhereClause() Where = "UPPER(Name) LIKE UPPER('New Zea%')" }; queryPoint.OutFields.Add("Name"); - var resultPoint = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var resultPoint = await IntegrationTestFixture.TestPolicy.Execute(() => { return gateway.Query(queryPoint); }); @@ -409,7 +409,7 @@ public async Task QueryObjectIdsAreHonored() var gateway = new ArcGISGateway(); var queryPoint = new Query(@"Earthquakes/EarthquakesFromLastSevenDays/MapServer/0") { ReturnGeometry = false }; - var resultPoint = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var resultPoint = await IntegrationTestFixture.TestPolicy.Execute(() => { return gateway.Query(queryPoint); }); @@ -422,7 +422,7 @@ public async Task QueryObjectIdsAreHonored() ReturnGeometry = false, ObjectIds = resultPoint.Features.Take(10).Select(f => long.Parse(f.Attributes[resultPoint.ObjectIdFieldName ?? "objectid"].ToString())).ToList() }; - var resultPointByOID = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var resultPointByOID = await IntegrationTestFixture.TestPolicy.Execute(() => { return gateway.Query(queryPointByOID); }); @@ -440,7 +440,7 @@ public async Task QueryOutFieldsAreHonored() var gateway = new ArcGISGateway(); var queryPolyline = new Query(@"Hydrography/Watershed173811/MapServer/1".AsEndpoint()) { OutFields = new List { "lengthkm" }, ReturnGeometry = false }; - var resultPolyline = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var resultPolyline = await IntegrationTestFixture.TestPolicy.Execute(() => { return gateway.Query(queryPolyline); }); @@ -454,7 +454,7 @@ public async Task QueryOutFieldsAreHonored() Where = "areasqkm = 0.012", OutFields = new List { "areasqkm", "elevation", "resolution", "reachcode" } }; - var resultPolygon = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var resultPolygon = await IntegrationTestFixture.TestPolicy.Execute(() => { return gateway.Query(queryPolygon); }); @@ -476,7 +476,7 @@ public async Task QueryOrderByIsHonored(string rootUrl, string relativeUrl, stri ReturnGeometry = false, Where = "CITY = 'WA'" }; - var result = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var result = await IntegrationTestFixture.TestPolicy.Execute(() => { return gateway.Query(query); }); @@ -487,7 +487,7 @@ public async Task QueryOrderByIsHonored(string rootUrl, string relativeUrl, stri ReturnGeometry = false, Where = "CITY = 'WA'" }; - var resultDesc = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var resultDesc = await IntegrationTestFixture.TestPolicy.Execute(() => { return gateway.Query(queryDesc); }); @@ -506,7 +506,7 @@ public async Task CanQueryExtent(string rootUrl, string relativeUrl) var gateway = new PortalGateway(rootUrl); var query = new QueryForExtent(relativeUrl.AsEndpoint()); - var result = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var result = await IntegrationTestFixture.TestPolicy.Execute(() => { return gateway.QueryForExtent(query); }); @@ -526,7 +526,7 @@ public async Task CanPagePointQuery(string rootUrl, string relativeUrl, int star var gateway = new PortalGateway(rootUrl); var queryCount = new QueryForCount(relativeUrl); - var resultCount = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var resultCount = await IntegrationTestFixture.TestPolicy.Execute(() => { return gateway.QueryForCount(queryCount); }); @@ -537,7 +537,7 @@ public async Task CanPagePointQuery(string rootUrl, string relativeUrl, int star Assert.True(numberToReturn < resultCount.NumberOfResults); var query = new Query(relativeUrl.AsEndpoint()) { ResultOffset = start, ResultRecordCount = numberToReturn }; - var result = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var result = await IntegrationTestFixture.TestPolicy.Execute(() => { return gateway.Query(query); }); @@ -554,7 +554,7 @@ public async Task CanQueryForCount() var gateway = new PortalGateway("http://services.arcgisonline.com/arcgis/"); var query = new QueryForCount(@"/Specialty/Soil_Survey_Map/MapServer/2".AsEndpoint()); - var result = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var result = await IntegrationTestFixture.TestPolicy.Execute(() => { return gateway.QueryForCount(query); }); @@ -570,7 +570,7 @@ public async Task CanQueryForIds() var gateway = new PortalGateway("http://services.arcgisonline.com/arcgis/"); var query = new QueryForIds(@"/Specialty/Soil_Survey_Map/MapServer/2"); - var result = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var result = await IntegrationTestFixture.TestPolicy.Execute(() => { return gateway.QueryForIds(query); }); @@ -584,7 +584,7 @@ public async Task CanQueryForIds() { ObjectIds = result.ObjectIds.Take(100).ToList() }; - var resultFiltered = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var resultFiltered = await IntegrationTestFixture.TestPolicy.Execute(() => { return gateway.QueryForIds(queryFiltered); }); @@ -612,7 +612,7 @@ async Task QueryGeometryCriteriaHonored(string serviceUrl) var queryPointAllResults = new Query(serviceUrl.AsEndpoint()); - var resultPointAllResults = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var resultPointAllResults = await IntegrationTestFixture.TestPolicy.Execute(() => { return gateway.Query(queryPointAllResults); }); @@ -623,7 +623,7 @@ async Task QueryGeometryCriteriaHonored(string serviceUrl) OutputSpatialReference = SpatialReference.WebMercator }; - var resultPointExtentResults = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var resultPointExtentResults = await IntegrationTestFixture.TestPolicy.Execute(() => { return gateway.Query(queryPointExtentResults); }); @@ -641,7 +641,7 @@ async Task QueryGeometryCriteriaHonored(string serviceUrl) { Geometry = new Polygon { Rings = rings } }; - var resultPointPolygonResults = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var resultPointPolygonResults = await IntegrationTestFixture.TestPolicy.Execute(() => { return gateway.Query(queryPointPolygonResults); }); @@ -688,7 +688,7 @@ public async Task CanAddUpdateAndDelete() { Adds = new List> { feature } }; - var resultAdd = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var resultAdd = await IntegrationTestFixture.TestPolicy.Execute(() => { return gateway.ApplyEdits(adds); }); @@ -707,7 +707,7 @@ public async Task CanAddUpdateAndDelete() { Updates = new List> { feature } }; - var resultUpdate = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var resultUpdate = await IntegrationTestFixture.TestPolicy.Execute(() => { return gateway.ApplyEdits(updates); }); @@ -722,7 +722,7 @@ public async Task CanAddUpdateAndDelete() { Deletes = new List { id } }; - var resultDelete = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var resultDelete = await IntegrationTestFixture.TestPolicy.Execute(() => { return gateway.ApplyEdits(deletes); }); @@ -751,7 +751,7 @@ public async Task CanAddUpdateAndDeleteUsingGlobalIds() Adds = new List> { feature }, UseGlobalIds = true }; - var resultAdd = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var resultAdd = await IntegrationTestFixture.TestPolicy.Execute(() => { return gateway.ApplyEdits(adds); }); @@ -772,7 +772,7 @@ public async Task CanAddUpdateAndDeleteUsingGlobalIds() Updates = new List> { feature }, UseGlobalIds = true }; - var resultUpdate = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var resultUpdate = await IntegrationTestFixture.TestPolicy.Execute(() => { return gateway.ApplyEdits(updates); }); @@ -795,7 +795,7 @@ public async Task CanAddUpdateAndDeleteUsingGlobalIds() UseGlobalIds = true }; - var resultDelete = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var resultDelete = await IntegrationTestFixture.TestPolicy.Execute(() => { return gateway.ApplyEdits(deletes); }); @@ -821,7 +821,7 @@ public async Task FindCanReturnResultsAndGeometry() LayerIdsToSearch = new List { 1, 2, 3 }, SearchFields = new List { "Name", "RouteName" } }; - var result = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var result = await IntegrationTestFixture.TestPolicy.Execute(() => { return gateway.Find(find); }); @@ -844,7 +844,7 @@ public async Task FindCanReturnResultsAndNoGeometry() SearchFields = new List { "Name", "RouteName" }, ReturnGeometry = false }; - var result = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var result = await IntegrationTestFixture.TestPolicy.Execute(() => { return gateway.Find(find); }); @@ -866,7 +866,7 @@ public async Task CanQueryAttachments() DefinitionExpression = "ASSET_R_ID = 44", GlobalIds = new List { "2aa7a8fd-6f6c-44e4-827d-14b4acc2123a" } }; - var result = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var result = await IntegrationTestFixture.TestPolicy.Execute(() => { return gateway.QueryAttachments(queryAttachments); }); @@ -889,7 +889,7 @@ public async Task CanQueryDomains() { LayerIdsToSearch = new List { 0 } }; - var result = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var result = await IntegrationTestFixture.TestPolicy.Execute(() => { return gateway.QueryDomains(queryDomains); }); @@ -907,7 +907,7 @@ public async Task CanGetHealthCheck(string rootUrl) { var gateway = new PortalGateway(rootUrl); - var result = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var result = await IntegrationTestFixture.TestPolicy.Execute(() => { return gateway.HealthCheck(); }); @@ -925,7 +925,7 @@ public async Task CanGetFeature(string rootUrl, string relativeUrl, long objectI { var gateway = new PortalGateway(rootUrl); - var result = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var result = await IntegrationTestFixture.TestPolicy.Execute(() => { return gateway.GetFeature(new LayerFeature(relativeUrl, objectId)); }); @@ -944,7 +944,7 @@ public async Task CanExportMap(string rootUrl, string relativeUrl) { var gateway = new PortalGateway(rootUrl); - var result = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var result = await IntegrationTestFixture.TestPolicy.Execute(() => { return gateway.ExportMap(new ExportMap(relativeUrl) { @@ -970,7 +970,7 @@ public async Task CanDownloadExportMapResponse(string rootUrl, string relativeUr { var gateway = new PortalGateway(rootUrl); - var exportMapResult = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var exportMapResult = await IntegrationTestFixture.TestPolicy.Execute(() => { return gateway.ExportMap(new ExportMap(relativeUrl) { @@ -985,7 +985,7 @@ public async Task CanDownloadExportMapResponse(string rootUrl, string relativeUr }); }); - var result = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var result = await IntegrationTestFixture.TestPolicy.Execute(() => { return gateway.DownloadExportMapToLocal(exportMapResult, @"c:\temp\_tests_"); }); @@ -1017,7 +1017,7 @@ public async Task QueryForOutputStatistics() GroupByFields = new List(new string[] { "ST" }), OutputStatistics = outStats }; - var result = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var result = await IntegrationTestFixture.TestPolicy.Execute(() => { return gateway.Query(query); }); diff --git a/tests/Anywhere.ArcGIS.Test.Integration/GeocodeTests.cs b/tests/Anywhere.ArcGIS.Test.Integration/GeocodeTests.cs index 628037c..95b13bc 100644 --- a/tests/Anywhere.ArcGIS.Test.Integration/GeocodeTests.cs +++ b/tests/Anywhere.ArcGIS.Test.Integration/GeocodeTests.cs @@ -25,7 +25,7 @@ public async Task CanGeocode(string rootUrl, string relativeUrl, string text, st Text = text, SourceCountry = sourceCountry }; - var response = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var response = await IntegrationTestFixture.TestPolicy.Execute(() => { return gateway.Geocode(geocode); }); @@ -48,7 +48,7 @@ public async Task CanSuggest(string rootUrl, string relativeUrl, string text) { Text = text }; - var response = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var response = await IntegrationTestFixture.TestPolicy.Execute(() => { return gateway.Suggest(suggest); }); @@ -74,7 +74,7 @@ public async Task CanReverseGeocodePoint(string rootUrl, string relativeUrl, dou SpatialReference = new SpatialReference { Wkid = wkid } } }; - var response = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var response = await IntegrationTestFixture.TestPolicy.Execute(() => { return gateway.ReverseGeocode(reverseGeocode); }); @@ -90,7 +90,7 @@ public async Task CanCustomGeocodePolygon(string rootUrl, string relativeUrl, st { var gateway = new PortalGateway(rootUrl); var customGeocode = new SingleInputCustomGeocode(relativeUrl) { Text = searchText }; - var response = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var response = await IntegrationTestFixture.TestPolicy.Execute(() => { return gateway.CustomGeocode(customGeocode); }); diff --git a/tests/Anywhere.ArcGIS.Test.Integration/GeometryGatewayTests.cs b/tests/Anywhere.ArcGIS.Test.Integration/GeometryGatewayTests.cs index 921632c..3d78516 100644 --- a/tests/Anywhere.ArcGIS.Test.Integration/GeometryGatewayTests.cs +++ b/tests/Anywhere.ArcGIS.Test.Integration/GeometryGatewayTests.cs @@ -20,7 +20,7 @@ public GeometryGatewayTests(IntegrationTestFixture fixture, ITestOutputHelper ou public async Task CanProject() { var gateway = new PortalGateway("http://sampleserver1.arcgisonline.com/ArcGIS"); - var result = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var result = await IntegrationTestFixture.TestPolicy.Execute(() => { return gateway.Query(new Query("Demographics/ESRI_Census_USA/MapServer/5") { Where = "STATE_NAME = 'Oregon'" }); }); @@ -31,7 +31,7 @@ public async Task CanProject() Assert.True(features[0].Geometry.Rings.Count > 0); features[0].Geometry.SpatialReference = result.SpatialReference; - var projectedFeatures = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var projectedFeatures = await IntegrationTestFixture.TestPolicy.Execute(() => { return new ArcGISOnlineGateway().Project(features, SpatialReference.WGS84); }); @@ -52,7 +52,7 @@ public async Task CanBuffer(string rootUrl, string relativeUrl, string where) { var gateway = new PortalGateway(rootUrl); - var result = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var result = await IntegrationTestFixture.TestPolicy.Execute(() => { return gateway.Query(new Query(relativeUrl) { Where = where }); }); @@ -68,7 +68,7 @@ async Task Buffer(PortalGatewayBase gateway, List> features, Sp int featuresCount = features.Count; double distance = 10.0; - var featuresBuffered = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var featuresBuffered = await IntegrationTestFixture.TestPolicy.Execute(() => { return new ArcGISOnlineGateway().Buffer(features, spatialReference, distance); }); @@ -82,7 +82,7 @@ async Task Buffer(PortalGatewayBase gateway, List> features, Sp public async Task CanSimplify() { var gateway = new PortalGateway("http://sampleserver1.arcgisonline.com/ArcGIS"); - var result = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var result = await IntegrationTestFixture.TestPolicy.Execute(() => { return gateway.Query(new Query("Demographics/ESRI_Census_USA/MapServer/5") { Where = "STATE_NAME = 'Oregon'" }); }); @@ -94,7 +94,7 @@ public async Task CanSimplify() Assert.True(features[0].Geometry.Rings.Count > 0); features[0].Geometry.SpatialReference = result.SpatialReference; - var simplifiedFeatures = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var simplifiedFeatures = await IntegrationTestFixture.TestPolicy.Execute(() => { return new ArcGISOnlineGateway().Simplify(features, result.SpatialReference); }); diff --git a/tests/Anywhere.ArcGIS.Test.Integration/SecureGISGatewayTests.cs b/tests/Anywhere.ArcGIS.Test.Integration/SecureGISGatewayTests.cs index 2cf88d7..688a0ce 100644 --- a/tests/Anywhere.ArcGIS.Test.Integration/SecureGISGatewayTests.cs +++ b/tests/Anywhere.ArcGIS.Test.Integration/SecureGISGatewayTests.cs @@ -22,7 +22,7 @@ public SecureGISGatewayTests(IntegrationTestFixture fixture, ITestOutputHelper o public async Task CanGenerateToken(string rootUrl, string username, string password) { var tokenProvider = new TokenProvider(rootUrl, username, password); - var token = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var token = await IntegrationTestFixture.TestPolicy.Execute(() => { return tokenProvider.CheckGenerateToken(CancellationToken.None); }); @@ -38,13 +38,13 @@ public async Task CanGenerateToken(string rootUrl, string username, string passw public async Task CanUseServerInfoToGenerateToken(string rootUrl, string username, string password) { var gateway = new PortalGateway(rootUrl); - var serverInfo = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var serverInfo = await IntegrationTestFixture.TestPolicy.Execute(() => { return gateway.Info(); }); var tokenProvider = new TokenProvider(serverInfo.AuthenticationInfo.TokenServicesUrl, username, password); - var token = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var token = await IntegrationTestFixture.TestPolicy.Execute(() => { return tokenProvider.CheckGenerateToken(CancellationToken.None); }); @@ -59,12 +59,12 @@ public async Task CanUseServerInfoToGenerateToken(string rootUrl, string usernam [InlineData("https://sampleserver6.arcgisonline.com/arcgis", "user1", "user1")] public async Task CanDescribeSecureSite(string rootUrl, string username, string password) { - var gateway = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var gateway = await IntegrationTestFixture.TestPolicy.Execute(() => { return PortalGateway.Create(rootUrl, username, password); }); - var response = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var response = await IntegrationTestFixture.TestPolicy.Execute(() => { return gateway.DescribeSite(); }); @@ -74,7 +74,7 @@ public async Task CanDescribeSecureSite(string rootUrl, string username, string foreach (var resource in response.ArcGISServerEndpoints.Where(x => !x.RelativeUrl.ToLowerInvariant().Contains("utilities"))) { - var ping = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var ping = await IntegrationTestFixture.TestPolicy.Execute(() => { return gateway.Ping(resource); }); @@ -87,7 +87,7 @@ public async Task CanDescribeSecureSite(string rootUrl, string username, string public async Task CanDescribeSecureSiteServices(string rootUrl, string username, string password) { var gateway = new PortalGateway(rootUrl, username, password); - var siteResponse = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var siteResponse = await IntegrationTestFixture.TestPolicy.Execute(() => { return gateway.DescribeSite(); }); @@ -100,7 +100,7 @@ public async Task CanDescribeSecureSiteServices(string rootUrl, string username, Resources = siteResponse.Resources.Where(x => !x.Path.ToLowerInvariant().Contains("utilities")).ToList() }; - var response = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var response = await IntegrationTestFixture.TestPolicy.Execute(() => { return gateway.DescribeServices(filteredSite); }); @@ -133,7 +133,7 @@ public async Task InvalidTokenReported(string rootUrl, string username, string p var gateway = new PortalGateway(rootUrl, tokenProvider: tokenProvider); var endpoint = new ArcGISServerEndpoint(relativeUrl); - var token = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => + var token = await IntegrationTestFixture.TestPolicy.Execute(() => { return tokenProvider.CheckGenerateToken(CancellationToken.None); }); diff --git a/tests/Anywhere.ArcGIS.Test.Integration/TestsFixture.cs b/tests/Anywhere.ArcGIS.Test.Integration/TestsFixture.cs index 4d18d18..a71d20e 100644 --- a/tests/Anywhere.ArcGIS.Test.Integration/TestsFixture.cs +++ b/tests/Anywhere.ArcGIS.Test.Integration/TestsFixture.cs @@ -2,7 +2,6 @@ { using Polly; using Serilog; - using Serilog.Events; using System; using System.Net; using System.Net.Http; @@ -20,7 +19,7 @@ static IntegrationTestFixture() TestPolicy = Policy .Handle() .Or() - .WaitAndRetryAsync(3, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt))); + .WaitAndRetry(3, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt))); Log.Logger = new LoggerConfiguration() .MinimumLevel.Verbose() diff --git a/tests/Anywhere.ArcGIS.Test/Anywhere.ArcGIS.Test.csproj b/tests/Anywhere.ArcGIS.Test/Anywhere.ArcGIS.Test.csproj index 2d5798d..0c9d4de 100644 --- a/tests/Anywhere.ArcGIS.Test/Anywhere.ArcGIS.Test.csproj +++ b/tests/Anywhere.ArcGIS.Test/Anywhere.ArcGIS.Test.csproj @@ -5,9 +5,12 @@ - - - + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive +