public void SetUp() { var fn = Substitute.For <Func <StepValidatorContext, IValidator <Step> > >(); fn(Arg.Any <StepValidatorContext>()).Validate(Arg.Any <ValidationContext>()).Returns(new ValidationResult()); _stepsValidator = new StepsValidator(fn); }
private void Validate_Denies_EmptySteps() { // Arrange var steps = new List <Step>(); // Act ValidationResult result = new StepsValidator().Validate(steps); // Assert result.Errors.Should().Contain(failure => failure.PropertyName.Equals(string.Empty)); }
private void Validate_Denies_NumbersLessThanOne(int number) { // Arrange Step step = new() { Number = number, Instruction = "test" }; IList <Step> steps = new[] { step }; // Act ValidationResult result = new StepsValidator().Validate(steps); // Assert result.Errors.Should().Contain(failure => failure.PropertyName.EndsWith(nameof(Step.Number))); }
private void Validate_Denies_EmptyInstruction() { // Arrange Step step = new() { Number = 1, Instruction = string.Empty }; IList <Step> steps = new[] { step }; // Act ValidationResult result = new StepsValidator().Validate(steps); // Assert result.Errors.Should().Contain(failure => failure.PropertyName.EndsWith(nameof(Step.Instruction))); } }