title: Unit Tests fail with exception code c0000005
body: <p>I am trying to create Unit Tests in Visual Studios 2012 using a Native Unit Test Project. </p>
  
  <p>This is the test I have:</p>
  
  <pre><code>TEST_METHOD(CalculationsRoundTests)
  {
      int result = Calculations::Round(1.0);
      Assert::AreEqual(1, result);
  }
  </code></pre>
  
  <p>Exporting the Class:</p>
  
  <pre><code>#ifdef EXPORT_TEST_FUNCTIONS
  #define MY_CALCULATIONS_EXPORT __declspec(dllexport)
  #else
  #define MY_CALCULATIONS_EXPORT
  #endif
  ...
  class CALCULATIONS_EXPORT Calculations {
  ...
  public:
  static int Round(const double&amp; x);
  </code></pre>
  
  <p>The function itself:</p>
  
  <pre><code>int Calculations::Round(const double&amp; x)
  {
      int temp;
      if (floor(x) + 0.5 &gt; x)
          temp = floor(x);
      else
          temp = ceil(x);
  
      return int(temp);
  }
  </code></pre>
  
  <p>However, the test nearly always fails with error code c0000005 (Access Violation).
  The test will fail the first time that x, or any other variable that may be declared in the function, is used.</p>
  
  <p>I followed the instructions at <a href="https://stackoverflow.com/questions/14010627/unresolved-externals-when-compiling-unit-tests-for-visual-c-2012">Unresolved externals when compiling unit tests for Visual C++ 2012</a></p>