title: How to test UIAlertController
body: <p>I'm testing a function that presents a UIAlertController, but the test keeps failing. This is what the function looks like:</p>
  
  <pre class="lang-swift prettyprint-override"><code>func presentBuyingErrorDialogue() {
    let alert = UIAlertController(
      title: "Warning",
      message: "Error purchasing item, please retry this action. If that doesn't help, try restarting or reinstalling the app.",
      preferredStyle: .alert
    )
    let okButton = UIAlertAction(title: "OK", style: .default)
    alert.addAction(okButton)
    self.present(alert, animated: true, completion: nil)
  }
  </code></pre>
  
  <p>Since this function is in a class called ShopViewController, I'm assuming that the correct way to test this would be to call the function <code>shopViewController.presentBuyingErrorDiaologue()</code> then use <code>XCTAssertTrue(shopViewController.presentedViewController is UIAlertController)</code>. However, the assert statement fails when I run the test. What would be the correct way to test that the UIAlertController is the presented view?</p>