Unit Testing
A proven technique to catch bugs and regressions early is to use unit tests that exercise various parts of the system by feeding in different combinations of input and checking the expected output. Various unit testing frameworks for .NET have been created over the years (NUnit being one of the most popular ones), and for the past few releases Visual Studio has built-in support for unit testing.
To set the scene, consider a very simple Calculator
class definition, as shown here:
public static class Calculator{ public static int Add(int a, int b) { return a + b; } public static int Subtract(int a, int b) { return a - b; } public static int Multiply(int a, int b) { return a * b; } public ...
Get C# 4.0 Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.