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"));
      string expected = Resources.SoapLog.Replace("\r\n", "\n").Trim();
      string actual = ((string) ContextStore.GetValue("FormattedSoapLog")).
          Replace("\r\n", "\n").Trim();
      Assert.AreEqual(expected, actual);
      Assert.AreEqual(Resources.ResponseLog.Replace("\r\n", "\n"),
          ((string) ContextStore.GetValue("FormattedRequestLog")).Replace("\r\n", "\n"));
    }
 public void TestCleanupAfterCall() {
   listener = new MockTraceListener(config);
   ContextStore.AddKey("SoapRequest", "SoapRequest");
   ContextStore.AddKey("SoapResponse", "SoapResponse");
   ContextStore.AddKey("FormattedSoapLog", "FormattedSoapLog");
   ContextStore.AddKey("FormattedRequestLog", "FormattedRequestLog");
   listener.CleanupAfterCall();
   Assert.Null(ContextStore.GetValue("SoapRequest"));
   Assert.Null(ContextStore.GetValue("SoapResponse"));
   Assert.Null(ContextStore.GetValue("FormattedSoapLog"));
   Assert.Null(ContextStore.GetValue("FormattedRequestLog"));
 }
 public void TestGetTimeStamp() {
   listener = new MockTraceListener(config);
   Assert.DoesNotThrow(delegate() {
     listener.GetTimeStampForTest();
   });
 }
    public void TestHandleMessageNoClient() {
      config.SetPropertyFieldForTests("MaskCredentials", true);
      listener = new MockTraceListener(config);

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

      XmlDocument xIncoming = new XmlDocument();
      xIncoming.LoadXml(Resources.XmlResponse);
      listener.HandleMessage(xIncoming, null, SoapMessageDirection.IN);
      Assert.AreEqual(xIncoming.OuterXml, ContextStore.GetValue("SoapResponse"));
      Assert.IsNull(ContextStore.GetValue("FormattedSoapLog"));
      Assert.IsNull(ContextStore.GetValue("FormattedRequestLog"));
    }
 public void TestCleanupAfterCall()
 {
     config.SetPropertyFieldForTests("LogToFile", true);
       listener = new MockTraceListener(config);
       ContextStore.AddKey("SoapRequest", "SoapRequest");
       ContextStore.AddKey("SoapResponse", "SoapResponse");
       listener.CleanupAfterCall();
       Assert.Null(ContextStore.GetValue("SoapRequest"));
       Assert.Null(ContextStore.GetValue("SoapResponse"));
 }
 public void TestProperties()
 {
     listener = new MockTraceListener(config);
       listener.Writer = writer;
       Assert.AreEqual(writer, listener.Writer);
 }
        public void TestHandleMessage()
        {
            config.SetPropertyFieldForTests("LogToFile", true);
              config.SetPropertyFieldForTests("MaskCredentials", true);
              listener = new MockTraceListener(config);
              listener.Writer = writer;

              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"),
              writer.SoapLog.Replace("\r\n", "\n"));
              Assert.AreEqual(Resources.ResponseLog.Replace("\r\n", "\n"),
              writer.RequestLog.Replace("\r\n", "\n"));
        }
        public void TestConstructor()
        {
            config.SetPropertyFieldForTests("LogToFile", false);
              listener = new MockTraceListener(config);
              Assert.IsNull(listener.Writer);

              config.SetPropertyFieldForTests("LogToFile", true);
              listener = new MockTraceListener(config);
              Assert.IsInstanceOf<DefaultTraceWriter>(listener.Writer);
        }