Partial Classes and Unit Tests
Just thought of something. A few times when I needed to create unit tests that covered private members, one thing I did was create nested classes. I never liked this approach but in a few cases, it seemed a lot cleaner than the alternatives (after all, changing member access just to accomodate unit tests seemed equally absurd). Anyway, I was playing around with some stuff for my book today and got to thinking about it. You can use a partial to hold your unit tests for a class. This will give you access to your private members without messing with your access modifiers. Then, if you need to remove them before a shipment, you can do it a lot easier. Still seems kind of klunky but ostensibly a cleaner solution than the previous way of handling it - this way your code file can hold your 'real' code and the partial file can hold the unit test stuff. This isn't my idea, I remember reading about it a long time ago I just don't remember where I read it so I can't give the original author credit.
Anyone doing something like this?