January 2011
6 posts
What Love Really Means →
One of my new favorite songs.
Jan 28th
Windows Visa/7 Repair disks →
Great article on creating repair disks for Windows Vista/7.
Jan 27th
4 tags
Exploiting NUnit attributes (ValuesAttribute)
Similar to my last post about using NUnit’s ValueSourceAttribute, this post offers another example of how to extend an NUnit attribute to get better unit tests. For this example NUnit version 2.5 or greater is required.  Consider the following enum and test object. public enum AnimalEnum : byte { None, Dog, Cat } public class ObjectToTest { public object...
Jan 23rd
6 notes
Exploiting NUnit attributes (ValueSourceAttribute)
Often times it become necessary to use reflection in a unit test to verify that all child classes pass a particular test. There are three basic ways to handle this: Don’t write the test, code with no tests is always bug-free right? Create an array of all of the child types. This is easy to do but not very scalable if the object is likely to be extended many times.  Use reflection to find...
Jan 21st
2 tags
Dynamic context menu not showing on first click
Today I was faced with a very interesting problem. Given a user control the context menu was not being shown the first time the user right clicked. There was nothing special about the user control nor the context menu except that the menu items were dynamically generated during the context menu’s opening event. Consider the follow code snippet: bool _showItem1; bool _showItem2; private...
Jan 6th
3 tags
Toggle an enum
Recently I have run into the problem where I created an enum to keep track of two states within my object. Sure  could have just used a boolean but the enum seemed to make the code easier to read. private enum SomeEnum : byte { FirstValue = 0, SecondValue = 1 } private SomeEnum _value; public void ToggleValue() { ...
Jan 5th
1 note