Contracts
public static class Contract | |
{ | |
public static void Requires(Expression<Func<bool>> assertion) | |
{ | |
if(!assertion.Compile()()) | |
{ | |
throw new ContractRequirementException(string.Format("Expression {0} evaluated to false", assertion.ToString())); | |
} | |
} | |
public static void Ensures(Expression<Func<bool>> assertion) | |
{ | |
if (!assertion.Compile()()) | |
{ | |
throw new ContractPromiseException(string.Format("Expression {0} evaluated to false", assertion.ToString())); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment