Beispiel #1
0
        public void TestInvalidXmlDoesNotThrow()
        {
            MockAdsUser           user      = new MockAdsUser(new MockAppConfig());
            MockTraceListener     listener  = (MockTraceListener)user.Listeners[0];
            SoapListenerInspector inspector = new SoapListenerInspector(user, TestServiceName);

            Message invalidXmlRequest = Message.CreateMessage(TestMessageVersion, "", "\u0003");

            Assert.DoesNotThrow(() => inspector.BeforeSendRequest(ref invalidXmlRequest, channel));
            Assert.DoesNotThrow(() => inspector.AfterReceiveReply(ref response, channel));
        }
        public void Init()
        {
            user           = new MockAdsUser(config);
            adsClient      = new MockAdsClient();
            adsClient.User = user;

            MockWebResponse response = new MockWebResponse(null, null);

            response.Headers["TestResponseKey"] = "TestResponseValue";
            adsClient.LastResponse = response;

            MockWebRequest request = new MockWebRequest(response, new Uri("http://localhost"), null,
                                                        false);

            request.Method = "POST";
            request.Headers["TestRequestKey"] = "TestRequestValue";
            adsClient.LastRequest             = request;
        }
Beispiel #3
0
        public void TestCorrectResponseInfo()
        {
            MockAdsUser           user      = new MockAdsUser(new MockAppConfig());
            MockTraceListener     listener  = (MockTraceListener)user.Listeners[0];
            SoapListenerInspector inspector = new SoapListenerInspector(user, TestServiceName);

            HttpResponseMessageProperty responseProperties = new HttpResponseMessageProperty();

            responseProperties.Headers.Add("X-TestHeader", "Hello World");
            responseProperties.StatusCode = System.Net.HttpStatusCode.OK;
            response.Properties.Add(HttpResponseMessageProperty.Name, responseProperties);

            inspector.BeforeSendRequest(ref request, channel);
            inspector.AfterReceiveReply(ref response, channel);

            Assert.AreEqual(responseProperties.Headers, listener.LastResponseInfo.Headers);
            Assert.AreEqual(responseProperties.StatusCode, listener.LastResponseInfo.StatusCode);
            Assert.AreEqual(ExpectedResponseXml, listener.LastResponseInfo.Body);
        }
Beispiel #4
0
        public void TestCorrectRequestInfo()
        {
            MockAdsUser       user     = new MockAdsUser(new MockAppConfig());
            MockTraceListener listener = new MockTraceListener(user.Config);

            user.Listeners.Add(listener);
            SoapListenerInspector inspector = new SoapListenerInspector(user, TestServiceName);

            HttpRequestMessageProperty requestProperties = new HttpRequestMessageProperty();

            requestProperties.Headers.Add("Authorization", "Bearer 1234");
            requestProperties.Method = "POST";
            request.Properties.Add(HttpRequestMessageProperty.Name, requestProperties);

            inspector.BeforeSendRequest(ref request, channel);
            inspector.AfterReceiveReply(ref response, channel);

            Assert.AreEqual(requestProperties.Headers, listener.LastRequestInfo.Headers);
            Assert.AreEqual(requestProperties.Method, listener.LastRequestInfo.HttpMethod);
            Assert.AreEqual(ExpectedRequestXml, listener.LastRequestInfo.Body);
            Assert.AreEqual(TestServiceName, listener.LastRequestInfo.Service);
        }