title: error C2338: Test writer must define specialization of ToString<const Q& q> for your class
body: <p>I'm currently getting the following error for a Visual Studio 2013 C++/CLI Native Unit Test.</p>
  
  <pre><code>error C2338: Test writer must define specialization of ToString&lt;const Q&amp; q&gt; for your class class std::basic_string&lt;wchar_t,struct std::char_traits&lt;wchar_t&gt;,class std::allocator&lt;wchar_t&gt; &gt; __cdecl Microsoft::VisualStudio::CppUnitTestFramework::ToString&lt;class LTI::IPCommon::CPPBoxesBuffer&gt;(const class LTI::IPCommon::CPPBoxesBuffer &amp;).  c:\program files (x86)\microsoft visual studio 12.0\vc\unittest\include\cppunittestassert.h
  </code></pre>
  
  <p>I've tried the solution suggested in <a href="https://stackoverflow.com/questions/16312325/vs2012-error-with-unit-test-assertareequal-object-object-didnt-work">VS2012 : Error with unit test : Assert::AreEqual( object, object ) didn't work</a> and wrote a specialization but it didn't work.</p>
  
  <p>Here is the class in BoxesBuffer.h:</p>
  
  <pre><code>    class CPPBoxesBuffer{        
          private:
              unsigned char* _data;
              int _lines;
  
          public:
              CPPBoxesBuffer(unsigned char* data, int lines){ _data = data; _lines = lines; };
  
              // Methods for std::map. Class must be Assignable
              CPPBoxesBuffer(){ _data = nullptr; _lines = 0; };
  
              CPPBoxesBuffer(const CPPBoxesBuffer&amp; other)
              {
                  _lines = other._lines;
                  _data = other._data;
              }
  
              CPPBoxesBuffer&amp; operator=(const CPPBoxesBuffer&amp; other)
              {
                  _lines = other._lines;
                  _data = other._data;
                  return *this;
              }
  
              bool operator==(const CPPBoxesBuffer&amp; other) const
              {
                  return _lines == other._lines &amp;&amp; _data == other._data;
              }
  
  
      };
  </code></pre>
  
  <p>Here is the test:</p>
  
  <pre><code>    TEST_METHOD(ShouldSetAndGetCppBoxesBufferData)
      {
          std::string key = "WhenPassingData";
          unsigned char t[5] = { 'a', 'b', 'c', 'd', 'e' };
          CPPBoxesBuffer data(t, 5);
          auto result = data;
          auto db = data == result; // This compiles.
  
          Assert::AreEqual(data, result);  // This fails with the error.
      }
  </code></pre>
  
  <p>Here is the specialization I wrote:</p>
  
  <pre><code>#include "CppUnitTest.h"
  #include "BoxesBuffer.h"
  
  namespace Microsoft
  {
      namespace VisualStudio
      {
          namespace CppUnitTestFramework
          {
              template&lt;&gt; static std::wstring ToString&lt;CPPBoxesBuffer&gt;(const class CPPBoxesBuffer&amp; t) { return L"CppBoxesBuffer"; }
          }
      }
  }
  </code></pre>
  
  <p>What am I doing wrong?</p>