public void TestHandleMessage()
        {
            config.SetPropertyFieldForTests("MaskCredentials", true);
            listener = new MockTraceListener(config);

            XmlDocument xOutgoing = new XmlDocument();

            xOutgoing.LoadXml(Resources.XmlRequest);
            listener.HandleMessage(xOutgoing, adsClient, SoapMessageDirection.OUT);
            Assert.AreEqual(xOutgoing.OuterXml, ContextStore.GetValue("SoapRequest"));

            XmlDocument xIncoming = new XmlDocument();

            xIncoming.LoadXml(Resources.XmlResponse);
            listener.HandleMessage(xIncoming, adsClient, SoapMessageDirection.IN);
            Assert.AreEqual(xIncoming.OuterXml, ContextStore.GetValue("SoapResponse"));
            Assert.AreEqual(Resources.SoapLog.Replace("\r\n", "\n"),
                            ((string)ContextStore.GetValue("FormattedSoapLog")).Replace("\r\n", "\n"));
            Assert.AreEqual(Resources.ResponseLog.Replace("\r\n", "\n"),
                            ((string)ContextStore.GetValue("FormattedRequestLog")).Replace("\r\n", "\n"));
        }
Пример #2
0
        public void TestHandleMessage()
        {
            config.SetPropertyFieldForTests("MaskCredentials", true);
            listener = new MockTraceListener(config);

            WebHeaderCollection requestHeaders = new WebHeaderCollection();

            requestHeaders["TestRequestKey"] = "TestRequestValue";
            RequestInfo request = new RequestInfo()
            {
                Body       = Resources.XmlRequest,
                Headers    = requestHeaders,
                Uri        = new Uri("https://localhost"),
                HttpMethod = "POST",
                Service    = TestServiceName
            };

            WebHeaderCollection responseHeaders = new WebHeaderCollection();

            responseHeaders["TestResponseKey"] = "TestResponseValue";
            ResponseInfo response = new ResponseInfo()
            {
                Body       = Resources.XmlResponse,
                Headers    = responseHeaders,
                StatusCode = HttpStatusCode.OK
            };

            listener.HandleMessage(request, response);
            string expected = Resources.SoapLog.Replace("\r\n", "\n").Trim();
            string actual   = (ContextStore.GetValue("FormattedSoapLog").ToString())
                              .Replace("\r\n", "\n").Trim();

            Assert.AreEqual(expected, actual);

            expected = Resources.ResponseLog.Replace("\r\n", "\n").Trim();
            actual   = (ContextStore.GetValue("FormattedRequestLog").ToString())
                       .Replace("\r\n", "\n").Trim();
            Assert.AreEqual(expected, actual);
        }