-
-
Notifications
You must be signed in to change notification settings - Fork 483
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implements .Clone() on top of flowed localized seed. #100.
- Loading branch information
Showing
4 changed files
with
128 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using FluentAssertions; | ||
using Xunit; | ||
|
||
namespace Bogus.Tests | ||
{ | ||
public class CloneTests : SeededTest | ||
{ | ||
[Fact] | ||
public void can_create_a_simple_clone() | ||
{ | ||
var orderFaker = new Faker<Examples.Order>() | ||
.UseSeed(88) | ||
.RuleFor(o => o.OrderId, f => f.IndexVariable++) | ||
.RuleFor(o => o.Quantity, f => f.Random.Number(1, 3)) | ||
.RuleFor(o => o.Item, f => f.Commerce.Product()); | ||
|
||
var clone = orderFaker.Clone(); | ||
|
||
var clonedOrder = clone.Generate(); | ||
|
||
var rootOrder = orderFaker.Generate(); | ||
|
||
clonedOrder.ShouldBeEquivalentTo(rootOrder); | ||
} | ||
|
||
[Fact] | ||
public void clone_has_different_rules() | ||
{ | ||
var rootFaker = new Faker<Examples.Order>() | ||
.UseSeed(88) | ||
.RuleFor(o => o.OrderId, f => f.IndexVariable++) | ||
.RuleFor(o => o.Quantity, f => f.Random.Number(1, 3)) | ||
.RuleFor(o => o.Item, f => f.Commerce.Product()); | ||
|
||
var cloneFaker = rootFaker.Clone() | ||
.RuleFor(o => o.Quantity, f => f.Random.Number(4, 6)); | ||
|
||
var rootOrder = rootFaker.Generate(); | ||
var clonedOrder = cloneFaker.Generate(); | ||
|
||
rootOrder.Quantity.Should() | ||
.BeGreaterOrEqualTo(1).And | ||
.BeLessOrEqualTo(3); | ||
|
||
clonedOrder.Quantity.Should() | ||
.BeGreaterOrEqualTo(4).And | ||
.BeLessOrEqualTo(6); | ||
} | ||
} | ||
} |
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