Exemplo n.º 1
0
        public void ThrownExceptionStackTrace()
        {
            var aml = @"<SOAP-ENV:Envelope xmlns:SOAP-ENV=""http://schemas.xmlsoap.org/soap/envelope/"">
  <SOAP-ENV:Body>
    <SOAP-ENV:Fault xmlns:af=""http://www.aras.com/InnovatorFault"">
      <faultcode>0</faultcode>
      <faultstring>No items of type SavedSearch found.</faultstring>
      <detail>
        <af:legacy_detail>No items of type SavedSearch found.</af:legacy_detail>
        <af:legacy_faultstring>No items of type 'SavedSearch' found using the criteria:
&lt;Item type=""SavedSearch"" action=""get""&gt;
  &lt;is_email_subscription&gt;1&lt;/is_email_subscription&gt;
  &lt;itname&gt;asdfasdfasdf&lt;/itname&gt;
&lt;/Item&gt;
</af:legacy_faultstring>
        <af:legacy_faultactor>   at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo)</af:legacy_faultactor>
      </detail>
    </SOAP-ENV:Fault>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>";

            ServerException serverEx = null;

            try
            {
                ElementFactory.Local.FromXml(aml).AssertNoError();
                Assert.Fail();
            }
            catch (ServerException ex)
            {
                serverEx = ex;
            }

            var str = serverEx.ToString();

            Assert.IsTrue(str.IndexOf("[Server") > 0);

            str = ElementFactory.Local.FromXml(aml).Exception.ToString();
            Assert.IsTrue(str.IndexOf("[Server") > 0);
        }
Exemplo n.º 2
0
        public void VerifySerialization()
        {
            var factory = ElementFactory.Local;

            var ex       = new ServerException("A bad exception");
            var expected = ex.ToString();

            ex = SerializeException <ServerException>(ex);
            Assert.AreEqual(expected, ex.ToString());

            ex       = factory.NoItemsFoundException("Part", "<query />");
            expected = ex.ToString();
            ex       = SerializeException <ServerException>(ex);
            Assert.AreEqual(expected, ex.ToString());

            ex       = factory.ValidationException("Missing Properties", factory.Item(factory.Type("Method")), "owned_by_id", "managed_by_id");
            expected = ex.ToString();
            ex       = SerializeException <ServerException>(ex);
            Assert.AreEqual(expected, ex.ToString());
        }