forked from bchavez/Bogus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added unit test class Issue319 for bchavez#319 with test cases decima…
…l_with_very_large_range_succeeds to Bogus.Tests. Updated Randomizer.Decimal to make the test pass.
- Loading branch information
Showing
2 changed files
with
98 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using System.Collections.Generic; | ||
using System.Reflection; | ||
using FluentAssertions; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
using Xunit.Sdk; | ||
|
||
namespace Bogus.Tests.GitHubIssues | ||
{ | ||
public class Issue319 : SeededTest | ||
{ | ||
class TestDataProvider : DataAttribute | ||
{ | ||
public override IEnumerable<object[]> GetData(MethodInfo testMethod) | ||
{ | ||
yield return new object[] { 0m, decimal.MaxValue }; | ||
yield return new object[] { decimal.MinValue, decimal.MaxValue }; | ||
yield return new object[] { decimal.MinValue, 0m }; | ||
// A range whose size exceeds decimal.MaxValue but which doesn't have decimal.MinValue or decimal.MaxValue as a bound. | ||
yield return new object[] { decimal.MinValue * 0.6m, decimal.MaxValue * 0.6m }; | ||
} | ||
} | ||
|
||
ITestOutputHelper _output; | ||
|
||
public Issue319(ITestOutputHelper output) | ||
=> _output = output; | ||
|
||
[Theory, TestDataProvider] | ||
public void decimal_with_very_large_range_succeeds(decimal min, decimal max) | ||
{ | ||
var randomizer = new Randomizer(); | ||
|
||
for (int iteration = 0; iteration < 300; iteration++) | ||
{ | ||
try | ||
{ | ||
randomizer.Decimal(min, max).Should().BeInRange(min, max); | ||
} | ||
catch | ||
{ | ||
_output.WriteLine("Test failed on iteration {0}", iteration); | ||
throw; | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters