title: Service Fabric Unit Testing and Dependency Injection
body: <p>I can't test a Reliable Service/Actor by just calling it's constructor and then test it's methods. <code>var testService = new SomeService();</code> throws a NullReferenceException. So what can I do with deployed Service..</p>
  
  <p>I understand that deployed SF Reliable Services/Actors are not standard .NET classes, and unit testing of deployed S/A maybe a strange idea.</p>
  
  <p>Anyway now I'm trying to give it a try.</p>
  
  <p>For example. I've just deployed a Service, than in the test I've created a Proxy object and added item into input queue of Service. Then I need to assert that input queue count = 1. And it works if I've just deployed a Service and no other Clients/Services/Actors have used it's input queue. But next time this test will be failed that's the problem. I need make the Service to stop operatating with other consumers, drop it's queue and than test it. For this purpose I can create some TestMode property and some methods like PropareoForTests/TestingCompleted and call them from test client before and after testing.</p>
  
  <p>Is this is a bad idea to do it like that. Maybe are there some guidelines for unit testing SF? Thanks.</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>While investigating <a href="https://github.com/Azure-Samples/service-fabric-dotnet-web-reference-app">Service Fabric Web Reference Application example</a> I've found this TODO string:</p>
  
  <pre><code>/// TODO: Temporary property-injection for an IServiceProxyWrapper until constructor injection is available.
  </code></pre>
  
  <p>Does it mean that SF Services will improve it's DI support? What about actors?</p>