-
-
Notifications
You must be signed in to change notification settings - Fork 512
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement Exclude on Randomizer.Enum #7
- Loading branch information
Showing
5 changed files
with
78 additions
and
9 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
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
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,53 @@ | ||
using System; | ||
using FluentAssertions; | ||
using NUnit.Framework; | ||
|
||
namespace Bogus.Tests | ||
{ | ||
[TestFixture] | ||
public class RandomizerTest : SeededTest | ||
{ | ||
private Randomizer r; | ||
|
||
[TestFixtureSetUp] | ||
public void BeforeRunningTestSession() | ||
{ | ||
r = new Randomizer(); | ||
} | ||
|
||
public enum Foo | ||
{ | ||
ExcludeMe, | ||
A,B,C,D | ||
} | ||
|
||
[Test] | ||
public void pick_an_enum() | ||
{ | ||
var f = r.Enum<Foo>(); | ||
f.Should().Be(Foo.C); | ||
} | ||
|
||
[Test] | ||
public void exclude_an_enum() | ||
{ | ||
//seeded value of 14 gets "ExcludeMe", ensure exclude works. | ||
Randomizer.Seed = new Random(14); | ||
var f = r.Enum( exclude: Foo.ExcludeMe); | ||
f.ToString().Dump(); | ||
|
||
f.Should().NotBe(Foo.ExcludeMe); | ||
} | ||
|
||
[Test] | ||
public void exclude_all_throws_an_error() | ||
{ | ||
Action act = () => r.Enum(Foo.ExcludeMe, Foo.A, Foo.B, Foo.C, Foo.D); | ||
|
||
act.ShouldThrow<ArgumentException>(); | ||
} | ||
} | ||
|
||
|
||
|
||
} |
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
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