Chapter 8. Code Contracts
This chapter will introduce you to code contracts. This is a very powerful technology and one that will enable you to secure your code from unnecessary errors. This is especially true when you are writing a class that is shared between several developers. Code contracts allow you to inspect and handle data passed to your method under contract. If the contract fails its validation, you can take decisive action within your method to handle this eventuality. This chapter will cover the following recipes:
- Downloading, installing, and integrating code contracts into Visual Studio
- Creating code contract preconditions
- Creating code contract postconditions
- Creating code contract invariant
- Creating code contract
Assert
andAssume
methods - Creating code contract
ForAll
method - Creating code contract
ValueAtReturn
method - Creating code contract
Result
method - Using code contracts on abstract classes
- Using contract abbreviator methods
- Creating tests using IntelliTest
- Using code...