public void TestConstructor1() { MessageValidationException ose = new MessageValidationException(); Assert.IsTrue(ose is ApplicationException, "MessageValidationException does not derive from ApplicationException"); }
public void TestConstructor2() { MessageValidationException ose = new MessageValidationException("abc"); Assert.IsTrue(ose is ApplicationException, "MessageValidationException does not derive from ApplicationException"); Assert.AreEqual(ose.Message, "abc", "Wrong constructor implementation"); }
public void TestConstructor3() { Exception e = new Exception("def"); MessageValidationException ose = new MessageValidationException("abc", e); Assert.IsTrue(ose is ApplicationException, "MessageValidationException does not derive from ApplicationException"); Assert.AreEqual(ose.Message, "abc", "Wrong constructor implementation"); Assert.AreEqual(ose.InnerException, e, "Wrong constructor implementation"); Assert.AreEqual(ose.InnerException.Message, "def", "Wrong constructor implementation"); }
public void ConstructorSerializationTest() { BinaryFormatter bf = new BinaryFormatter(); MemoryStream stream = new MemoryStream(); MessageValidationException ex1 = new MessageValidationException("Failed"); bf.Serialize(stream, ex1); stream.Flush(); stream.Seek(0, SeekOrigin.Begin); MessageValidationException ex2 = (MessageValidationException)bf.Deserialize(stream); Assert.AreEqual(ex1.Message, ex2.Message, "Error message should be correct."); }