In this post I put out some code for checking method arguments. I changed it somewhat regarding value types:
public void DoSomethingMeaningfull(Int32 someNumber) { // Throws ArgumentOutOfRangeException Check.Argument((IComparable<Int32>)someNumber, "someNumber").IsNotNegative(); }
public void DoSomethingMeaningfull(Int32 someNumber) { // Throws ArgumentOutOfRangeException Check.Argument((IComparable<Int32>)someNumber, "someNumber").IsNotPositive(); }
public void DoSomethingMeaningfull(Int32 someNumber) { // Throws ArgumentOutOfRangeException Check.Argument((IComparable<Int32>)someNumber, "someNumber").IsNotZero(); }
As you can see, I opened it up for all comparable types. The code for this can be downloaded here. Please let me know what you think.