Blog

Design by Contract - The Sequel

November 20, 2007

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.

If you're interested in an in-person or online course that teaches you and your team how to write maintainable unit tests and get the most out of TDD practices, make sure to have a look at our trainings and workshops or contact us at infonull@nullprincipal-itnull.be.

Profile picture of Jan Van Ryswyck

Jan Van Ryswyck

Thank you for visiting my blog. I’m a professional software developer since Y2K. A blogger since Y2K+5. Provider of training and coaching in XP practices. Curator of the Awesome Talks list. Past organizer of the European Virtual ALT.NET meetings. Thinking and learning about all kinds of technologies since forever.

Comments

About

Thank you for visiting my website. I’m a professional software developer since Y2K. A blogger since Y2K+5. Provider of training and coaching in XP practices. Curator of the Awesome Talks list. Past organizer of the European Virtual ALT.NET meetings. Thinking and learning about all kinds of technologies since forever.

Latest articles





Contact information

(+32) 496 38 00 82

infonull@nullprincipal-itnull.be