Ejemplo n.º 1
0
        public void GetExceptionMessage_WithSmartObjectException()
        {
            //Arrange
            var ctor = typeof(SmartObjectExceptionData).GetConstructors(BindingFlags.Instance | BindingFlags.NonPublic).FirstOrDefault();

            string             serviceName           = Guid.NewGuid().ToString();
            string             serviceGuid           = Guid.NewGuid().ToString();
            string             message               = Guid.NewGuid().ToString();
            string             innerExceptionMessage = Guid.NewGuid().ToString();
            const SeverityType severity              = SeverityType.Error;

            var smartObjectExceptionData = (SmartObjectExceptionData)ctor.Invoke(new object[] { serviceName, serviceGuid, message, innerExceptionMessage, severity });

            var collection = new SmartObjectExceptionDataCollection
            {
                smartObjectExceptionData
            };
            var    exception = new SmartObjectException(collection);
            string expected  = $@"Service: {serviceName}
Service Guid: {serviceGuid}
Severity: {severity.ToString()}
Error Message: {message}
InnerException Message: {innerExceptionMessage}";

            // Action
            var actual = ExceptionExtensions.GetExceptionMessage(exception);

            // Assert
            Assert.AreEqual(Regex.Replace(expected.Trim(), @"\s+", " "), Regex.Replace(actual.Trim(), @"\s+", " "));
        }
Ejemplo n.º 2
0
 private void ParseSmOException(SmartObjectException ex)
 {
     StringBuilder sb = new StringBuilder();
     foreach (SmartObjectExceptionData m in ex.BrokerData)
     {
         sb.AppendFormat("{0} - {1} - service:{2}",m.Message, m.InnerExceptionMessage, m.ServiceName);
     }
     throw new Exception(sb.ToString(), ex);        
 }