-
-
Notifications
You must be signed in to change notification settings - Fork 513
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tests: Use file-scoped namespaces. (#520)
- Loading branch information
Showing
103 changed files
with
7,377 additions
and
7,485 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 |
---|---|---|
@@ -1,50 +1,49 @@ | ||
using FluentAssertions; | ||
using Xunit; | ||
|
||
namespace Bogus.Tests | ||
namespace Bogus.Tests; | ||
|
||
public class CloneTests : SeededTest | ||
{ | ||
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.Should().BeEquivalentTo(rootOrder); | ||
} | ||
|
||
[Fact] | ||
public void clone_has_different_rules() | ||
{ | ||
[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.Should().BeEquivalentTo(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); | ||
} | ||
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); | ||
} | ||
} |
Oops, something went wrong.