title: Getting error while testing Angular 2 Material Dialog Component
body: <p>When I run the test I am getting "Can't resolve all parameters for MdDialogRef: (?, ?)" error. Please help.</p>
  
  <p>Please refer the below code for further reference.</p>
  
  <p><strong>MyComponent.spec.ts</strong></p>
  
  <pre><code>import { async, ComponentFixture, ComponentFixtureAutoDetect, TestBed } from '@angular/core/testing';
  import { MyComponent } from './my.component';
  import { MdDialogModule, MdDialog, MdDialogConfig, MdDialogRef } from '@angular/material';
  import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
  
  describe('Component: My Component', () =&gt; {
  
    let component: MyComponent;
    let fixture: ComponentFixture&lt;MyComponent&gt;;
  
    beforeEach(async(() =&gt; {
      TestBed.configureTestingModule({
        declarations: [MyComponent],
        imports: [BrowserAnimationsModule, MdDialogModule.forRoot()],
        providers: [MdDialogRef],
      })
        .compileComponents();
    }));
  
    beforeEach(() =&gt; {
      fixture = TestBed.createComponent(MyComponent);
      component = fixture.componentInstance;
      fixture.detectChanges();
    });
  
    it('should, have defined component', () =&gt; {
      expect(component).toBeDefined();
    });
  });
  </code></pre>
  
  <p><strong>MyComponent.ts</strong></p>
  
  <pre><code>import { Component } from '@angular/core';
  import { MdDialog, MdDialogRef } from '@angular/material';
  @Component({
      templateUrl: './mys.component.html'
  })
  
  export class MyComponent {
      constructor(public dialogRef: MdDialogRef&lt;any&gt;) { }
  }
  </code></pre>