Skip to content

Commit

Permalink
Resolve #425 (#451)
Browse files Browse the repository at this point in the history
* Resolve #425

* Update additional tests

---------

Co-authored-by: Philip Reed <[email protected]>
  • Loading branch information
philip-reed and Philip Reed authored Jun 28, 2024
1 parent c77201e commit ce86f00
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
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

0 comments on commit ce86f00

Please sign in to comment.