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 feature and unit test for bchavez#577
- Loading branch information
Showing
2 changed files
with
87 additions
and
5 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,40 @@ | ||
using FluentAssertions; | ||
using System; | ||
using System.Linq; | ||
using Xunit; | ||
|
||
namespace Bogus.Tests.GitHubIssues; | ||
|
||
public class Issue577 : SeededTest | ||
{ | ||
[Fact] | ||
public void issue_577() | ||
{ | ||
var items = Enumerable.Range(1, 10).ToArray(); | ||
|
||
var f = new Faker(); | ||
|
||
// The minimum number is more than the number of items in the list. | ||
Action minimum_bounds = () => f.PickRandom(items, 15, 25).ToList(); | ||
minimum_bounds.Should().Throw<ArgumentOutOfRangeException>(); | ||
|
||
// The maximum number is less than zero. | ||
Action maximum_bounds = () => f.PickRandom(items, 2, -1).ToList(); | ||
maximum_bounds.Should().Throw<ArgumentOutOfRangeException>(); | ||
|
||
// Should return an empty list. | ||
var pickedEmpty = f.PickRandom(items, 0, 0); | ||
pickedEmpty.Dump(); | ||
pickedEmpty.Should().BeEmpty(); | ||
|
||
// Should return NULL. | ||
var pickedNull = f.PickRandom(items, 0, 0, true); | ||
pickedNull.Dump(); | ||
pickedNull.Should().BeNull(); | ||
|
||
// Should return a list with some items. | ||
var picked = f.PickRandom(items, 2, 5); | ||
picked.Dump(); | ||
picked.Should().Equal(7, 2, 1, 4, 9); | ||
} | ||
} |
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