public void GetInvoiceFormAsPdf_AsyncWithDelegates_ThrowsWebException() { // Arrange var cf = new CompanyFile { Uri = new Uri("https://dc1.api.myob.com/accountright/7D5F5516-AF68-4C5B-844A-3F054E00DF10") }; var uri = cf.Uri.AbsoluteUri + "/" + Route + "/" + _uid + "?templatename=tn"; _webFactory.RegisterExceptionForUri <WebException>(uri); var iis = new TestInvoiceService(_configuration, _webFactory, null); // Act iis.GetInvoiceFormAsPdf(cf, _uid, null, "tn", (c, s) => Assert.Fail("Exception Expected"), ( u, e) => Assert.IsNotNull(e as WebException)); }
public void GetInvoiceFormAsPdf_Sync_ThrowsInvalidOperationException() { // Arrange var cf = new CompanyFile { Uri = new Uri("https://dc1.api.myob.com/accountright/7D5F5516-AF68-4C5B-844A-3F054E00DF10") }; var uri = cf.Uri.AbsoluteUri + "/" + Route + "/" + _uid + "?templatename=tn"; _webFactory.RegisterExceptionForUri <WebException>(uri); var iis = new TestInvoiceService(_configuration, _webFactory, null); // Act var ex = Assert.Throws <ApiCommunicationException>(() => iis.GetInvoiceFormAsPdf(cf, _uid, null, "tn")); // Assert Assert.AreEqual(uri.ToLower(), ex.URI.AbsoluteUri.ToLower()); Assert.IsInstanceOf <InvalidOperationException>(ex.InnerException); }