From ec4688948505c2d0091d03e6668134f7218fc5f3 Mon Sep 17 00:00:00 2001 From: Max Novak Date: Wed, 9 Oct 2024 19:30:10 +0300 Subject: [PATCH] Fix 'ShouldPassRawDataToOnRawResponseReceived' --- .../IntegrationTests/DistanceMatrixTests.cs | 1 - GoogleMapsApi/Engine/MapsAPIGenericEngine.cs | 13 +++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/GoogleMapsApi.Test/IntegrationTests/DistanceMatrixTests.cs b/GoogleMapsApi.Test/IntegrationTests/DistanceMatrixTests.cs index 8242cdb..5858842 100644 --- a/GoogleMapsApi.Test/IntegrationTests/DistanceMatrixTests.cs +++ b/GoogleMapsApi.Test/IntegrationTests/DistanceMatrixTests.cs @@ -217,7 +217,6 @@ static Uri onUriCreated(Uri uri) } [Test] - [Ignore("Need to fix it")] public async Task ShouldPassRawDataToOnRawResponseReceived() { var request = new DistanceMatrixRequest diff --git a/GoogleMapsApi/Engine/MapsAPIGenericEngine.cs b/GoogleMapsApi/Engine/MapsAPIGenericEngine.cs index 81f822e..261de0d 100644 --- a/GoogleMapsApi/Engine/MapsAPIGenericEngine.cs +++ b/GoogleMapsApi/Engine/MapsAPIGenericEngine.cs @@ -7,6 +7,8 @@ using System.Runtime.Serialization.Json; using System.Threading; using System.Threading.Tasks; +using System.Text; + namespace GoogleMapsApi.Engine { @@ -26,16 +28,15 @@ protected internal static async Task QueryGoogleAPIAsync(TRequest req if (request == null) throw new ArgumentNullException(nameof(request)); - var uri = request.GetUri(); - if (OnUriCreated != null) - { - uri = OnUriCreated(uri); - } - + var requstUri = request.GetUri(); + var uri = OnUriCreated?.Invoke(requstUri) ?? requstUri; + var client = new HttpClient(); var response = await client.DownloadDataTaskAsyncAsString(uri, timeout, token).ConfigureAwait(false); + OnRawResponseReceived?.Invoke(Encoding.UTF8.GetBytes(response)); + return JsonConvert.DeserializeObject(response); }