-
-
Notifications
You must be signed in to change notification settings - Fork 0
fix: throw ArgumentOutOfRangeException when times of For is not positive
#369
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -319,6 +319,23 @@ public async Task CallbackWithValue_ShouldNotExecuteWhenParameterDoesNotMatch() | |
| await That(callCount).IsEqualTo(0); | ||
| } | ||
|
|
||
| [Theory] | ||
| [InlineData(-2)] | ||
| [InlineData(0)] | ||
| public async Task For_LessThanOne_ShouldThrowArgumentOutOfRangeException(int times) | ||
| { | ||
| IReturnMethodSetupTest sut = Mock.Create<IReturnMethodSetupTest>(); | ||
|
|
||
| void Act() | ||
| { | ||
| sut.SetupMock.Method.Method1(It.IsAny<int>()) | ||
| .Returns("").For(times); | ||
| } | ||
|
|
||
| await That(Act).Throws<ArgumentOutOfRangeException>() | ||
| .WithMessage("Times must be greater than zero.").AsPrefix(); | ||
| } | ||
|
|
||
| [Fact] | ||
| public async Task For_ShouldStopExecutingCallbackAfterTheGivenTimes() | ||
| { | ||
|
|
@@ -377,6 +394,23 @@ public async Task InParallel_ShouldInvokeParallelCallbacksAlways() | |
| await That(callCount3).IsEqualTo(6); | ||
| } | ||
|
|
||
| [Theory] | ||
| [InlineData(-2)] | ||
| [InlineData(0)] | ||
| public async Task Only_LessThanOne_ShouldThrowArgumentOutOfRangeException(int times) | ||
| { | ||
| IReturnMethodSetupTest sut = Mock.Create<IReturnMethodSetupTest>(); | ||
|
|
||
| void Act() | ||
| { | ||
| sut.SetupMock.Method.Method1(It.IsAny<int>()) | ||
| .Returns("").Only(times); | ||
|
Comment on lines
+406
to
+407
|
||
| } | ||
|
|
||
| await That(Act).Throws<ArgumentOutOfRangeException>() | ||
| .WithMessage("Times must be greater than zero.").AsPrefix(); | ||
| } | ||
|
|
||
| [Theory] | ||
| [InlineData(1, 1)] | ||
| [InlineData(2, 3)] | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test validates the
Formethod but usesReturns("")which tests a different code path than the callback-focusedDo()method. Consider adding a test that uses.Do(() => { }).For(times)to match the property setup test pattern and ensure validation works consistently across both setup approaches.