示例#1
0
        public void TestAdWordsApiExceptionForFault()
        {
            SoapFaultInspector <AdWordsApiException> inspector =
                new SoapFaultInspector <AdWordsApiException>()
            {
                ErrorType = typeof(ApiException)
            };

            foreach (string faultXml in faultXmls)
            {
                XmlDocument xDoc    = XmlUtilities.CreateDocument(faultXml);
                Message     message = Message.CreateMessage(new XmlNodeReader(xDoc), Int32.MaxValue,
                                                            TestMessageVersion);

                AdWordsApiException exception = Assert.Throws <AdWordsApiException>(
                    delegate() { inspector.AfterReceiveReply(ref message, this.channel); },
                    "No exception was thrown for a SOAP Fault response");
                Assert.AreEqual(typeof(ApiException), exception.ApiException.GetType());
                ApiException apiException = (ApiException)exception.ApiException;
                Assert.AreEqual(1, apiException.errors.Length);
                Assert.AreEqual(typeof(AuthenticationError), apiException.errors[0].GetType());
                AuthenticationError error = (AuthenticationError)apiException.errors[0];
                Assert.AreEqual(AuthenticationErrorReason.CUSTOMER_NOT_FOUND, error.reason);
            }
        }
示例#2
0
        public void TestAdManagerApiExceptionForFault()
        {
            SoapFaultInspector <AdManagerApiException> inspector =
                new SoapFaultInspector <AdManagerApiException>()
            {
                ErrorType = typeof(AdManager.v202202.ApiException)
            };

            XmlDocument xDoc    = XmlUtilities.CreateDocument(fault_xml);
            Message     message = Message.CreateMessage(new XmlNodeReader(xDoc), Int32.MaxValue,
                                                        TestMessageVersion);

            AdManagerApiException exception = Assert.Throws <AdManagerApiException>(
                delegate() { inspector.AfterReceiveReply(ref message, this.channel); },
                "No exception was thrown for a SOAP Fault response");

            Assert.AreEqual(typeof(ApiException), exception.ApiException.GetType());
            ApiException apiException = (ApiException)exception.ApiException;

            Assert.AreEqual(1, apiException.errors.Length);
            Assert.AreEqual(typeof(PublisherQueryLanguageContextError),
                            apiException.errors[0].GetType());
            PublisherQueryLanguageContextError error =
                (PublisherQueryLanguageContextError)apiException.errors[0];

            Assert.AreEqual(PublisherQueryLanguageContextErrorReason.UNEXECUTABLE, error.reason);
            Assert.AreEqual("Mapping requested for unknown identifer", error.fieldPath);
        }
示例#3
0
        public void TestNoExceptionForNoFault()
        {
            SoapFaultInspector <AdWordsApiException> inspector =
                new SoapFaultInspector <AdWordsApiException>()
            {
                ErrorType = typeof(ApiException)
            };
            Message message = Message.CreateMessage(TestMessageVersion, null);

            Assert.DoesNotThrow(
                delegate() { inspector.AfterReceiveReply(ref message, this.channel); },
                "Exception was thrown for a response that wasn't a fault.");
        }