Testing checks software behavior against requirements and builds confidence that code works as intended. Developers share responsibility for testing and maintaining the code they ship, especially when applications are delivered rapidly. section 6.1
Unit-testing practice in .NET centers on:
- Testing individual methods with quick-running tests that avoid external dependencies where possible. section 6.1
- Designing maintainable, testable code with SOLID principles; replacing complex dependencies with mocks or fakes can simplify tests. section 6.2 section 7.0
- Using xUnit facts for tests without inputs and theories for sets of inputs; assertions can check equality or verify that exceptions are thrown. section 6.7
Listing 6.17 Theory test for board sizes
[Theory]
[InlineData(8, false)] #1
[InlineData(9, true)]
public void EmptyBoardSizes(int size, bool isValid)
{
if (!isValid)
{
Assert.Throws<ArgumentException>( #2
"size", #3
() => new ArrayBoard(size)); #4
}
else
{
_ = new ArrayBoard(size); #5
}
}
A theory test checks board sizes using multiple inputs and asserts that an invalid size throws an ArgumentException. section 6.6.2




















































