public void TestSerialization() { MessageFormattingException serialized; exception = new MessageFormattingException(MESSAGE, CAUSE); using (Stream stream = new MemoryStream()) { BinaryFormatter formatter = new BinaryFormatter(); // serialize the exception formatter.Serialize(stream, exception); stream.Position = 0; // deserialize serialized = (MessageFormattingException) formatter.Deserialize(stream); } Assert.AreEqual(MESSAGE, serialized.Message, "The message was not set properly."); // Just check the message because it is impossible to compare two different Exception // instances for equality. Assert.AreEqual(CAUSE.Message, serialized.InnerException.Message, "The inner cause was not set properly."); }
public void Test1ParamCtor() { exception = new MessageFormattingException(MESSAGE); Assert.AreEqual(MESSAGE, exception.Message, "The message was not set properly."); }
public void Test2ParamCtor() { exception = new MessageFormattingException(MESSAGE, CAUSE); Assert.AreEqual(MESSAGE, exception.Message, "The message was not set properly."); Assert.AreSame(CAUSE, exception.InnerException, "The inner cause was not set properly."); }
public void Test0ParamCtor() { exception = new MessageFormattingException(); Assert.IsNotNull(exception, "Fail to create instance."); }