public void TestCtorInfoContext() { // Stream for serialization. using (Stream stream = new MemoryStream()) { // Serialize the instance. InvalidSessionException serial = new InvalidSessionException(message, cause); BinaryFormatter formatter = new BinaryFormatter(); formatter.Serialize(stream, serial); // Deserialize the instance. stream.Seek(0, SeekOrigin.Begin); InvalidSessionException deserial = formatter.Deserialize(stream) as InvalidSessionException; // Verify the instance. Assert.IsFalse(serial == deserial, "Instance not deserialized."); Assert.AreEqual(serial.Message, deserial.Message, "Message mismatches."); Assert.AreEqual(serial.InnerException.Message, deserial.InnerException.Message, "InnerException mismatches."); } }
public void TestCtorMessageInner_Null3() { InvalidSessionException ex = new InvalidSessionException(null, null); Assert.IsNotNull(ex, "A new instance should be created."); Assert.IsNull(ex.InnerException, "Invalid inner message."); }
public void TestCtorMessage_Valid() { Exception ex = new InvalidSessionException(message); Assert.IsNotNull(ex, "A new instance should be created."); Assert.AreEqual(message, ex.Message, "ex.Message should be equal to message."); Assert.IsNull(ex.InnerException, "Invalid inner message."); }
public void TestCtorMessageInner_Null2() { Exception ex = new InvalidSessionException(null, cause); Assert.IsNotNull(ex, "A new instance should be created."); Assert.AreEqual(cause, ex.InnerException, "ex.InnerException should be equal to cause."); }