I’m a bit of a noob regarding unit testing but I’m puzzled on how to write proper tests for validation methods. Simple example:
public void EnsureExactly5Chars(string s)
How would you write tests for this method? One test that provides a string of 5 chars is expected but how many tests that expect this method to fail? One, two, thousands?
Another example would be:
public void EnsureDateIsYYMMDD(string date)
You need to test the a valid value passes, that a patently invalid value fails and also edge cases.
For your string example, you should test with a 5 char string that passes, a long string, a short string (1 char?) and edge cases (null, string.Empty, 4 characters and 6 characters).