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

Resolve #425 #451

Merged
merged 2 commits into from
Jun 28, 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
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,13 @@ public ContainerOptionsBuilder WithManualThroughput(int throughput = 400)
/// <param name="maxAutoScaleThroughput">The maximum RU/s that this containers throughput can autoscale to.</param>
/// <remarks>If a container has already been created without specifying a throughput then it cannot be updated.</remarks>
/// <returns>Instance of <see cref="ContainerOptionsBuilder"/></returns>
public ContainerOptionsBuilder WithAutoscaleThroughput(int maxAutoScaleThroughput = 4_000)
public ContainerOptionsBuilder WithAutoscaleThroughput(int maxAutoScaleThroughput = 1_000)
{
if (maxAutoScaleThroughput is < 4_000 or > 1_000_000)
if (maxAutoScaleThroughput is < 1_000 or > 1_000_000)
{
throw new ArgumentOutOfRangeException(
nameof(maxAutoScaleThroughput),
"Autoscale throughput must be between 4,000 and 1,000,000 RUs.");
"Autoscale throughput must be between 1,000 and 1,000,000 RUs.");
}

if (maxAutoScaleThroughput % 1000 != 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,16 @@ public void RepositoryOptionsBuilderThrowsArgumentNullExceptionWhenContainerBuil
=> Assert.Throws<ArgumentNullException>(() => new RepositoryOptions().ContainerBuilder.Configure<Product>(null!));

[Theory]
[InlineData(300)]
[InlineData(90)]
[InlineData(1_100_000)]
public void RepositoryOptionsBuilderThrowsOutOfRangeExceptionWhenAutoscaleThroughputIsOutOfRange(int throughput) =>
Assert.Throws<ArgumentOutOfRangeException>(() => new RepositoryOptions().ContainerBuilder.Configure<Product>(builder => builder.WithAutoscaleThroughput(throughput)));

[Theory]
[InlineData(1500)]
[InlineData(1_150_000)]
[InlineData(2200)]
public void RepositoryOptionsBuilderThrowsInvalidOperationExceptionWhenAutoscaleThroughputNotAMultipleOf1000(int throughput) =>
Assert.Throws<ArgumentOutOfRangeException>(() => new RepositoryOptions().ContainerBuilder.Configure<Product>(builder => builder.WithAutoscaleThroughput(throughput)));

Assert.Throws<InvalidOperationException>(() => new RepositoryOptions().ContainerBuilder.Configure<Product>(builder => builder.WithAutoscaleThroughput(throughput)));

[Theory]
[InlineData(200)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public void GetThroughputPropertiesItemAutoscaleThroughputProperties()
_repositoryOptions.ContainerBuilder.Configure<TestItemWithEtag>(builder => builder.WithAutoscaleThroughput());
ThroughputProperties? throughputProperties = _provider.GetThroughputProperties<TestItemWithEtag>();

Assert.Equal(4000, throughputProperties!.AutoscaleMaxThroughput);
Assert.Equal(1000, throughputProperties!.AutoscaleMaxThroughput);
Assert.Null(throughputProperties.Throughput);
}

Expand All @@ -49,7 +49,7 @@ public void GetThroughputPropertiesItemsWithConflictingAutoScaleValues()
InvalidOperationException exception = Assert.Throws<InvalidOperationException>(() => _provider.GetThroughputProperties<TestItemWithEtag>());

Assert.Contains("autoscale", exception.Message);
Assert.Contains("4000", exception.Message);
Assert.Contains("1000", exception.Message);
Assert.Contains("5000", exception.Message);
}

Expand Down