SUMMARY
Unit tests should be designed to isolate and verify small parts of code. If your test strays into calls across multiple methods, you should think about your test and class design. Integration tests are important, but they serve a different purpose than unit tests. Don't confuse the purpose of unit tests with these other types of tests. Keep your unit tests small and simple and reflective of the business needs. Only write unit tests against your class's public interface, and use interfaces liberally.
NUnit and Moq are crucial tools for effectively practicing TDD. NUnit is an easy-to-use and widely popular unit testing framework for .NET. It provides facilities to write unit tests that can be executed by a test running, quickly giving you results of your test run. Moq lets you create mocks and stubs of external resources and intra-application dependencies so that you know you're focusing on only the specific code under test. Moq lets you create objects that stand in for these resources and provide some limited functionality for the code under test to verify its functionality.
Get Professional Test-Driven Development with C#: Developing Real World Applications with TDD 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.