I have the following code:
class Program
{
static void Main(string[] args)
{
Console.WriteLine(SqrtRoot(0));
Console.WriteLine(SqrtRoot(10));
Console.WriteLine(SqrtRoot(-10));
Console.ReadKey();
}
public static int SqrtRoot(int i)
{
Contract.Requires(i >= 0);
return (int)Math.Sqrt(i);
}
}
I am running it in debug mode, and it should fire some kind of error in the last line
Console.WriteLine(SqrtRoot(-10));
altough, for some reason, it doesn't. It seems to ignore the Contract.Requires() call. Should I set up something when trying to use Code Contracts?
I'm using Visual Studio 2010 RC.
Thanks