File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11<Project Sdk =" Microsoft.NET.Sdk" >
22 <PropertyGroup >
3- <TargetFrameworks >net8.0;net6.0</TargetFrameworks >
3+ <TargetFrameworks >net8.0;net6.0;net4.8 </TargetFrameworks >
44 <LangVersion >latest</LangVersion >
55 <OutputType >Library</OutputType >
66 <IsPackable >false</IsPackable >
99 </PropertyGroup >
1010
1111 <ItemGroup >
12- <FrameworkReference Include =" Microsoft.AspNetCore.App" />
13- <PackageReference Include =" Microsoft.NET.Test.Sdk" Version =" 17.8.0" />
14- <PackageReference Include =" NUnit" Version =" 4.0.1" />
15- <PackageReference Include =" NUnit3TestAdapter" Version =" 4.5.0" />
16- <PackageReference Include =" NUnit.Analyzers" Version =" 3.10.0" />
17- <PackageReference Include =" coverlet.collector" Version =" 6.0.0" />
12+ <PackageReference Include =" Microsoft.NET.Test.Sdk" Version =" 17.11.1" />
13+ <PackageReference Include =" Newtonsoft.Json" Version =" 13.0.3" />
14+ <PackageReference Include =" NUnit" Version =" 4.2.2" />
15+ <PackageReference Include =" NUnit3TestAdapter" Version =" 4.6.0" />
16+ <PackageReference Include =" NUnit.Analyzers" Version =" 4.3.0" >
17+ <PrivateAssets >all</PrivateAssets >
18+ <IncludeAssets >runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets >
19+ </PackageReference >
20+ <PackageReference Include =" coverlet.collector" Version =" 6.0.2" >
21+ <PrivateAssets >all</PrivateAssets >
22+ <IncludeAssets >runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets >
23+ </PackageReference >
1824 </ItemGroup >
1925
2026 <ItemGroup >
Original file line number Diff line number Diff line change 1- using Microsoft . Extensions . Configuration ;
1+ using GoogleMapsApi . Test . Utils ;
22using System . IO ;
33
44namespace GoogleMapsApi . Test . IntegrationTests
@@ -12,24 +12,12 @@ namespace GoogleMapsApi.Test.IntegrationTests
1212 public class BaseTestIntegration
1313 {
1414 const string ApiKeyEnvironmentVariable = "GOOGLE_API_KEY" ;
15- private readonly IConfigurationRoot Configuration ;
1615
1716 public BaseTestIntegration ( )
1817 {
19- var builder = new ConfigurationBuilder ( )
20- . SetBasePath ( Directory . GetCurrentDirectory ( ) )
21- . AddEnvironmentVariables ( ) ;
22-
23- string appsettingsPath = Path . Combine ( Directory . GetCurrentDirectory ( ) , "appsettings.json" ) ;
24- if ( File . Exists ( appsettingsPath ) )
25- {
26- builder . AddJsonFile ( "appsettings.json" , optional : true , reloadOnChange : true ) ;
27- }
28-
29- Configuration = builder . Build ( ) ;
3018 }
3119
32- protected string ApiKey => Configuration . GetValue < string > ( ApiKeyEnvironmentVariable )
20+ protected string ApiKey => AppSettings . Load ( ) ? . GoogleApiKey
3321 ?? Environment . GetEnvironmentVariable ( ApiKeyEnvironmentVariable )
3422 ?? throw new InvalidOperationException ( $ "API key is not configured. Please set the { ApiKeyEnvironmentVariable } environment variable.") ;
3523 }
Original file line number Diff line number Diff line change @@ -195,9 +195,7 @@ public async Task ShouldReplaceUriViaOnUriCreated()
195195
196196 static Uri onUriCreated ( Uri uri )
197197 {
198- var builder = new UriBuilder ( uri ) ;
199- builder . Query = builder . Query . Replace ( "placeholder" , "1,2" ) ;
200- return builder . Uri ;
198+ return new Uri ( uri . ToString ( ) . Replace ( "placeholder" , "1,2" ) ) ;
201199 }
202200
203201 GoogleMaps . DistanceMatrix . OnUriCreated += onUriCreated ;
Original file line number Diff line number Diff line change 1+ using Newtonsoft . Json ;
2+ using System ;
3+ using System . Collections . Generic ;
4+ using System . Linq ;
5+ using System . Text ;
6+ using System . Threading . Tasks ;
7+
8+ namespace GoogleMapsApi . Test . Utils
9+ {
10+ internal class AppSettings
11+ {
12+ [ JsonProperty ( PropertyName = "GOOGLE_API_KEY" ) ]
13+ public string ? GoogleApiKey { get ; set ; }
14+
15+ public static AppSettings ? Load ( )
16+ {
17+ var path = Path . Combine ( AppDomain . CurrentDomain . BaseDirectory , "appsettings.json" ) ;
18+ if ( ! File . Exists ( path ) ) return null ;
19+ return JsonConvert . DeserializeObject < AppSettings > ( File . ReadAllText ( path ) ) ;
20+ }
21+ }
22+ }
Original file line number Diff line number Diff line change 11<Project Sdk =" Microsoft.NET.Sdk" >
22 <PropertyGroup >
3- <TargetFrameworks >net8.0;net7.0;net6.0;netstandard2.1 </TargetFrameworks >
3+ <TargetFrameworks >net8.0;net7.0;net6.0;netstandard2.0 </TargetFrameworks >
44 <LangVersion >latest</LangVersion >
55 <Version >0.0.0</Version >
66 <AppxAutoIncrementPackageRevision >True</AppxAutoIncrementPackageRevision >
You can’t perform that action at this time.
0 commit comments