ParkSquare.Testing.Helpers
8.0.0
dotnet add package ParkSquare.Testing.Helpers --version 8.0.0
NuGet\Install-Package ParkSquare.Testing.Helpers -Version 8.0.0
<PackageReference Include="ParkSquare.Testing.Helpers" Version="8.0.0" />
paket add ParkSquare.Testing.Helpers --version 8.0.0
#r "nuget: ParkSquare.Testing.Helpers, 8.0.0"
// Install ParkSquare.Testing.Helpers as a Cake Addin #addin nuget:?package=ParkSquare.Testing.Helpers&version=8.0.0 // Install ParkSquare.Testing.Helpers as a Cake Tool #tool nuget:?package=ParkSquare.Testing.Helpers&version=8.0.0
Test Data Generators
Background
This package contains various fluent style data generators and extension methods for constrained non-determinism in your unit tests, integration tests, general automation projects and mock-ups. These are great for generating values within certain boundaries, or for creating real-world dummy data that will pass validation algorithms.
Bank Account Number
Bank account number generated by this will pass LUHN checksum and conform to UK bank account standards.
var accountNumber = AccountNumberGenerator.AnyValidAccountNumber();
Console.WriteLine(accountNumber);
Credit Card Generator
Card numbers will pass the LUHN checksum, and can specifically generate debit or credit card numbers, or ones that meet the validation checks for Visa or Mastercard.
Console.WriteLine(CreditCardGenerator.AnyCardNumber());
Console.WriteLine(CreditCardGenerator.AnyCreditCardNumber());
Console.WriteLine(CreditCardGenerator.AnyDebitCardNumber());
Console.WriteLine(CreditCardGenerator.AnyMastercardCreditCardNumber());
Console.WriteLine(CreditCardGenerator.AnyMastercardDebitCardNumber());
Console.WriteLine(CreditCardGenerator.AnyVisaCreditCardNumber());
Console.WriteLine(CreditCardGenerator.AnyVisaDebitCardNumber());
Sort Code Generator
This generates a valid UK six-digit sort code, with or without formatting.
Console.WriteLine(SortCodeGenerator.AnyValidSortCode());
Console.WriteLine(SortCodeGenerator.AnyValidSortCodeWithDashes());
Random Array Item
var testArry = new[] {"One", "Two", "Three"};
var randomItem = testArry.AnyElement();
Console.WriteLine(randomItem);
Boolean Generator
Console.WriteLine(BooleanGenerator.IsCoinTossHeads());
Byte Generator
Console.WriteLine(ByteGenerator.AnyByte());
foreach (var b in ByteGenerator.AnyByteArrayOfSize(10))
{
Console.WriteLine(b);
}
Double Generator
Console.WriteLine(DoubleGenerator.AnyDouble());
Console.WriteLine(DoubleGenerator.AnyPositiveDouble());
Console.WriteLine(DoubleGenerator.AnyNegativeDouble());
Char Generator
Console.WriteLine(CharGenerator.RandomAlpha());
Console.WriteLine(CharGenerator.RandomAlphaNumeric());
Console.WriteLine(CharGenerator.RandomChar());
Console.WriteLine(CharGenerator.RandomDigit());
Dates & Times
Dates and times relative to current date/time
Console.WriteLine(DateTime.Now.AnyTime());
Console.WriteLine(DateTime.Now.AnyDifferentTime());
Console.WriteLine(DateTime.Now.AnyTimeOtherThan(new TimeSpan(1, 2, 3, 4)));
Console.WriteLine(DateTimeGenerator.FirstDayOfThisMonth());
Console.WriteLine(DateTimeGenerator.FirstDayOfMonth(DateTime.Now));
Console.WriteLine(DateTimeGenerator.LastDayOfThisMonth());
Console.WriteLine(DateTimeGenerator.LastDayOfMonth(DateTime.Now));
Console.WriteLine(DateTimeGenerator.Today());
Console.WriteLine(DateTimeGenerator.Tomorrow());
General date/time generators
Methods ending in 'Date' will have midnight (00:00:00) as the time portion, ones ending in 'DateTime' will have a random time.
Console.WriteLine(DateTimeGenerator.AnyDate());
Console.WriteLine(DateTimeGenerator.AnyTime());
Console.WriteLine(DateTimeGenerator.AnyDateAfter(DateTime.Now));
Console.WriteLine(DateTimeGenerator.AnyDateBefore(DateTime.Now));
Console.WriteLine(DateTimeGenerator.AnyDateBetween(DateTime.Now, new DateTime(2099, 1, 1)));
Console.WriteLine(DateTimeGenerator.AnyDateExcept(DateTime.Now));
Console.WriteLine(DateTimeGenerator.AnyDateTime());
Console.WriteLine(DateTimeGenerator.AnyDateTimeAfter(DateTime.Now));
Console.WriteLine(DateTimeGenerator.AnyDateTimeExcept(DateTime.Now));
Pair of dates
These can be useful when you need a time period with a set start and end date.
var pair1 = DateTimeGenerator.AnyPairOfDateTimes();
Console.WriteLine(pair1.Min + ", " + pair1.Max);
var pair2 = DateTimeGenerator.AnyPairOfDates();
Console.WriteLine(pair2.Min + ", " + pair2.Max);
var relative1 = DateTimeGenerator.AnyRelativeDateTimes();
Console.WriteLine("Now: " + relative1.Now + " Past: " + relative1.InThePast + " Future: " + relative1.InTheFuture);
Decimal Generator
var d1 = 1.23M;
Console.WriteLine(d1.LimitedBy(1, 2));
Console.WriteLine(d1.ReverseSign());
Console.WriteLine(d1.Absolute());
Console.WriteLine(DecimalGenerator.AnyCurrencyAmount());
Console.WriteLine(DecimalGenerator.AnyCurrencyAmountGreaterThan(100));
Console.WriteLine(DecimalGenerator.AnyDecimalInHalfOpenRange(10, 100));
Console.WriteLine(DecimalGenerator.AnyPositiveCurrencyAmount());
Email Address Generator
This will generate e-mail addresses that will pass most e-mail validation algorithms.
Console.WriteLine(EmailAddressGenerator.AnyEmailAddress());
Random Items (Enumerable)
var e1 = new[] {"one", "two", "three", "four", "five"};
var e2 = e1.Shuffle();
foreach (var e in e2) Console.WriteLine(e);
Console.WriteLine(e1.AnyItem());
e1.ForEach(Console.WriteLine);
Generate Lists & Collections
var e3 = EnumerableGenerator.BoundedSequence(10, CreateNewThing);
e3.ForEach(Console.WriteLine);
var e4 = EnumerableGenerator.UniqueBoundedSequence(10, CreateNewThing);
e4.ForEach(Console.WriteLine);
Random Enum Value
Console.WriteLine(EnumGenerator.AnyEnumValue<ThingEnumeration>());
Console.WriteLine(EnumGenerator.AnyEnumValueExcept(ThingEnumeration.Hello));
Console.WriteLine(EnumGenerator.AnyEnumValueIn(ThingEnumeration.Hello, ThingEnumeration.World));
Integer Generator
Console.WriteLine(IntegerGenerator.AnyInteger());
Console.WriteLine(IntegerGenerator.AnyIntegerInHalfOpenRange(100, 1000));
var i1 = IntegerGenerator.AnyIntegerListOfSize(10);
i1.ForEach(Console.WriteLine);
var i2 = IntegerGenerator.UniquePositiveIntegerListOfSize(10);
i2.ForEach(Console.WriteLine);
Ip Address Generator
This will generate valid IP v4 addresses.
Console.WriteLine(IpAddressGenerator.AnyIpAddress());
IpAddressGenerator.GenerateRandomNonRepeatingIpAddresses(10).ForEach(Console.WriteLine);
Luhn Generator
This will generate a number of the required length, where the last digit is a valid Luhn check digit. This is the algorithm commonly used by bank accounts and credit card numbers, so if the standard UK lengths are not suitable, then use this instead.
Console.WriteLine(LuhnGenerator.AnyValidNumber(10));
Console.WriteLine(LuhnGenerator.CalculateCheckDigit("12345"));
Name Generator
These generators will create random names and titles, with the ability to have specific male or female forenames if required.
Console.WriteLine(NameGenerator.AnyName());
Console.WriteLine(NameGenerator.AnyAdultTitle());
Console.WriteLine(NameGenerator.AnyChildTitle());
Console.WriteLine(NameGenerator.AnyFemaleForename());
Console.WriteLine(NameGenerator.AnyMaleForename());
Console.WriteLine(NameGenerator.AnyForename());
Console.WriteLine(NameGenerator.AnyMaleName());
Console.WriteLine(NameGenerator.AnyFemaleName());
Console.WriteLine(NameGenerator.AnySurname());
Console.WriteLine(NameGenerator.AnyTitle());
National Insurance Number Generator (NINO)
This will generate a valid UK National Insurance number, with or without formatting.
Console.WriteLine(NationalInsuranceNumberGenerator.Any());
Console.WriteLine(NationalInsuranceNumberGenerator.AnyFormatted());
Postcode Generator
This will generate a valid UK postcode that is either a genuine postcode somewhere in the country, or one that may not necessarily be real but which passes most standard validation algorithms.
Console.WriteLine(PostcodeGenerator.AnyPostcode());
Console.WriteLine(PostcodeGenerator.AnyValidPostcode());
Short Generator
Console.WriteLine(ShortGenerator.AnyShort());
Console.WriteLine(ShortGenerator.AnyShortInHalfOpenRange(10, 100));
String Generator
Console.WriteLine(StringGenerator.AnyNonNullString());
Console.WriteLine(StringGenerator.AnyEmptyOrWhitespaceString());
Console.WriteLine(StringGenerator.AnyStringOfSizeAndCase(100, CaseType.TitleCase));
Console.WriteLine(StringGenerator.SequenceOfAlphaNumerics(10));
Console.WriteLine(StringGenerator.SequenceOfAlphas(10));
Console.WriteLine(StringGenerator.SequenceOfDigits(10));
Telephone Number Generator
This can generate a landline or mobile telephone number that will pass validation checks.
Console.WriteLine(TelephoneNumberGenerator.AnyLandlineNumber());
Console.WriteLine(TelephoneNumberGenerator.AnyMobileNumber());
Console.WriteLine(TelephoneNumberGenerator.AnyTelephoneNumber());
User Agent Generator
This will generate a user agent string.
Console.WriteLine(UserAgentGenerator.AnyUserAgent());
Console.WriteLine(UserAgentGenerator.GoogleBotUserAgent());
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- No dependencies.
-
net6.0
- No dependencies.
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
8.0.0 | 3,522 | 6/22/2024 |
3.4.7 | 22,350 | 8/22/2022 |
3.4.5 | 954 | 8/19/2022 |
3.4.4 | 32,392 | 11/22/2021 |
3.4.2 | 11,565 | 5/16/2021 |
3.4.1 | 1,920 | 4/18/2021 |
3.4.0 | 31,728 | 2/11/2020 |
3.3.0 | 15,184 | 9/2/2019 |
3.2.3 | 3,497 | 7/2/2019 |
3.2.2 | 1,831 | 6/5/2019 |
3.2.1 | 1,161 | 6/5/2019 |
3.2.0 | 1,289 | 6/4/2019 |
3.1.0 | 34,879 | 1/17/2019 |
2.5.2 | 19,760 | 7/4/2018 |
2.5.1 | 4,605 | 1/29/2018 |
2.5.0 | 1,616 | 1/29/2018 |
2.4.2 | 2,393 | 6/30/2017 |
2.4.1 | 1,750 | 6/6/2017 |
2.4.0 | 1,549 | 6/6/2017 |
2.3.0 | 1,587 | 6/2/2017 |
2.2.6 | 1,788 | 3/6/2017 |
2.2.5 | 1,639 | 3/6/2017 |
2.2.4 | 1,535 | 3/6/2017 |
2.2.3 | 1,764 | 2/20/2017 |
2.2.2 | 1,770 | 2/2/2017 |
2.2.1 | 1,617 | 2/1/2017 |
2.2.0 | 1,754 | 1/8/2017 |
2.1.55 | 1,592 | 1/3/2017 |
2.1.54 | 1,547 | 1/3/2017 |
2.1.53 | 3,261 | 9/23/2016 |
2.1.51 | 3,430 | 4/6/2016 |
2.1.50 | 1,862 | 3/26/2016 |
2.1.49 | 1,613 | 3/25/2016 |
2.1.48 | 1,616 | 3/25/2016 |
2.1.47 | 1,627 | 3/25/2016 |
2.1.46 | 1,540 | 3/25/2016 |
2.1.45 | 1,581 | 3/25/2016 |
2.1.44 | 1,963 | 3/14/2016 |
2.1.43 | 1,573 | 3/14/2016 |
2.1.42 | 1,652 | 3/14/2016 |
2.1.41 | 1,749 | 3/11/2016 |
2.1.40 | 1,709 | 3/10/2016 |
2.1.39 | 1,648 | 3/10/2016 |
2.1.38 | 1,902 | 2/20/2016 |
2.1.37 | 1,634 | 2/20/2016 |
2.1.36 | 1,603 | 2/20/2016 |
2.1.35 | 1,643 | 2/20/2016 |
2.1.34 | 1,627 | 2/18/2016 |
2.1.33 | 1,615 | 2/18/2016 |
2.1.32 | 1,614 | 2/18/2016 |
2.1.31 | 2,125 | 2/14/2016 |
2.1.30 | 1,706 | 2/13/2016 |
2.1.29 | 1,595 | 2/10/2016 |
2.1.28 | 1,591 | 2/7/2016 |
2.1.27 | 1,632 | 2/6/2016 |
2.1.26 | 1,590 | 2/6/2016 |
2.1.25 | 1,543 | 2/6/2016 |
2.1.24 | 1,596 | 2/6/2016 |
2.1.23 | 1,634 | 2/3/2016 |
2.1.22 | 2,194 | 2/1/2016 |
2.1.19 | 1,601 | 1/29/2016 |
2.1.0 | 2,739 | 1/14/2016 |
2.0.6 | 2,044 | 12/23/2015 |
2.0.5 | 1,836 | 12/22/2015 |
2.0.4 | 1,906 | 8/15/2015 |
2.0.3 | 1,572 | 8/15/2015 |
2.0.2 | 2,073 | 8/14/2015 |
2.0.1 | 2,467 | 7/29/2015 |
2.0.0 | 1,800 | 7/29/2015 |