title: How to unit test stateless service in service fabric
body: <p>I want to create an instance of class A which inherits class StatelessService in my unit test. But I can't. I've tried everything: mocking dependencies, implementing my own contexts and etc.</p>
  
  <p>When I try to create an instance, StatelessService throws NullReferenceException somewhere inside.</p>
  
  <p>Can it be done at all?</p>
  
  <pre><code>class A : StatelessService
  {
      public A(StatelessServiceContext context) : base(context /* Here will be thrown NullReferenceException */)
      {
          // It will never even get there.
      }
  }
  
  class UnitTest
  {
      public void TestMethod()
      {
          var activationContext = MOCK&lt;ICodePackageActivationContext&gt;();
          var context = new StatelessServiceContext(..., activationContext, ...);
          var a = new A(context); // Here will be thrown an exception.
      }
  }
  </code></pre>