예제 #1
0
 public static MessageFormatException CreateMessageFormatException(Exception cause)
 {
     string msg = cause.Message;
     if (msg == null || msg.Length == 0)
     {
         msg = cause.ToString();
     }
     MessageFormatException exception = new MessageFormatException(msg, cause);
     return exception;
 }
예제 #2
0
        public void SerializationDeserialization()
        {
            MessageFormatException ex = new MessageFormatException("MessageFormatExceptionTest-SerializationDeserialization",
                new InvalidOperationException("Inner-SerializationDeserialization"));
            string serialized = JsonConvert.SerializeObject(ex);

            MessageFormatException ex2 = JsonConvert.DeserializeObject<MessageFormatException>(serialized);
            Assert.That(ex2.MessageId, Is.EqualTo("MessageFormatExceptionTest-SerializationDeserialization"));
            Assert.That(ex2.InnerException, Is.Not.Null);
            Assert.That(ex2.InnerException.Message, Is.EqualTo("Inner-SerializationDeserialization"));
        }
예제 #3
0
        public void SerializationDeserialization()
        {
            MessageFormatException ex = new MessageFormatException("MessageFormatExceptionTest-SerializationDeserialization",
                                                                   new InvalidOperationException("Inner-SerializationDeserialization"));
            string serialized = JsonConvert.SerializeObject(ex);

            MessageFormatException ex2 = JsonConvert.DeserializeObject <MessageFormatException>(serialized);

            Assert.That(ex2.MessageId, Is.EqualTo("MessageFormatExceptionTest-SerializationDeserialization"));
            Assert.That(ex2.InnerException, Is.Not.Null);
            Assert.That(ex2.InnerException.Message, Is.EqualTo("Inner-SerializationDeserialization"));
        }
예제 #4
0
        public static MessageFormatException CreateMessageFormatException(Exception cause)
        {
            string msg = cause.Message;

            if (msg == null || msg.Length == 0)
            {
                msg = cause.ToString();
            }
            MessageFormatException exception = new MessageFormatException(msg, cause);

            return(exception);
        }
예제 #5
0
        public void Ctors()
        {
            MessageFormatException ex = new MessageFormatException("MessageFormatExceptionTest-Ctors");
            Assert.That("MessageFormatExceptionTest-Ctors", Is.EqualTo(ex.MessageId));
            Assert.That("The message with ID 'MessageFormatExceptionTest-Ctors' does not hold a valid job descriptor.",
                Is.EqualTo(ex.Message));

            ex = new MessageFormatException("MessageFormatExceptionTest-Ctors", new NotSupportedException());
            Assert.That("MessageFormatExceptionTest-Ctors", Is.EqualTo(ex.MessageId));
            Assert.That("The message with ID 'MessageFormatExceptionTest-Ctors' does not hold a valid job descriptor.",
                Is.EqualTo(ex.Message));
            Assert.That(ex.InnerException, Is.TypeOf<NotSupportedException>());
        }
예제 #6
0
        public static MessageFormatException CreateMessageFormatException(this Exception cause)
        {
            var msg = cause.Message;

            if (msg.IsEmpty())
            {
                msg = cause.ToString();
            }

            var exception = new MessageFormatException(msg, cause);

            return(exception);
        }
예제 #7
0
        public void Ctors()
        {
            MessageFormatException ex = new MessageFormatException("MessageFormatExceptionTest-Ctors");

            Assert.That("MessageFormatExceptionTest-Ctors", Is.EqualTo(ex.MessageId));
            Assert.That("The message with ID 'MessageFormatExceptionTest-Ctors' does not hold a valid job descriptor.",
                        Is.EqualTo(ex.Message));

            ex = new MessageFormatException("MessageFormatExceptionTest-Ctors", new NotSupportedException());
            Assert.That("MessageFormatExceptionTest-Ctors", Is.EqualTo(ex.MessageId));
            Assert.That("The message with ID 'MessageFormatExceptionTest-Ctors' does not hold a valid job descriptor.",
                        Is.EqualTo(ex.Message));
            Assert.That(ex.InnerException, Is.TypeOf <NotSupportedException>());
        }