public List <Contractor> GetContractorsAged(DateTime minDate, DateTime?maxDate) { Fail.IfNotDate(minDate, Violation.Of("minDate must be a midnight")); Fail.IfNotDate(maxDate, Violation.Of("maxDate must be a midnight")); // WARN: Below is sample code with no sense at all return(new List <Contractor>(0)); }
public void IfNotMidnightWithMessage(DateTime dateTime) { // ACT var exception = Assert.Throws <DesignByContractViolationException>( () => Fail.IfNotDate(dateTime, Violation.Of("date should have no hour nor second")) ); // ASSERT Assert.That(exception.Message, Is.EqualTo("date should have no hour nor second")); }
public void IfNotMidnightSuccessWithName(DateTime?date) { // ACT Fail.IfNotDate(date, nameof(date)); }
public void IfNotMidnightSuccessWithMessage(DateTime?date) { // ACT Fail.IfNotDate(date, Violation.Of("date should have no hour nor second")); }