title: Am I implementing this simple contract incorrectly?
body: <p>This is my code:</p>
  
  <pre><code>public class RegularPolygon
  {
      public int VertexCount;
      public double SideLength;
  
      public RegularPolygon(int vertexCount, double sideLength)
      {
          Contract.Requires(vertexCount &gt;= 3);
          VertexCount = vertexCount;
          SideLength = sideLength;
      }
  
      [ContractInvariantMethod]
      private void RegularPolygonInvariants()
      {
          Contract.Invariant(VertexCount&gt;=3);
      }
  
  }
  </code></pre>
  
  <p>I have tried with both the <strong>Contract.Requires</strong> and <strong>Contract.Invariant</strong> methods to prevent the vertexCount variable from becoming less than or equal to 2; however I am still able to initialise a RegularPolygon with 2 or fewer sides. My (simplified) NUnit test looks like this:</p>
  
  <pre><code>[TestFixture]
  class TestRegularPolygon
  {
      private RegularPolygon _polygon;
  
      [SetUp]
      public void Init()
      {
          _polygon = new RegularPolygon(1, 50);
      }
  
      [Test]
      public void Constructor()
      {
          Assert.That(_polygon.VertexCount,Is.GreaterThanOrEqualTo(3));
      }
  
  }
  </code></pre>
  
  <p>The above test also passes and I cannot figure out why!</p>
  
  <p>At first I thought ReSharper might have been messing something up because it greys out the line and displays this message whenever I try to use a method in the <code>Contract</code> namespace: </p>
  
  <blockquote>
    <p>Method invocation is skipped. Compiler will not generate method invocation because the method is conditional, or it is partial method without implementation.</p>
  </blockquote>
  
  <p>But suspending R# and running the tests in NUnit has the same result with no errors or warnings in VS either. So I assume that is just because ReSharper does not have highlighting compatibility for code contracts yet.</p>
  
  <p>I have looked at the documentation and as far as I can tell I shouldn't be having this problem.</p>
  
  <p><strong>Am I using code contracts incorrectly or is my environment preventing it from working somehow?</strong></p>
  
  <p>Thank you.</p>