Project Description
FluentValidation.Validators.UnitTestExtension
Links
GitHub: https://github.com/MichalJankowskii/FluentValidation.Validators.UnitTestExtension
NuGet: https://www.nuget.org/packages/FluentValidation.Validators.UnitTestExtension
Description
Main purpose of this small library is to extend and simplify possibilities of testing code that is using FluentValidation package.
This library allows you to focus on testing your implementation. You will be able to write test that will run faster, will be readable and will test only your implementation.
Please look at the following example of PersonValidator:
public class PersonValidator : AbstractValidator<Person> { public PersonValidator() { RuleFor(person => person.Name).NotNull(); } }
By using this library you can write unit test like this:
public class PersonValidatorTests { [Fact] public void When_PersonValidatorConstructing_Then_RulesAreConfiguredCorrectly() { var personValidator = new PersonValidator(); personValidator.ShouldHaveRules(x => x.Name, BaseVerifiersSetComposer.Build() .AddPropertyValidatorVerifier<NotNullValidator>() .Create()); } }
By using this library you will be:
- more effective in writing unit tests
- you will be testing only your code
- your test will be more robustness
- moreover you will be able to check order of validators
- and many more.
Leave A Comment