示例#1
0
        public void GetPdf_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.GetPdf(cf, _uid, null, "tn", (c, s) => Assert.Fail("Exception Expected"), (
                           u, e) => Assert.IsNotNull(e as WebException));
        }
示例#2
0
        public void GetPdf_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.GetPdf(cf, _uid, null, "tn"));

            // Assert
            Assert.AreEqual(uri.ToLower(), ex.URI.AbsoluteUri.ToLower());
            Assert.IsInstanceOf <InvalidOperationException>(ex.InnerException);
        }