Skip to content

Commit

Permalink
Fix review comment, faulty input check ProgressiveTimeout class
Browse files Browse the repository at this point in the history
  • Loading branch information
helto4real committed Jul 1, 2024
1 parent bbe824b commit 234c6ed
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public void TestProgressiveTimeoutInputChecksThrows()
Assert.Throws<ArgumentOutOfRangeException>(() => new ProgressiveTimeout(TimeSpan.Zero, TimeSpan.FromSeconds(100), 2.0));
// Check that max timeout is greater than start timeout
Assert.Throws<ArgumentOutOfRangeException>(() => new ProgressiveTimeout(TimeSpan.FromSeconds(100), TimeSpan.FromSeconds(99), 2.0));
// Check that max timeout is not same as start timeout
Assert.Throws<ArgumentOutOfRangeException>(() => new ProgressiveTimeout(TimeSpan.FromSeconds(100), TimeSpan.FromSeconds(100), 2.0));
// Check that increase factor is greater than 1
Assert.Throws<ArgumentOutOfRangeException>(() => new ProgressiveTimeout(TimeSpan.FromSeconds(10), TimeSpan.FromSeconds(100), 1.0));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,9 @@ public class ProgressiveTimeout

public ProgressiveTimeout(TimeSpan initialTimeout, TimeSpan maxTimeout, double increaseFactor)
{
if (initialTimeout <= TimeSpan.Zero)
throw new ArgumentOutOfRangeException(nameof(initialTimeout), "Initial timeout must be greater than zero.");

if (maxTimeout < initialTimeout)
throw new ArgumentOutOfRangeException(nameof(maxTimeout), "Max timeout must be greater than or equal to initial timeout.");

if (increaseFactor <= 1)
throw new ArgumentOutOfRangeException(nameof(increaseFactor), "Increase factor must be greater than 1.");
ArgumentOutOfRangeException.ThrowIfLessThanOrEqual(initialTimeout, TimeSpan.Zero, nameof(initialTimeout));
ArgumentOutOfRangeException.ThrowIfLessThanOrEqual(maxTimeout, initialTimeout, nameof(maxTimeout));
ArgumentOutOfRangeException.ThrowIfLessThanOrEqual(increaseFactor, 1, nameof(increaseFactor));

_initialTimeout = initialTimeout;
_maxTimeout = maxTimeout;
Expand Down

0 comments on commit 234c6ed

Please sign in to comment.