diff --git a/TestStack.Dossier.Tests/DataSources/Picking/PickingTests.cs b/TestStack.Dossier.Tests/DataSources/Picking/PickingTests.cs new file mode 100644 index 0000000..566161c --- /dev/null +++ b/TestStack.Dossier.Tests/DataSources/Picking/PickingTests.cs @@ -0,0 +1,48 @@ +using System.Linq; +using Shouldly; +using TestStack.Dossier.DataSources.Picking; +using TestStack.Dossier.Lists; +using TestStack.Dossier.Tests.TestHelpers.Objects.Entities; +using Xunit; + +namespace TestStack.Dossier.Tests.DataSources.Picking +{ + public class PickingTests + { + [Fact] + public void RandomItemFrom_should_add_items_from_list_randomly() + { + var addresses = Builder
.CreateListOfSize(15).BuildList(); + var customers = Builder + .CreateListOfSize(15) + .All() + .Set(x => x.PostalAddress, Pick.RandomItemFrom(addresses).Next) + .BuildList(); + + var uniqueAddresses = customers.Select(x => x.PostalAddress).Distinct().Count(); + uniqueAddresses.ShouldBeGreaterThan(3); + uniqueAddresses.ShouldBeLessThan(15); + } + + [Fact] + public void RepeatingSequenceFrom_should_add_items_from_list_sequentially_and_repeat_when_list_completes() + { + var addresses = Builder
.CreateListOfSize(3).BuildList(); + var customers = Builder + .CreateListOfSize(9) + .All() + .Set(x => x.PostalAddress, Pick.RepeatingSequenceFrom(addresses).Next) + .BuildList(); + + for (int i = 0; i < 2; i++) + { + var address = customers[i].PostalAddress; + address.ShouldBeSameAs(customers[i + 3].PostalAddress); + address.ShouldBeSameAs(customers[i + 6].PostalAddress); + + address.ShouldNotBeSameAs(customers[i + 1].PostalAddress); + address.ShouldNotBeSameAs(customers[i + 2].PostalAddress); + } + } + } +} diff --git a/TestStack.Dossier.Tests/TestStack.Dossier.Tests.csproj b/TestStack.Dossier.Tests/TestStack.Dossier.Tests.csproj index e8fe2ff..b9368a6 100644 --- a/TestStack.Dossier.Tests/TestStack.Dossier.Tests.csproj +++ b/TestStack.Dossier.Tests/TestStack.Dossier.Tests.csproj @@ -58,6 +58,7 @@ + @@ -119,6 +120,7 @@ TestStack.Dossier +