Creating tests using IntelliTest
IntelliTest allows developers to create and run tests against their code contracts. This allows developers to create the most robust code possible by creating additional code contracts to pass the test failures reported by IntelliTest. One thing to note, however, is that IntelliTest is included in the Visual Studio Enterprise only.
Getting ready
You will need to use Visual Studio Enterprise 2015 to be able to create and run IntelliTests.
How to do it…
Before you go on, ensure that you have added the code contracts
using
statement to the top of yourRecipes.cs
class file:using System.Diagnostics.Contracts;
Add a new class called
CodeContractTests
to yourRecipes.cs
file:public class CodeContractTests { }
Then, add a method called
Calculate()
to theCodeContractTests
class and pass two integer values as parameters to theCalculate()
method. Inside theCalculate()
method, add a code contract to ensure that the result from this method is never equal to zero:public...