public async Task Run_ReturnsSkip() { // Arrange Func <bool> shouldRun = () => false; Action runInternal = () => { }; var validator = new TestableValidator(shouldRun, runInternal); var context = new ValidationContext(); // Act var result = await validator.ValidateAsync(context); // Assert Assert.Same(validator, result.Validator); Assert.Equal(TestResult.Skip, result.Result); Assert.Null(result.Exception); }
public async Task Run_ReturnsFail() { // Arrange var exception = new Exception(); Func <bool> shouldRun = () => true; Action runInternal = () => { throw exception; }; var validator = new TestableValidator(shouldRun, runInternal); var context = new ValidationContext(); // Act var result = await validator.ValidateAsync(context); // Assert Assert.Same(validator, result.Validator); Assert.Equal(TestResult.Fail, result.Result); Assert.Same(exception, result.Exception); }