title: Testing component with MdDialogRef injected is calling service
body: <p>I'm having a problem with testing a component having MdDialogRef and a service injected. I'd like to test that this component is calling the injected service. The problem is that I can't retrieve the service with the usual</p>
  
  <pre><code>fixture = TestBed.createComponent(...); 
  component = fixture.componentInstance; 
  service = fixture.debugElement.injector.get(Service);
  </code></pre>
  
  <p>because the component with an injected MDDialogRef has to be retrieved like this: </p>
  
  <pre><code>dialog = TestBed.get(MdDialog);
  dialogRef = dialog.open(CompanyLogoComponent);
  component = dialogRef.componentInstance;
  </code></pre>
  
  <p>This is a workaround for MdDialogRef, which says 'no provider available for MdDialogRef', and when providing needing many parameters. (Maybe there is a better way how to do this and then use fixture?)</p>
  
  <p>So, no fixture available to retrieve service with ...'debugElement.injector...' </p>
  
  <p>When injecting the service, I have another scope, because the spy doesn't react:</p>
  
  <pre><code>it('method should call service', inject ([Service], (service: Service) =&gt;  {
  expect(service).toBeTruthy();
  spyOn(service, 'method').and.callThrough();
  component.methodCallingService();
  expect(service.method).toHaveBeenCalled();
  }));
  </code></pre>
  
  <p>Any idea how I could bind the scope to the component here or retrieve the service through the component(dialogRef.componentInstance)?</p>