diff --git a/Directory.build.props b/Directory.build.props index 953a4da..11d9258 100644 --- a/Directory.build.props +++ b/Directory.build.props @@ -15,16 +15,15 @@ All - - All - - + All AllEnabledByDefault + true + true diff --git a/Geo.NET.ruleset b/Geo.NET.ruleset index a260842..3c0fd06 100644 --- a/Geo.NET.ruleset +++ b/Geo.NET.ruleset @@ -3,6 +3,7 @@ + diff --git a/src/Geo.ArcGIS/DependencyInjection/ServiceCollectionExtensions.cs b/src/Geo.ArcGIS/DependencyInjection/ServiceCollectionExtensions.cs index e1da716..e86bb18 100644 --- a/src/Geo.ArcGIS/DependencyInjection/ServiceCollectionExtensions.cs +++ b/src/Geo.ArcGIS/DependencyInjection/ServiceCollectionExtensions.cs @@ -6,6 +6,7 @@ namespace Geo.ArcGIS.DependencyInjection { using System; + using System.Net.Http; using Geo.ArcGIS.Abstractions; using Geo.ArcGIS.Models; using Geo.ArcGIS.Services; @@ -26,10 +27,15 @@ public static class ServiceCollectionExtensions /// /// /// - /// A to add the ArcGIS services to. + /// An to add the ArcGIS services to. /// A with the options to add to the ArcGIS configuration. - /// A with the added services. - public static IServiceCollection AddArcGISServices(this IServiceCollection services, Action optionsBuilder) + /// Optional. A delegate that is used to configure the . + /// An to configure the http client. + /// Thrown if is null. + public static IHttpClientBuilder AddArcGISServices( + this IServiceCollection services, + Action optionsBuilder, + Action configureClient = null) { services.AddCoreServices(); @@ -47,9 +53,13 @@ public static IServiceCollection AddArcGISServices(this IServiceCollection servi services.AddHttpClient(); services.AddSingleton(); - services.AddHttpClient(); - return services; + return services.AddHttpClient(configureClient ?? DefaultHttpClientConfiguration); + } + + private static void DefaultHttpClientConfiguration(HttpClient client) + { + // No-op } } } diff --git a/src/Geo.ArcGIS/Services/ArcGISGeocoding.cs b/src/Geo.ArcGIS/Services/ArcGISGeocoding.cs index b97ca00..bafe8df 100644 --- a/src/Geo.ArcGIS/Services/ArcGISGeocoding.cs +++ b/src/Geo.ArcGIS/Services/ArcGISGeocoding.cs @@ -43,7 +43,7 @@ public class ArcGISGeocoding : ClientExecutor, IArcGISGeocoding /// Initializes a new instance of the class. /// /// A used for making calls to the ArcGIS system. - /// A used for retreiving the ArcGIS token. + /// An used for retreiving the ArcGIS token. /// An used to provide exceptions based on an exception type. /// An used to create a resource string provider for log or exception messages. /// An used to create a logger used for logging information. diff --git a/src/Geo.ArcGIS/Services/ArcGISTokenContainer.cs b/src/Geo.ArcGIS/Services/ArcGISTokenContainer.cs index 589a0d4..e6b0326 100644 --- a/src/Geo.ArcGIS/Services/ArcGISTokenContainer.cs +++ b/src/Geo.ArcGIS/Services/ArcGISTokenContainer.cs @@ -24,7 +24,7 @@ public class ArcGISTokenContainer : IArcGISTokenContainer /// /// Initializes a new instance of the class. /// - /// A used to retrieve the token if expired of none existant. + /// An used to retrieve the token if expired of none existant. public ArcGISTokenContainer(IArcGISTokenRetrevial tokenRetrevial) { _tokenRetrevial = tokenRetrevial ?? throw new ArgumentNullException(nameof(tokenRetrevial)); diff --git a/src/Geo.ArcGIS/Services/ArcGISTokenRetrevial.cs b/src/Geo.ArcGIS/Services/ArcGISTokenRetrevial.cs index 2e56894..f2bedaa 100644 --- a/src/Geo.ArcGIS/Services/ArcGISTokenRetrevial.cs +++ b/src/Geo.ArcGIS/Services/ArcGISTokenRetrevial.cs @@ -27,7 +27,7 @@ public class ArcGISTokenRetrevial : IArcGISTokenRetrevial /// Initializes a new instance of the class. /// /// A used for placing calls to the ArcGIS token generation API. - /// A used for fetching the ArcGIS credentials. + /// An used for fetching the ArcGIS credentials. public ArcGISTokenRetrevial( HttpClient client, IArcGISCredentialsContainer credentialsContainer) diff --git a/src/Geo.Bing/DependencyInjection/ServiceCollectionExtensions.cs b/src/Geo.Bing/DependencyInjection/ServiceCollectionExtensions.cs index 0076a37..c468b5c 100644 --- a/src/Geo.Bing/DependencyInjection/ServiceCollectionExtensions.cs +++ b/src/Geo.Bing/DependencyInjection/ServiceCollectionExtensions.cs @@ -6,6 +6,7 @@ namespace Geo.Bing.DependencyInjection { using System; + using System.Net.Http; using Geo.Bing.Abstractions; using Geo.Bing.Models; using Geo.Bing.Services; @@ -26,10 +27,15 @@ public static class ServiceCollectionExtensions /// /// /// - /// A to add the Bing services to. + /// An to add the Bing services to. /// A with the options to add to the Bing configuration. - /// A with the added services. - public static IServiceCollection AddBingServices(this IServiceCollection services, Action optionsBuilder) + /// Optional. A delegate that is used to configure the . + /// An to configure the http client. + /// Thrown if is null. + public static IHttpClientBuilder AddBingServices( + this IServiceCollection services, + Action optionsBuilder, + Action configureClient = null) { services.AddCoreServices(); @@ -45,9 +51,12 @@ public static IServiceCollection AddBingServices(this IServiceCollection service services.AddSingleton(new BingKeyContainer(string.Empty)); } - services.AddHttpClient(); + return services.AddHttpClient(configureClient ?? DefaultHttpClientConfiguration); + } - return services; + private static void DefaultHttpClientConfiguration(HttpClient client) + { + // No-op } } } diff --git a/src/Geo.Bing/Services/BingGeocoding.cs b/src/Geo.Bing/Services/BingGeocoding.cs index 99be37f..a771f7a 100644 --- a/src/Geo.Bing/Services/BingGeocoding.cs +++ b/src/Geo.Bing/Services/BingGeocoding.cs @@ -35,7 +35,7 @@ public class BingGeocoding : ClientExecutor, IBingGeocoding /// Initializes a new instance of the class. /// /// A used for placing calls to the Bing Geocoding API. - /// A used for fetching the Bing key. + /// An used for fetching the Bing key. /// An used to provide exceptions based on an exception type. /// An used to create a resource string provider for log or exception messages. /// An used to create a logger used for logging information. diff --git a/src/Geo.Core/Abstractions/IGeoNETResourceStringProviderFactory.cs b/src/Geo.Core/Abstractions/IGeoNETResourceStringProviderFactory.cs index eeb3331..bea47ac 100644 --- a/src/Geo.Core/Abstractions/IGeoNETResourceStringProviderFactory.cs +++ b/src/Geo.Core/Abstractions/IGeoNETResourceStringProviderFactory.cs @@ -14,21 +14,21 @@ namespace Geo.Core public interface IGeoNETResourceStringProviderFactory { /// - /// Creates a based on a type. + /// Creates an based on a type. /// /// The type of the resource to create an for. /// An . IGeoNETResourceStringProvider CreateResourceStringProvider(); /// - /// Creates a based on a type. + /// Creates an based on a type. /// /// The type of the resource to create an for. /// An . IGeoNETResourceStringProvider CreateResourceStringProvider(Type resourceType); /// - /// Creates a based on the resouce file name and assembly. + /// Creates an based on the resouce file name and assembly. /// /// The name of the resource file. /// Optional. The assembly the resource file is located in. If not passed in, the current assembly will be used. diff --git a/src/Geo.Core/DependencyInjection/ServiceCollectionExtensions.cs b/src/Geo.Core/DependencyInjection/ServiceCollectionExtensions.cs index 0f088af..35bfa24 100644 --- a/src/Geo.Core/DependencyInjection/ServiceCollectionExtensions.cs +++ b/src/Geo.Core/DependencyInjection/ServiceCollectionExtensions.cs @@ -5,7 +5,9 @@ namespace Geo.Core.DependencyInjection { + using System; using Microsoft.Extensions.DependencyInjection; + using Microsoft.Extensions.DependencyInjection.Extensions; /// /// Extension methods for the class. @@ -14,14 +16,26 @@ public static class ServiceCollectionExtensions { /// /// Adds the Core services to the service collection. + /// + /// Adds the services: + /// + /// + /// + /// + /// /// - /// A to add the Core services to. - /// A with the added services. + /// An to add the Core services to. + /// The for chaining. + /// Thrown if is null. public static IServiceCollection AddCoreServices(this IServiceCollection services) { - services - .AddTransient() - .AddTransient(); + if (services == null) + { + throw new ArgumentNullException(nameof(services)); + } + + services.TryAddTransient(); + services.TryAddTransient(); return services; } diff --git a/src/Geo.Google/DependencyInjection/ServiceCollectionExtensions.cs b/src/Geo.Google/DependencyInjection/ServiceCollectionExtensions.cs index 963935e..d7b58a7 100644 --- a/src/Geo.Google/DependencyInjection/ServiceCollectionExtensions.cs +++ b/src/Geo.Google/DependencyInjection/ServiceCollectionExtensions.cs @@ -6,6 +6,7 @@ namespace Geo.Google.DependencyInjection { using System; + using System.Net.Http; using Geo.Core.DependencyInjection; using Geo.Google.Abstractions; using Geo.Google.Models; @@ -26,10 +27,15 @@ public static class ServiceCollectionExtensions /// /// /// - /// A to add the Google services to. + /// An to add the Google services to. /// A with the options to add to the Google configuration. - /// A with the added services. - public static IServiceCollection AddGoogleServices(this IServiceCollection services, Action optionsBuilder) + /// Optional. A delegate that is used to configure the . + /// An to configure the http client. + /// Thrown if is null. + public static IHttpClientBuilder AddGoogleServices( + this IServiceCollection services, + Action optionsBuilder, + Action configureClient = null) { services.AddCoreServices(); @@ -45,9 +51,12 @@ public static IServiceCollection AddGoogleServices(this IServiceCollection servi services.AddSingleton(new GoogleKeyContainer(string.Empty)); } - services.AddHttpClient(); + return services.AddHttpClient(configureClient ?? DefaultHttpClientConfiguration); + } - return services; + private static void DefaultHttpClientConfiguration(HttpClient client) + { + // No-op } } } diff --git a/src/Geo.Google/Services/GoogleGeocoding.cs b/src/Geo.Google/Services/GoogleGeocoding.cs index 329047e..588859f 100644 --- a/src/Geo.Google/Services/GoogleGeocoding.cs +++ b/src/Geo.Google/Services/GoogleGeocoding.cs @@ -45,7 +45,7 @@ public class GoogleGeocoding : ClientExecutor, IGoogleGeocoding /// Initializes a new instance of the class. /// /// A used for placing calls to the Google Geocoding API. - /// A used for fetching the Google key. + /// An used for fetching the Google key. /// An used to provide exceptions based on an exception type. /// An used to create a resource string provider for log or exception messages. /// An used to create a logger used for logging information. diff --git a/src/Geo.Here/DependencyInjection/ServiceCollectionExtensions.cs b/src/Geo.Here/DependencyInjection/ServiceCollectionExtensions.cs index 3426b34..6c4e542 100644 --- a/src/Geo.Here/DependencyInjection/ServiceCollectionExtensions.cs +++ b/src/Geo.Here/DependencyInjection/ServiceCollectionExtensions.cs @@ -6,6 +6,7 @@ namespace Geo.Here.DependencyInjection { using System; + using System.Net.Http; using Geo.Core.DependencyInjection; using Geo.Here.Abstractions; using Geo.Here.Models; @@ -26,10 +27,15 @@ public static class ServiceCollectionExtensions /// /// /// - /// A to add the HERE services to. + /// An to add the HERE services to. /// A with the options to add to the HERE configuration. - /// A with the added services. - public static IServiceCollection AddHereServices(this IServiceCollection services, Action optionsBuilder) + /// Optional. A delegate that is used to configure the . + /// An to configure the http client. + /// Thrown if is null. + public static IHttpClientBuilder AddHereServices( + this IServiceCollection services, + Action optionsBuilder, + Action configureClient = null) { services.AddCoreServices(); @@ -45,9 +51,12 @@ public static IServiceCollection AddHereServices(this IServiceCollection service services.AddSingleton(new HereKeyContainer(string.Empty)); } - services.AddHttpClient(); + return services.AddHttpClient(configureClient ?? DefaultHttpClientConfiguration); + } - return services; + private static void DefaultHttpClientConfiguration(HttpClient client) + { + // No-op } } } diff --git a/src/Geo.Here/Services/HereGeocoding.cs b/src/Geo.Here/Services/HereGeocoding.cs index 060c18c..a04508c 100644 --- a/src/Geo.Here/Services/HereGeocoding.cs +++ b/src/Geo.Here/Services/HereGeocoding.cs @@ -40,7 +40,7 @@ public class HereGeocoding : ClientExecutor, IHereGeocoding /// Initializes a new instance of the class. /// /// A used for placing calls to the HERE Geocoding API. - /// A used for fetching the HERE key. + /// An used for fetching the HERE key. /// An used to provide exceptions based on an exception type. /// An used to create a resource string provider for log or exception messages. /// An used to create a logger used for logging information. diff --git a/src/Geo.Here/Services/PolylineEncoderDecoder.cs b/src/Geo.Here/Services/PolylineEncoderDecoder.cs index 39f0b5c..3f38654 100644 --- a/src/Geo.Here/Services/PolylineEncoderDecoder.cs +++ b/src/Geo.Here/Services/PolylineEncoderDecoder.cs @@ -26,7 +26,7 @@ internal class PolylineEncoderDecoder /// The third dimension value will be eligible for encoding only when ThirdDimension is other than ABSENT. /// This is lossy compression based on precision accuracy. /// - /// A of of coordinate triples that to be encoded. + /// An of of coordinate triples that to be encoded. /// Floating point precision of the coordinate to be encoded. /// A which may be a level, altitude, elevation or some other custom value. /// Floating point precision for thirdDimension value. @@ -53,10 +53,10 @@ public static string Encode(IEnumerable coordinates, int precision, Thi } /// - /// Decode the encoded input to a of . + /// Decode the encoded input to an of . /// /// The encoded URL-safe encoded . - /// A of coordinate triples that are decoded from the input. + /// An of coordinate triples that are decoded from the input. public static IReadOnlyList Decode(string encoded) { if (string.IsNullOrEmpty(encoded?.Trim())) diff --git a/src/Geo.MapBox/DependencyInjection/ServiceCollectionExtensions.cs b/src/Geo.MapBox/DependencyInjection/ServiceCollectionExtensions.cs index a02db9f..cd60f06 100644 --- a/src/Geo.MapBox/DependencyInjection/ServiceCollectionExtensions.cs +++ b/src/Geo.MapBox/DependencyInjection/ServiceCollectionExtensions.cs @@ -6,6 +6,7 @@ namespace Geo.MapBox.DependencyInjection { using System; + using System.Net.Http; using Geo.Core.DependencyInjection; using Geo.MapBox.Abstractions; using Geo.MapBox.Models; @@ -26,10 +27,15 @@ public static class ServiceCollectionExtensions /// /// /// - /// A to add the MapBox services to. + /// An to add the MapBox services to. /// A with the options to add to the MapBox configuration. - /// A with the added services. - public static IServiceCollection AddMapBoxServices(this IServiceCollection services, Action optionsBuilder) + /// Optional. A delegate that is used to configure the . + /// An to configure the http client. + /// Thrown if is null. + public static IHttpClientBuilder AddMapBoxServices( + this IServiceCollection services, + Action optionsBuilder, + Action configureClient = null) { services.AddCoreServices(); @@ -45,9 +51,12 @@ public static IServiceCollection AddMapBoxServices(this IServiceCollection servi services.AddSingleton(new MapBoxKeyContainer(string.Empty)); } - services.AddHttpClient(); + return services.AddHttpClient(configureClient ?? DefaultHttpClientConfiguration); + } - return services; + private static void DefaultHttpClientConfiguration(HttpClient client) + { + // No-op } } } diff --git a/src/Geo.MapBox/Services/MapBoxGeocoding.cs b/src/Geo.MapBox/Services/MapBoxGeocoding.cs index a051c72..ae6bf59 100644 --- a/src/Geo.MapBox/Services/MapBoxGeocoding.cs +++ b/src/Geo.MapBox/Services/MapBoxGeocoding.cs @@ -42,7 +42,7 @@ public class MapBoxGeocoding : ClientExecutor, IMapBoxGeocoding /// Initializes a new instance of the class. /// /// A used for placing calls to the here Geocoding API. - /// A used for fetching the here key. + /// An used for fetching the here key. /// An used to provide exceptions based on an exception type. /// An used to create a resource string provider for log or exception messages. /// An used to create a logger used for logging information. diff --git a/src/Geo.MapQuest/DependencyInjection/ServiceCollectionExtensions.cs b/src/Geo.MapQuest/DependencyInjection/ServiceCollectionExtensions.cs index c6b7b57..ac5ed02 100644 --- a/src/Geo.MapQuest/DependencyInjection/ServiceCollectionExtensions.cs +++ b/src/Geo.MapQuest/DependencyInjection/ServiceCollectionExtensions.cs @@ -6,6 +6,7 @@ namespace Geo.MapQuest.DependencyInjection { using System; + using System.Net.Http; using Geo.Core.DependencyInjection; using Geo.MapQuest.Abstractions; using Geo.MapQuest.Models; @@ -26,10 +27,15 @@ public static class ServiceCollectionExtensions /// /// /// - /// A to add the MapQuest services to. + /// An to add the MapQuest services to. /// A with the options to add to the MapQuest configuration. - /// A with the added services. - public static IServiceCollection AddMapQuestServices(this IServiceCollection services, Action optionsBuilder) + /// Optional. A delegate that is used to configure the . + /// An to configure the http client. + /// Thrown if is null. + public static IHttpClientBuilder AddMapQuestServices( + this IServiceCollection services, + Action optionsBuilder, + Action configureClient = null) { services.AddCoreServices(); @@ -47,9 +53,12 @@ public static IServiceCollection AddMapQuestServices(this IServiceCollection ser services.AddSingleton(new MapQuestEndpoint(false)); } - services.AddHttpClient(); + return services.AddHttpClient(configureClient ?? DefaultHttpClientConfiguration); + } - return services; + private static void DefaultHttpClientConfiguration(HttpClient client) + { + // No-op } } } diff --git a/src/Geo.MapQuest/Services/MapQuestGeocoding.cs b/src/Geo.MapQuest/Services/MapQuestGeocoding.cs index ed8084f..2729b17 100644 --- a/src/Geo.MapQuest/Services/MapQuestGeocoding.cs +++ b/src/Geo.MapQuest/Services/MapQuestGeocoding.cs @@ -39,8 +39,8 @@ public class MapQuestGeocoding : ClientExecutor, IMapQuestGeocoding /// Initializes a new instance of the class. /// /// A used for placing calls to the MapQuest Geocoding API. - /// A used for fetching the MapQuest key. - /// A used for fetching which MapQuest endpoint to use. + /// An used for fetching the MapQuest key. + /// An used for fetching which MapQuest endpoint to use. /// An used to provide exceptions based on an exception type. /// An used to create a resource string provider for log or exception messages. /// An used to create a logger used for logging information. diff --git a/src/Source.props b/src/Source.props index 7e58f1c..369be80 100644 --- a/src/Source.props +++ b/src/Source.props @@ -6,7 +6,13 @@ - + + + + + + + diff --git a/test/Geo.ArcGIS.Tests/DependencyInjection/ServiceCollectionExtensionsTests.cs b/test/Geo.ArcGIS.Tests/DependencyInjection/ServiceCollectionExtensionsTests.cs new file mode 100644 index 0000000..1a6f136 --- /dev/null +++ b/test/Geo.ArcGIS.Tests/DependencyInjection/ServiceCollectionExtensionsTests.cs @@ -0,0 +1,74 @@ +// +// Copyright (c) Geo.NET. +// Licensed under the MIT license. See the LICENSE file in the solution root for full license information. +// + +namespace Geo.ArcGIS.Tests.DependencyInjection +{ + using System; + using System.Net.Http; + using FluentAssertions; + using Geo.ArcGIS.Abstractions; + using Geo.ArcGIS.DependencyInjection; + using Microsoft.Extensions.DependencyInjection; + using Xunit; + + /// + /// Unit tests for the class. + /// + public class ServiceCollectionExtensionsTests + { + [Fact] + public void AddArcGISServices_WithValidCall_ConfiguresAllServices() + { + // Arrange + var services = new ServiceCollection(); + + // Act + services.AddArcGISServices(options => options.UseClientCredentials("abc", "123")); + + // Assert + var provider = services.BuildServiceProvider(); + + provider.GetRequiredService().Should().NotBeNull(); + provider.GetRequiredService().Should().NotBeNull(); + provider.GetRequiredService().Should().NotBeNull(); + provider.GetRequiredService().Should().NotBeNull(); + } + + [Fact] + public void AddArcGISServices_WithNullOptions_ConfiguresAllServices() + { + // Arrange + var services = new ServiceCollection(); + + // Act + services.AddArcGISServices(null); + + // Assert + var provider = services.BuildServiceProvider(); + + provider.GetRequiredService().Should().NotBeNull(); + provider.GetRequiredService().Should().NotBeNull(); + provider.GetRequiredService().Should().NotBeNull(); + provider.GetRequiredService().Should().NotBeNull(); + } + + [Fact] + public void AddArcGISServices_WithClientConfiguration_ConfiguresHttpClientAllServices() + { + // Arrange + var services = new ServiceCollection(); + + // Act + services.AddArcGISServices( + options => options.UseClientCredentials("abc", "123"), + client => client.Timeout = TimeSpan.FromSeconds(1)); + + // Assert + var provider = services.BuildServiceProvider(); + var client = provider.GetRequiredService().CreateClient("IArcGISGeocoding"); + client.Timeout.Should().Be(TimeSpan.FromSeconds(1)); + } + } +} diff --git a/test/Geo.ArcGIS.Tests/GlobalSuppressions.cs b/test/Geo.ArcGIS.Tests/GlobalSuppressions.cs new file mode 100644 index 0000000..ba5a3c3 --- /dev/null +++ b/test/Geo.ArcGIS.Tests/GlobalSuppressions.cs @@ -0,0 +1,13 @@ +// +// Copyright (c) Geo.NET. +// Licensed under the MIT license. See the LICENSE file in the solution root for full license information. +// + +// This file is used by Code Analysis to maintain SuppressMessage +// attributes that are applied to this project. +// Project-level suppressions either have no target or are given +// a specific target and scoped to a namespace, type, member, etc. +using System.Diagnostics.CodeAnalysis; + +[assembly: SuppressMessage("Naming", "CA1707:Identifiers should not contain underscores", Justification = "Using Microsoft recommended unit test naming", Scope = "namespaceanddescendants", Target = "~N:Geo.ArcGIS.Tests")] +[assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:Elements should be documented", Justification = "The name of the test should explain the test", Scope = "namespaceanddescendants", Target = "~N:Geo.ArcGIS.Tests")] diff --git a/test/Geo.ArcGIS.Tests/TestData/CultureTestData.cs b/test/Geo.ArcGIS.Tests/TestData/CultureTestData.cs index 4069b52..0503119 100644 --- a/test/Geo.ArcGIS.Tests/TestData/CultureTestData.cs +++ b/test/Geo.ArcGIS.Tests/TestData/CultureTestData.cs @@ -17,7 +17,7 @@ public class CultureTestData : IEnumerable /// /// Gets the enumerator for the test data. /// - /// A of []. + /// An of []. public IEnumerator GetEnumerator() { var cultures = CultureInfo.GetCultures(CultureTypes.AllCultures); @@ -30,7 +30,7 @@ public IEnumerator GetEnumerator() /// /// Gets the enumerator for the test data. /// - /// A . + /// An . IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); } } diff --git a/test/Geo.Bing.Tests/DependencyInjection/ServiceCollectionExtensionsTests.cs b/test/Geo.Bing.Tests/DependencyInjection/ServiceCollectionExtensionsTests.cs new file mode 100644 index 0000000..aabe188 --- /dev/null +++ b/test/Geo.Bing.Tests/DependencyInjection/ServiceCollectionExtensionsTests.cs @@ -0,0 +1,70 @@ +// +// Copyright (c) Geo.NET. +// Licensed under the MIT license. See the LICENSE file in the solution root for full license information. +// + +namespace Geo.Bing.Tests.DependencyInjection +{ + using System; + using System.Net.Http; + using FluentAssertions; + using Geo.Bing.Abstractions; + using Geo.Bing.DependencyInjection; + using Microsoft.Extensions.DependencyInjection; + using Xunit; + + /// + /// Unit tests for the class. + /// + public class ServiceCollectionExtensionsTests + { + [Fact] + public void AddBingServices_WithValidCall_ConfiguresAllServices() + { + // Arrange + var services = new ServiceCollection(); + + // Act + services.AddBingServices(options => options.UseKey("abc")); + + // Assert + var provider = services.BuildServiceProvider(); + + provider.GetRequiredService().Should().NotBeNull(); + provider.GetRequiredService().Should().NotBeNull(); + } + + [Fact] + public void AddBingServices_WithNullOptions_ConfiguresAllServices() + { + // Arrange + var services = new ServiceCollection(); + + // Act + services.AddBingServices(null); + + // Assert + var provider = services.BuildServiceProvider(); + + provider.GetRequiredService().Should().NotBeNull(); + provider.GetRequiredService().Should().NotBeNull(); + } + + [Fact] + public void AddBingServices_WithClientConfiguration_ConfiguresHttpClientAllServices() + { + // Arrange + var services = new ServiceCollection(); + + // Act + services.AddBingServices( + options => options.UseKey("abc"), + client => client.Timeout = TimeSpan.FromSeconds(2)); + + // Assert + var provider = services.BuildServiceProvider(); + var client = provider.GetRequiredService().CreateClient("IBingGeocoding"); + client.Timeout.Should().Be(TimeSpan.FromSeconds(2)); + } + } +} diff --git a/test/Geo.Bing.Tests/GlobalSuppressions.cs b/test/Geo.Bing.Tests/GlobalSuppressions.cs new file mode 100644 index 0000000..ec285d2 --- /dev/null +++ b/test/Geo.Bing.Tests/GlobalSuppressions.cs @@ -0,0 +1,13 @@ +// +// Copyright (c) Geo.NET. +// Licensed under the MIT license. See the LICENSE file in the solution root for full license information. +// + +// This file is used by Code Analysis to maintain SuppressMessage +// attributes that are applied to this project. +// Project-level suppressions either have no target or are given +// a specific target and scoped to a namespace, type, member, etc. +using System.Diagnostics.CodeAnalysis; + +[assembly: SuppressMessage("Naming", "CA1707:Identifiers should not contain underscores", Justification = "Using Microsoft recommended unit test naming", Scope = "namespaceanddescendants", Target = "~N:Geo.Bing.Tests")] +[assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:Elements should be documented", Justification = "The name of the test should explain the test", Scope = "namespaceanddescendants", Target = "~N:Geo.Bing.Tests")] diff --git a/test/Geo.Bing.Tests/TestData/CultureTestData.cs b/test/Geo.Bing.Tests/TestData/CultureTestData.cs index ac02e02..a8059bc 100644 --- a/test/Geo.Bing.Tests/TestData/CultureTestData.cs +++ b/test/Geo.Bing.Tests/TestData/CultureTestData.cs @@ -17,7 +17,7 @@ public class CultureTestData : IEnumerable /// /// Gets the enumerator for the test data. /// - /// A of []. + /// An of []. public IEnumerator GetEnumerator() { var cultures = CultureInfo.GetCultures(CultureTypes.AllCultures); @@ -30,7 +30,7 @@ public IEnumerator GetEnumerator() /// /// Gets the enumerator for the test data. /// - /// A . + /// An . IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); } } diff --git a/test/Geo.Core.Tests/ClientExecutorShould.cs b/test/Geo.Core.Tests/ClientExecutorShould.cs index 5fd2707..db88395 100644 --- a/test/Geo.Core.Tests/ClientExecutorShould.cs +++ b/test/Geo.Core.Tests/ClientExecutorShould.cs @@ -145,7 +145,7 @@ public void ThrowExceptionOnNullUri() sut.Invoking(x => x.CallAsync(new Uri("http://test.com/ArgumentNullException"))) .Should() - .Throw() + .ThrowAsync() .WithMessage("Value cannot be null. (Parameter 'requestUri')"); } @@ -159,7 +159,7 @@ public void ThrowExceptionOnInvalidUri() sut.Invoking(x => x.CallAsync(new Uri("http://test.com/InvalidOperationException"))) .Should() - .Throw() + .ThrowAsync() .WithMessage("requestUri"); } @@ -173,7 +173,7 @@ public void ThrowExceptionOnHttpFailure() sut.Invoking(x => x.CallAsync(new Uri("http://test.com/HttpRequestException"))) .Should() - .Throw() + .ThrowAsync() .WithMessage("Exception of type 'System.Net.Http.HttpRequestException' was thrown."); } @@ -187,7 +187,7 @@ public void ThrowExceptionOnCancelledRequest() sut.Invoking(x => x.CallAsync(new Uri("http://test.com/TaskCanceledException"))) .Should() - .Throw(); + .ThrowAsync(); } /// @@ -200,7 +200,7 @@ public void ThrowExceptionOnInvalidJson1() sut.Invoking(x => x.CallAsync(new Uri("http://test.com/JsonReaderException"))) .Should() - .Throw(); + .ThrowAsync(); } /// @@ -213,7 +213,7 @@ public void ThrowExceptionOnInvalidJson2() sut.Invoking(x => x.CallAsync(new Uri("http://test.com/JsonSerializationException"))) .Should() - .Throw(); + .ThrowAsync(); } /// @@ -248,13 +248,13 @@ public async Task SuccesfullyReturnObject() /// Checks an exception is thrown when null is passed for the uri. /// [Fact] - public void ThrowWrappedExceptionOnNullUri() + public async Task ThrowWrappedExceptionOnNullUri() { var sut = new TestClientExecutor(_httpClient, _exceptionProvider, _resourceStringProviderFactory); - sut.Invoking(x => x.CallAsync(new Uri("http://test.com/ArgumentNullException"), ApiName)) + (await sut.Invoking(x => x.CallAsync(new Uri("http://test.com/ArgumentNullException"), ApiName)) .Should() - .Throw() + .ThrowAsync()) .WithInnerException(); } @@ -262,13 +262,13 @@ public void ThrowWrappedExceptionOnNullUri() /// Checks an exception is thrown an invalid uri is passed in. /// [Fact] - public void ThrowWrappedExceptionOnInvalidUri() + public async Task ThrowWrappedExceptionOnInvalidUri() { var sut = new TestClientExecutor(_httpClient, _exceptionProvider, _resourceStringProviderFactory); - sut.Invoking(x => x.CallAsync(new Uri("http://test.com/InvalidOperationException"), ApiName)) + (await sut.Invoking(x => x.CallAsync(new Uri("http://test.com/InvalidOperationException"), ApiName)) .Should() - .Throw() + .ThrowAsync()) .WithInnerException(); } @@ -276,13 +276,13 @@ public void ThrowWrappedExceptionOnInvalidUri() /// Checks an exception is thrown on an http failure. /// [Fact] - public void ThrowWrappedExceptionOnHttpFailure() + public async Task ThrowWrappedExceptionOnHttpFailure() { var sut = new TestClientExecutor(_httpClient, _exceptionProvider, _resourceStringProviderFactory); - sut.Invoking(x => x.CallAsync(new Uri("http://test.com/HttpRequestException"), ApiName)) + (await sut.Invoking(x => x.CallAsync(new Uri("http://test.com/HttpRequestException"), ApiName)) .Should() - .Throw() + .ThrowAsync()) .WithInnerException(); } @@ -290,13 +290,13 @@ public void ThrowWrappedExceptionOnHttpFailure() /// Checks an exception is thrown when the task is cancelled. /// [Fact] - public void ThrowWrappedExceptionOnCancelledRequest() + public async Task ThrowWrappedExceptionOnCancelledRequest() { var sut = new TestClientExecutor(_httpClient, _exceptionProvider, _resourceStringProviderFactory); - sut.Invoking(x => x.CallAsync(new Uri("http://test.com/TaskCanceledException"), ApiName)) + (await sut.Invoking(x => x.CallAsync(new Uri("http://test.com/TaskCanceledException"), ApiName)) .Should() - .Throw() + .ThrowAsync()) .WithInnerException(); } @@ -304,13 +304,13 @@ public void ThrowWrappedExceptionOnCancelledRequest() /// Checks an exception is thrown when the returned json is invalid. /// [Fact] - public void ThrowWrappedExceptionOnInvalidJson1() + public async Task ThrowWrappedExceptionOnInvalidJson1() { var sut = new TestClientExecutor(_httpClient, _exceptionProvider, _resourceStringProviderFactory); - sut.Invoking(x => x.CallAsync(new Uri("http://test.com/JsonReaderException"), ApiName)) + (await sut.Invoking(x => x.CallAsync(new Uri("http://test.com/JsonReaderException"), ApiName)) .Should() - .Throw() + .ThrowAsync()) .WithInnerException(); } @@ -318,13 +318,13 @@ public void ThrowWrappedExceptionOnInvalidJson1() /// Checks an exception is thrown when the returned json is invalid. /// [Fact] - public void ThrowWrappedExceptionOnInvalidJson2() + public async Task ThrowWrappedExceptionOnInvalidJson2() { var sut = new TestClientExecutor(_httpClient, _exceptionProvider, _resourceStringProviderFactory); - sut.Invoking(x => x.CallAsync(new Uri("http://test.com/JsonSerializationException"), ApiName)) + (await sut.Invoking(x => x.CallAsync(new Uri("http://test.com/JsonSerializationException"), ApiName)) .Should() - .Throw() + .ThrowAsync()) .WithInnerException(); } @@ -338,7 +338,7 @@ public void ThrowWrappedExceptionOnErrorJson() sut.Invoking(x => x.CallAsync(new Uri("http://test.com/Failure"), ApiName)) .Should() - .Throw() + .ThrowAsync() .Where(x => x.Data.Count == 3 && x.Data["responseBody"].ToString() == "{'Message':'Access denied'}" && diff --git a/test/Geo.Google.Tests/DependencyInjection/ServiceCollectionExtensionsTests.cs b/test/Geo.Google.Tests/DependencyInjection/ServiceCollectionExtensionsTests.cs new file mode 100644 index 0000000..9fc93c4 --- /dev/null +++ b/test/Geo.Google.Tests/DependencyInjection/ServiceCollectionExtensionsTests.cs @@ -0,0 +1,70 @@ +// +// Copyright (c) Geo.NET. +// Licensed under the MIT license. See the LICENSE file in the solution root for full license information. +// + +namespace Geo.Google.Tests.DependencyInjection +{ + using System; + using System.Net.Http; + using FluentAssertions; + using Geo.Google.Abstractions; + using Geo.Google.DependencyInjection; + using Microsoft.Extensions.DependencyInjection; + using Xunit; + + /// + /// Unit tests for the class. + /// + public class ServiceCollectionExtensionsTests + { + [Fact] + public void AddGoogleServices_WithValidCall_ConfiguresAllServices() + { + // Arrange + var services = new ServiceCollection(); + + // Act + services.AddGoogleServices(options => options.UseKey("abc")); + + // Assert + var provider = services.BuildServiceProvider(); + + provider.GetRequiredService().Should().NotBeNull(); + provider.GetRequiredService().Should().NotBeNull(); + } + + [Fact] + public void AddGoogleServices_WithNullOptions_ConfiguresAllServices() + { + // Arrange + var services = new ServiceCollection(); + + // Act + services.AddGoogleServices(null); + + // Assert + var provider = services.BuildServiceProvider(); + + provider.GetRequiredService().Should().NotBeNull(); + provider.GetRequiredService().Should().NotBeNull(); + } + + [Fact] + public void AddGoogleServices_WithClientConfiguration_ConfiguresHttpClientAllServices() + { + // Arrange + var services = new ServiceCollection(); + + // Act + services.AddGoogleServices( + options => options.UseKey("abc"), + client => client.Timeout = TimeSpan.FromSeconds(3)); + + // Assert + var provider = services.BuildServiceProvider(); + var client = provider.GetRequiredService().CreateClient("IGoogleGeocoding"); + client.Timeout.Should().Be(TimeSpan.FromSeconds(3)); + } + } +} diff --git a/test/Geo.Google.Tests/GlobalSuppressions.cs b/test/Geo.Google.Tests/GlobalSuppressions.cs new file mode 100644 index 0000000..ee6850d --- /dev/null +++ b/test/Geo.Google.Tests/GlobalSuppressions.cs @@ -0,0 +1,13 @@ +// +// Copyright (c) Geo.NET. +// Licensed under the MIT license. See the LICENSE file in the solution root for full license information. +// + +// This file is used by Code Analysis to maintain SuppressMessage +// attributes that are applied to this project. +// Project-level suppressions either have no target or are given +// a specific target and scoped to a namespace, type, member, etc. +using System.Diagnostics.CodeAnalysis; + +[assembly: SuppressMessage("Naming", "CA1707:Identifiers should not contain underscores", Justification = "Using Microsoft recommended unit test naming", Scope = "namespaceanddescendants", Target = "~N:Geo.Google.Tests")] +[assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:Elements should be documented", Justification = "The name of the test should explain the test", Scope = "namespaceanddescendants", Target = "~N:Geo.Google.Tests")] diff --git a/test/Geo.Google.Tests/TestData/CultureTestData.cs b/test/Geo.Google.Tests/TestData/CultureTestData.cs index 8963b78..057791b 100644 --- a/test/Geo.Google.Tests/TestData/CultureTestData.cs +++ b/test/Geo.Google.Tests/TestData/CultureTestData.cs @@ -17,7 +17,7 @@ public class CultureTestData : IEnumerable /// /// Gets the enumerator for the test data. /// - /// A of []. + /// An of []. public IEnumerator GetEnumerator() { var cultures = CultureInfo.GetCultures(CultureTypes.AllCultures); @@ -30,7 +30,7 @@ public IEnumerator GetEnumerator() /// /// Gets the enumerator for the test data. /// - /// A . + /// An . IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); } } diff --git a/test/Geo.Here.Tests/DependencyInjection/ServiceCollectionExtensionsTests.cs b/test/Geo.Here.Tests/DependencyInjection/ServiceCollectionExtensionsTests.cs new file mode 100644 index 0000000..701a351 --- /dev/null +++ b/test/Geo.Here.Tests/DependencyInjection/ServiceCollectionExtensionsTests.cs @@ -0,0 +1,70 @@ +// +// Copyright (c) Geo.NET. +// Licensed under the MIT license. See the LICENSE file in the solution root for full license information. +// + +namespace Geo.Here.Tests.DependencyInjection +{ + using System; + using System.Net.Http; + using FluentAssertions; + using Geo.Here.Abstractions; + using Geo.Here.DependencyInjection; + using Microsoft.Extensions.DependencyInjection; + using Xunit; + + /// + /// Unit tests for the class. + /// + public class ServiceCollectionExtensionsTests + { + [Fact] + public void AddHereServices_WithValidCall_ConfiguresAllServices() + { + // Arrange + var services = new ServiceCollection(); + + // Act + services.AddHereServices(options => options.UseKey("abc")); + + // Assert + var provider = services.BuildServiceProvider(); + + provider.GetRequiredService().Should().NotBeNull(); + provider.GetRequiredService().Should().NotBeNull(); + } + + [Fact] + public void AddHereServices_WithNullOptions_ConfiguresAllServices() + { + // Arrange + var services = new ServiceCollection(); + + // Act + services.AddHereServices(null); + + // Assert + var provider = services.BuildServiceProvider(); + + provider.GetRequiredService().Should().NotBeNull(); + provider.GetRequiredService().Should().NotBeNull(); + } + + [Fact] + public void AddHereServices_WithClientConfiguration_ConfiguresHttpClientAllServices() + { + // Arrange + var services = new ServiceCollection(); + + // Act + services.AddHereServices( + options => options.UseKey("abc"), + client => client.Timeout = TimeSpan.FromSeconds(4)); + + // Assert + var provider = services.BuildServiceProvider(); + var client = provider.GetRequiredService().CreateClient("IHereGeocoding"); + client.Timeout.Should().Be(TimeSpan.FromSeconds(4)); + } + } +} diff --git a/test/Geo.Here.Tests/GlobalSuppressions.cs b/test/Geo.Here.Tests/GlobalSuppressions.cs new file mode 100644 index 0000000..b26ae3d --- /dev/null +++ b/test/Geo.Here.Tests/GlobalSuppressions.cs @@ -0,0 +1,13 @@ +// +// Copyright (c) Geo.NET. +// Licensed under the MIT license. See the LICENSE file in the solution root for full license information. +// + +// This file is used by Code Analysis to maintain SuppressMessage +// attributes that are applied to this project. +// Project-level suppressions either have no target or are given +// a specific target and scoped to a namespace, type, member, etc. +using System.Diagnostics.CodeAnalysis; + +[assembly: SuppressMessage("Naming", "CA1707:Identifiers should not contain underscores", Justification = "Using Microsoft recommended unit test naming", Scope = "namespaceanddescendants", Target = "~N:Geo.Here.Tests")] +[assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:Elements should be documented", Justification = "The name of the test should explain the test", Scope = "namespaceanddescendants", Target = "~N:Geo.Here.Tests")] diff --git a/test/Geo.Here.Tests/TestData/CultureTestData.cs b/test/Geo.Here.Tests/TestData/CultureTestData.cs index ff866ac..d33a47d 100644 --- a/test/Geo.Here.Tests/TestData/CultureTestData.cs +++ b/test/Geo.Here.Tests/TestData/CultureTestData.cs @@ -17,7 +17,7 @@ public class CultureTestData : IEnumerable /// /// Gets the enumerator for the test data. /// - /// A of []. + /// An of []. public IEnumerator GetEnumerator() { var cultures = CultureInfo.GetCultures(CultureTypes.AllCultures); @@ -30,7 +30,7 @@ public IEnumerator GetEnumerator() /// /// Gets the enumerator for the test data. /// - /// A . + /// An . IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); } } diff --git a/test/Geo.MapBox.Tests/DependencyInjection/ServiceCollectionExtensionsTests.cs b/test/Geo.MapBox.Tests/DependencyInjection/ServiceCollectionExtensionsTests.cs new file mode 100644 index 0000000..f0bafee --- /dev/null +++ b/test/Geo.MapBox.Tests/DependencyInjection/ServiceCollectionExtensionsTests.cs @@ -0,0 +1,70 @@ +// +// Copyright (c) Geo.NET. +// Licensed under the MIT license. See the LICENSE file in the solution root for full license information. +// + +namespace Geo.MapBox.Tests.DependencyInjection +{ + using System; + using System.Net.Http; + using FluentAssertions; + using Geo.MapBox.Abstractions; + using Geo.MapBox.DependencyInjection; + using Microsoft.Extensions.DependencyInjection; + using Xunit; + + /// + /// Unit tests for the class. + /// + public class ServiceCollectionExtensionsTests + { + [Fact] + public void AddMapBoxServices_WithValidCall_ConfiguresAllServices() + { + // Arrange + var services = new ServiceCollection(); + + // Act + services.AddMapBoxServices(options => options.UseKey("abc")); + + // Assert + var provider = services.BuildServiceProvider(); + + provider.GetRequiredService().Should().NotBeNull(); + provider.GetRequiredService().Should().NotBeNull(); + } + + [Fact] + public void AddMapBoxServices_WithNullOptions_ConfiguresAllServices() + { + // Arrange + var services = new ServiceCollection(); + + // Act + services.AddMapBoxServices(null); + + // Assert + var provider = services.BuildServiceProvider(); + + provider.GetRequiredService().Should().NotBeNull(); + provider.GetRequiredService().Should().NotBeNull(); + } + + [Fact] + public void AddMapBoxServices_WithClientConfiguration_ConfiguresHttpClientAllServices() + { + // Arrange + var services = new ServiceCollection(); + + // Act + services.AddMapBoxServices( + options => options.UseKey("abc"), + client => client.Timeout = TimeSpan.FromSeconds(5)); + + // Assert + var provider = services.BuildServiceProvider(); + var client = provider.GetRequiredService().CreateClient("IMapBoxGeocoding"); + client.Timeout.Should().Be(TimeSpan.FromSeconds(5)); + } + } +} diff --git a/test/Geo.MapBox.Tests/GlobalSuppressions.cs b/test/Geo.MapBox.Tests/GlobalSuppressions.cs new file mode 100644 index 0000000..3b6781e --- /dev/null +++ b/test/Geo.MapBox.Tests/GlobalSuppressions.cs @@ -0,0 +1,13 @@ +// +// Copyright (c) Geo.NET. +// Licensed under the MIT license. See the LICENSE file in the solution root for full license information. +// + +// This file is used by Code Analysis to maintain SuppressMessage +// attributes that are applied to this project. +// Project-level suppressions either have no target or are given +// a specific target and scoped to a namespace, type, member, etc. +using System.Diagnostics.CodeAnalysis; + +[assembly: SuppressMessage("Naming", "CA1707:Identifiers should not contain underscores", Justification = "Using Microsoft recommended unit test naming", Scope = "namespaceanddescendants", Target = "~N:Geo.MapBox.Tests")] +[assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:Elements should be documented", Justification = "The name of the test should explain the test", Scope = "namespaceanddescendants", Target = "~N:Geo.MapBox.Tests")] diff --git a/test/Geo.MapBox.Tests/TestData/CultureTestData.cs b/test/Geo.MapBox.Tests/TestData/CultureTestData.cs index 4871789..c622e80 100644 --- a/test/Geo.MapBox.Tests/TestData/CultureTestData.cs +++ b/test/Geo.MapBox.Tests/TestData/CultureTestData.cs @@ -17,7 +17,7 @@ public class CultureTestData : IEnumerable /// /// Gets the enumerator for the test data. /// - /// A of []. + /// An of []. public IEnumerator GetEnumerator() { var cultures = CultureInfo.GetCultures(CultureTypes.AllCultures); @@ -30,7 +30,7 @@ public IEnumerator GetEnumerator() /// /// Gets the enumerator for the test data. /// - /// A . + /// An . IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); } } diff --git a/test/Geo.MapQuest.Tests/DependencyInjection/ServiceCollectionExtensionsTests.cs b/test/Geo.MapQuest.Tests/DependencyInjection/ServiceCollectionExtensionsTests.cs new file mode 100644 index 0000000..69d10a3 --- /dev/null +++ b/test/Geo.MapQuest.Tests/DependencyInjection/ServiceCollectionExtensionsTests.cs @@ -0,0 +1,72 @@ +// +// Copyright (c) Geo.NET. +// Licensed under the MIT license. See the LICENSE file in the solution root for full license information. +// + +namespace Geo.MapQuest.Tests.DependencyInjection +{ + using System; + using System.Net.Http; + using FluentAssertions; + using Geo.MapQuest.Abstractions; + using Geo.MapQuest.DependencyInjection; + using Microsoft.Extensions.DependencyInjection; + using Xunit; + + /// + /// Unit tests for the class. + /// + public class ServiceCollectionExtensionsTests + { + [Fact] + public void AddMapQuestServices_WithValidCall_ConfiguresAllServices() + { + // Arrange + var services = new ServiceCollection(); + + // Act + services.AddMapQuestServices(options => options.UseKey("abc")); + + // Assert + var provider = services.BuildServiceProvider(); + + provider.GetRequiredService().Should().NotBeNull(); + provider.GetRequiredService().Should().NotBeNull(); + provider.GetRequiredService().Should().NotBeNull(); + } + + [Fact] + public void AddMapQuestServices_WithNullOptions_ConfiguresAllServices() + { + // Arrange + var services = new ServiceCollection(); + + // Act + services.AddMapQuestServices(null); + + // Assert + var provider = services.BuildServiceProvider(); + + provider.GetRequiredService().Should().NotBeNull(); + provider.GetRequiredService().Should().NotBeNull(); + provider.GetRequiredService().Should().NotBeNull(); + } + + [Fact] + public void AddMapQuestServices_WithClientConfiguration_ConfiguresHttpClientAllServices() + { + // Arrange + var services = new ServiceCollection(); + + // Act + services.AddMapQuestServices( + options => options.UseKey("abc"), + client => client.Timeout = TimeSpan.FromSeconds(6)); + + // Assert + var provider = services.BuildServiceProvider(); + var client = provider.GetRequiredService().CreateClient("IMapQuestGeocoding"); + client.Timeout.Should().Be(TimeSpan.FromSeconds(6)); + } + } +} diff --git a/test/Geo.MapQuest.Tests/GlobalSuppressions.cs b/test/Geo.MapQuest.Tests/GlobalSuppressions.cs new file mode 100644 index 0000000..fbafb98 --- /dev/null +++ b/test/Geo.MapQuest.Tests/GlobalSuppressions.cs @@ -0,0 +1,13 @@ +// +// Copyright (c) Geo.NET. +// Licensed under the MIT license. See the LICENSE file in the solution root for full license information. +// + +// This file is used by Code Analysis to maintain SuppressMessage +// attributes that are applied to this project. +// Project-level suppressions either have no target or are given +// a specific target and scoped to a namespace, type, member, etc. +using System.Diagnostics.CodeAnalysis; + +[assembly: SuppressMessage("Naming", "CA1707:Identifiers should not contain underscores", Justification = "Using Microsoft recommended unit test naming", Scope = "namespaceanddescendants", Target = "~N:Geo.MapQuest.Tests")] +[assembly: SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:Elements should be documented", Justification = "The name of the test should explain the test", Scope = "namespaceanddescendants", Target = "~N:Geo.MapQuest.Tests")] diff --git a/test/Geo.MapQuest.Tests/TestData/CultureTestData.cs b/test/Geo.MapQuest.Tests/TestData/CultureTestData.cs index e6bcb1c..69e6e1e 100644 --- a/test/Geo.MapQuest.Tests/TestData/CultureTestData.cs +++ b/test/Geo.MapQuest.Tests/TestData/CultureTestData.cs @@ -17,7 +17,7 @@ public class CultureTestData : IEnumerable /// /// Gets the enumerator for the test data. /// - /// A of []. + /// An of []. public IEnumerator GetEnumerator() { var cultures = CultureInfo.GetCultures(CultureTypes.AllCultures); @@ -30,7 +30,7 @@ public IEnumerator GetEnumerator() /// /// Gets the enumerator for the test data. /// - /// A . + /// An . IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); } } diff --git a/test/Tests.with.xUnit.props b/test/Tests.with.xUnit.props index d990ea2..86d6e41 100644 --- a/test/Tests.with.xUnit.props +++ b/test/Tests.with.xUnit.props @@ -1,15 +1,15 @@ - - - - - + runtime; build; native; contentfiles; analyzers; buildtransitive all - + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive all