using System.Threading.Tasks;
using System.Collections.Generic;
public static void Main()
var reservationGenerator = new Faker<Reservation>("pl")
.RuleFor(x => x.Id, f => Guid.NewGuid())
.RuleFor(x => x.EmployeeName, f => f.Person.FullName)
.RuleFor(x => x.LicensePlate, f => f.Lorem.Text())
.RuleFor(x => x.Date, f => f.Date.Between(DateTime.Now.AddDays(-7), DateTime.Now).Date);
var reservation = reservationGenerator.Generate();
public Guid Id {get; private set; }
public string EmployeeName {get; private set; }
public string LicensePlate {get; private set; }
public DateTime Date {get; private set; }
public Reservation(Guid id, string employeeName, string licensePlate, DateTime date)
EmployeeName = employeeName;
LicensePlate = licensePlate;
[Collection(nameof(CategoryTestFixture))]
private readonly CategoryTestFixture _categoryTestFixture;
public UnitTest1(CategoryTestFixture categoryTestFixture)
_categoryTestFixture = categoryTestFixture;
[Trait("UnitTests", nameof(ValidarConstruirObjetoCategory))]
public Task ValidarConstruirObjetoCategory()
var obj = _categoryTestFixture.GetNewValidCategory();
Assert.NotNull(obj.Name);
Assert.True(obj.Name.Length.Between(Category.MIN_NAME_LENGTH, Category.MAX_NAME_LENGTH));
return Task.CompletedTask;
[Trait("UnitTests", nameof(ValidarAlgumaCoisa))]
[MemberData(nameof(GetAlgumaCoisa), parameters: 15)]
public Task ValidarAlgumaCoisa(string algumaCoisa)
Assert.NotNull(algumaCoisa);
Console.WriteLine(algumaCoisa);
return Task.CompletedTask;
public static IEnumerable<object[]> GetAlgumaCoisa(int numberIterations = 15)
var fixture = new CategoryTestFixture();
for (int i = 0; i < numberIterations; i++)
yield return new object[] { fixture.GetValidName() };
public sealed class Category
public const int MIN_NAME_LENGTH = 5;
public const int MAX_NAME_LENGTH = 50;
public string Name { get; init; }
public Category(string name)
public bool IsValid() => Name != null && Name.Length.Between(MIN_NAME_LENGTH, MAX_NAME_LENGTH);
throw new InvalidOperationException();
public static class NumberExtensions
public static bool Between(this int number, int start, int end)
=> number >= start && number <= end;
public abstract class FixtureBase
protected readonly Faker faker = new("pt_BR");
public sealed class CategoryTestFixture : FixtureBase
public Category GetNewValidCategory()
=> new Category(GetValidName());
public string GetValidName()
var name = faker.Person.FullName;
while (name.Length < Category.MIN_NAME_LENGTH)
name = faker.Person.FullName;
if (name.Length > Category.MAX_NAME_LENGTH)
name = name[0..Category.MAX_NAME_LENGTH];
[CollectionDefinition(nameof(CategoryTestFixture))]
public sealed class CategoryTestFixtureCollection : ICollectionFixture<CategoryTestFixture> { }