Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated dependencies and now compatible from netstandard2.0 to net8.0 #166

Merged
merged 1 commit into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions GoogleMapsApi.Test/GoogleMapsApi.Test.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net8.0;net6.0</TargetFrameworks>
<TargetFrameworks>net8.0;net6.0;net4.8</TargetFrameworks>
<LangVersion>latest</LangVersion>
<OutputType>Library</OutputType>
<IsPackable>false</IsPackable>
Expand All @@ -9,12 +9,18 @@
</PropertyGroup>

<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageReference Include="NUnit" Version="4.0.1" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="NUnit.Analyzers" Version="3.10.0" />
<PackageReference Include="coverlet.collector" Version="6.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="NUnit" Version="4.2.2" />
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
<PackageReference Include="NUnit.Analyzers" Version="4.3.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
Expand Down
16 changes: 2 additions & 14 deletions GoogleMapsApi.Test/IntegrationTests/BaseTestIntegration.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.Extensions.Configuration;
using GoogleMapsApi.Test.Utils;
using System.IO;

namespace GoogleMapsApi.Test.IntegrationTests
Expand All @@ -12,24 +12,12 @@ namespace GoogleMapsApi.Test.IntegrationTests
public class BaseTestIntegration
{
const string ApiKeyEnvironmentVariable = "GOOGLE_API_KEY";
private readonly IConfigurationRoot Configuration;

public BaseTestIntegration()
{
var builder = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddEnvironmentVariables();

string appsettingsPath = Path.Combine(Directory.GetCurrentDirectory(), "appsettings.json");
if (File.Exists(appsettingsPath))
{
builder.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
}

Configuration = builder.Build();
}

protected string ApiKey => Configuration.GetValue<string>(ApiKeyEnvironmentVariable)
protected string ApiKey => AppSettings.Load()?.GoogleApiKey
?? Environment.GetEnvironmentVariable(ApiKeyEnvironmentVariable)
?? throw new InvalidOperationException($"API key is not configured. Please set the {ApiKeyEnvironmentVariable} environment variable.");
}
Expand Down
4 changes: 1 addition & 3 deletions GoogleMapsApi.Test/IntegrationTests/DistanceMatrixTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,7 @@ public async Task ShouldReplaceUriViaOnUriCreated()

static Uri onUriCreated(Uri uri)
{
var builder = new UriBuilder(uri);
builder.Query = builder.Query.Replace("placeholder", "1,2");
return builder.Uri;
return new Uri(uri.ToString().Replace("placeholder", "1,2"));
}

GoogleMaps.DistanceMatrix.OnUriCreated += onUriCreated;
Expand Down
22 changes: 22 additions & 0 deletions GoogleMapsApi.Test/Utils/AppSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GoogleMapsApi.Test.Utils
{
internal class AppSettings
{
[JsonProperty(PropertyName ="GOOGLE_API_KEY")]
public string? GoogleApiKey { get; set; }

public static AppSettings? Load()
{
var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "appsettings.json");
if (!File.Exists(path)) return null;
return JsonConvert.DeserializeObject<AppSettings>(File.ReadAllText(path));
}
}
}
2 changes: 1 addition & 1 deletion GoogleMapsApi/GoogleMapsApi.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net8.0;net7.0;net6.0;netstandard2.1</TargetFrameworks>
<TargetFrameworks>net8.0;net7.0;net6.0;netstandard2.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
<Version>0.0.0</Version>
<AppxAutoIncrementPackageRevision>True</AppxAutoIncrementPackageRevision>
Expand Down
Loading