title: .NET Core 2 - Create instance of controller class which has a repository
body: <p>I have the following controller Class; </p>
  
  <pre><code>public class MyController: Controller
  {
      private IValueService _service;
  
      public MyController(IValueService service)
      {
          this._service = service;
      }
  
      public void MyMethod()
      {
          var values = _service.GetAll();
      }
  }
  </code></pre>
  
  <p>I would like to create an instance of this Class and call the method MyMethod(), e.g.</p>
  
  <pre><code>var MyCopy = new MyController();
  MyCopy.MyMethod();
  </code></pre>
  
  <p>However i get the message i need to give the required service parameter. How would i create an instance of a controller that has a service (repository) so i can call its methods? </p>