Should I create my own Assert class based on these reasons?

Posted by Mike on Programmers See other posts from Programmers or by Mike
Published on 2012-03-19T14:47:37Z Indexed on 2012/03/19 18:14 UTC
Read the original article Hit count: 344

Filed under:
|
|

The main reason I don't like Debug.Assert is the fact that these assertions are disabled in Release. I know that there's a performance reason for that, but at least in my situation I believe the gains would outweigh the cost. (By the way, I'm guessing this is the situation in most cases). And yes, I know that you can use Trace.Assert instead. But even though that would work, I find the name Trace distracting, since I don't see this as tracing.

The other reason to create my own class is laziness I guess, since I could write methods for the most usual cases like Assert.IsNotNull, Assert.Equals and so forth.

The second part of my question has to do with using Environment.FailFast in this class. Would that be a good idea? I do like the ideas put forth in this document. That's pretty much where I got the idea from.

One last point. Does creating a design like this imply having an untestable code path, as described in this answer by Eric Lippert on a different (but related) question?

© Programmers or respective owner

Related posts about design

Related posts about .NET