public void Returns_an_error_for_each_failed_requirement() { var reqA = new Mock <AbstractRequirement <string> >() { CallBase = true }; reqA.Setup(t => t.Check(It.IsAny <string>())).Returns(new[] { new ValidationError { Message = "A" } }); var reqB = new Mock <AbstractRequirement <string> >() { CallBase = true }; reqB.Setup(t => t.Check(It.IsAny <string>())).Returns(new ValidationError[0]); var reqC = new Mock <AbstractRequirement <string> >() { CallBase = true }; reqC.Setup(t => t.Check(It.IsAny <string>())).Returns(new[] { new ValidationError { Message = "C" } }); var val = new _Validator <object>(); var reqs = val._Require(t => t.ToString()); reqs.ContinueOnError = true; reqs.Add(reqA.Object); reqs.Add(reqB.Object); reqs.Add(reqC.Object); var list = val.Check("").ToList(); Assert.Equal(2, list.Count); }
public void Returns_an_empty_enumeration_when_no_requirements() { var val = new _Validator <object>(); val._Require(t => t.ToString()); Assert.Empty(val.Check("")); }