For unit testing in C#, I see the point from the idea of when implementing a new feature or begning a new solution, its better to start with the unit testing from then.
But when there is a fully fledged solution already established with little or no Unit Tests created, what is the point in testing when there is a more than adequate exception handling in place already ?
Im writing unit tests but fail to see the point when i cant pass through malformed data ANYWAY into anything im testing as i have used ENUM’s mostly!
Unless I missing something absolutely crazy.. Am I wasting time going back to older code to integrate Unit Tests ?
Writing unit tests for existing code is helpful when you’re currently or in the future going to work at it. The tests help you make sure that you’re not introducing any new bugs or unwillingly change some behavior.
Also, writing tests for existing code can help determining the actual functionality of possibly unknown or complicated implementations.
In the unlikely case of bug-free software that will never be touched by a developer again adding unit tests probably won’t help you much. But in any other case it helps document the behavior and establish a safety net for the future.
Oh, and since you mention it: Using
enumswon’t protect you from passing invalid arguments in C#.