Unit testing is supported directly in Visual Studio® 2010 editions Professional and above. Visual Studio® supports automatically creating unit tests based on your source code. You can right click a method or a class and selecting Create Unit Tests…. For example, if we right clicked on our EditInvoicePresenter
class and chose Create Unit Tests…, we'd be presented with the following form:
The default action for a class is to select all methods within the class to be tested. If we accept the defaults for this class and press OK, code similar to the following will be generated:
/// <summary> ///This is a test class for CreateInvoicePresenterTest and is /// intended to contain all CreateInvoicePresenterTest Unit ///Tests ///</summary> /// <summary> ///A test for CreateInvoicePresenter Constructor ///</summary> [TestMethod()] public void CreateInvoicePresenterConstructorTest() { ICreateInvoiceView view = null; // TODO: Initialize to // an...