title: Angular: How to mock MatDialogRef while testing
body: <p>I have a <code>DialogComponent</code> that has the following constructor where <code>Dialog</code> is a custom object:</p>
  <pre class="lang-js prettyprint-override"><code>constructor(
      public dialogRef: MatDialogRef&lt;CustomDialogComponent&gt;,
      @Inject(MAT_DIALOG_DATA) public data: Dialog
  )
  </code></pre>
  <p>I created the following <code>TestBed</code> in Angular4:</p>
  <pre class="lang-js prettyprint-override"><code>data = new Dialog()
  data.message = 'Dialog Message'
  
  TestBed.configureTestingModule({
      imports: [MaterialModules],
      declarations: [CustomDialogComponent],
      providers: [MatDialogRef, { provide: Dialog, useValue: data }]
  })
  
  TestBed.overrideModule(BrowserDynamicTestingModule, {
      set: {
          entryComponents: [CustomDialogComponent]
      }
  })
  await TestBed.compileComponents()
  </code></pre>
  <p>But I get the following error:</p>
  <pre><code>Failed: Can't resolve all parameters for MatDialogRef: (?, ?, ?).
  Error: Can't resolve all parameters for MatDialogRef: (?, ?, ?).
  </code></pre>
  <p>changing providers to:</p>
  <pre class="lang-js prettyprint-override"><code>providers: [
      { provide: MatDialogRef, useValue: {} },
      { provide: MAT_DIALOG_DATA,  useValue: data }
  ]
  </code></pre>
  <p>results in the following error:</p>
  <pre><code>Error: No provider for Dialog!
  </code></pre>
  <p>How do I resolve this?</p>