Skip to content

Commit

Permalink
add doc comments for new ConfigurationExtensions overloads
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerReid committed Mar 21, 2023
1 parent 2a8442f commit db5fd31
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,23 @@ public static AWSOptions GetAWSOptions(this IConfiguration config)
return GetAWSOptions(config, DEFAULT_CONFIG_SECTION);
}

/// <summary>
/// Constructs an AWSOptions class with the options specified in the "AWS" section in the IConfiguration object.
/// </summary>
/// <param name="config"></param>
/// <param name="configSection">The config section to extract AWS options from.</param>
/// <returns>The AWSOptions containing the values set in configuration system.</returns>
public static AWSOptions GetAWSOptions(this IConfiguration config, string configSection)
{
return GetAWSOptions<DefaultClientConfig>(config, configSection);
}

/// <summary>
/// Constructs an AWSOptions class with the options specified in the "AWS" section in the IConfiguration object.
/// </summary>
/// <typeparam name="TConfig">The AWS client config to be used in creating clients, like AmazonS3Config.</typeparam>
/// <param name="config"></param>
/// <returns>The AWSOptions containing the values set in configuration system.</returns>
public static AWSOptions GetAWSOptions<TConfig>(this IConfiguration config) where TConfig : ClientConfig, new()
{
return GetAWSOptions<TConfig>(config, DEFAULT_CONFIG_SECTION);
Expand All @@ -58,6 +70,7 @@ public static AWSOptions GetAWSOptions(this IConfiguration config, string config
/// <summary>
/// Constructs an AWSOptions class with the options specified in the "AWS" section in the IConfiguration object.
/// </summary>
/// <typeparam name="TConfig">The AWS client config to be used in creating clients, like AmazonS3Config.</typeparam>
/// <param name="config"></param>
/// <param name="configSection">The config section to extract AWS options from.</param>
/// <returns>The AWSOptions containing the values set in configuration system.</returns>
Expand Down
40 changes: 20 additions & 20 deletions extensions/test/NETCore.SetupTests/ConfigurationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ public void GetClientConfigSettingsTest()
Assert.Equal(DefaultConfigurationMode.Standard, client.Config.DefaultConfigurationMode);
Assert.Equal(RequestRetryMode.Adaptive, client.Config.RetryMode);

// verify S3 config specific settings are not configured
var clientConfig = client.Config as AmazonS3Config;
Assert.NotNull(clientConfig);
// verify S3 config specific settings are not configured
var clientConfig = client.Config as AmazonS3Config;
Assert.NotNull(clientConfig);
Assert.False(clientConfig.ForcePathStyle);
}

Expand Down Expand Up @@ -210,22 +210,22 @@ public void TestRegionFoundFromEnvironmentVariable()
}

[Fact]
public void ClientConfigTypeOverloadTest()
{
var config = new ConfigurationBuilder()
.AddJsonFile("./TestFiles/GetClientConfigSettingsTest.json")
.Build();

var options = config.GetAWSOptions<AmazonS3Config>();

public void ClientConfigTypeOverloadTest()
{
var config = new ConfigurationBuilder()
.AddJsonFile("./TestFiles/GetClientConfigSettingsTest.json")
.Build();

var options = config.GetAWSOptions<AmazonS3Config>();

Assert.Equal(RegionEndpoint.USWest2, options.Region);
Assert.True(options.DefaultClientConfig.UseHttp);
Assert.Equal(6, options.DefaultClientConfig.MaxErrorRetry);
Assert.Equal(TimeSpan.FromMilliseconds(1000), options.DefaultClientConfig.Timeout);
Assert.Equal("us-east-1", options.DefaultClientConfig.AuthenticationRegion);
Assert.Equal(DefaultConfigurationMode.Standard, options.DefaultConfigurationMode);

var client = options.CreateServiceClient<IAmazonS3>();
Assert.Equal(DefaultConfigurationMode.Standard, options.DefaultConfigurationMode);

var client = options.CreateServiceClient<IAmazonS3>();
Assert.NotNull(client);
Assert.Equal(RegionEndpoint.USWest2, client.Config.RegionEndpoint);
Assert.True(client.Config.UseHttp);
Expand All @@ -239,12 +239,12 @@ public void ClientConfigTypeOverloadTest()
options.DefaultClientConfig.RetryMode = RequestRetryMode.Adaptive;
client = options.CreateServiceClient<IAmazonS3>();
Assert.Equal(DefaultConfigurationMode.Standard, client.Config.DefaultConfigurationMode);
Assert.Equal(RequestRetryMode.Adaptive, client.Config.RetryMode);

// verify S3 config specific settings are configured
var clientConfig = client.Config as AmazonS3Config;
Assert.NotNull(clientConfig);
Assert.True(clientConfig.ForcePathStyle);
Assert.Equal(RequestRetryMode.Adaptive, client.Config.RetryMode);

// verify S3 config specific settings are configured
var clientConfig = client.Config as AmazonS3Config;
Assert.NotNull(clientConfig);
Assert.True(clientConfig.ForcePathStyle);
}
}
}

0 comments on commit db5fd31

Please sign in to comment.