public void TestSimpleConstructor() { CddbException testException = new TestCddbException(123); Assert.AreEqual(123, testException.StatusCode); string testExceptionString = testException.ToString(); Assert.IsNotNull(testExceptionString); }
public void TestInnerException() { Exception inner = new Exception("This is a test"); CddbException testException = new TestCddbException( 456, "Hello World", inner ); Assert.AreSame(inner, testException.InnerException); }
public void TestSerialization() { BinaryFormatter formatter = new BinaryFormatter(); using (MemoryStream memory = new MemoryStream()) { TestCddbException exception1 = new TestCddbException( 789, "Hello World" ); formatter.Serialize(memory, exception1); memory.Position = 0; object exception2 = formatter.Deserialize(memory); Assert.IsInstanceOf <TestCddbException>(exception2); Assert.AreEqual( exception1.StatusCode, ((TestCddbException)exception2).StatusCode ); Assert.AreEqual( exception1.Message, ((TestCddbException)exception2).Message ); } }
public void TestSerialization() { BinaryFormatter formatter = new BinaryFormatter(); using(MemoryStream memory = new MemoryStream()) { TestCddbException exception1 = new TestCddbException( 789, "Hello World" ); formatter.Serialize(memory, exception1); memory.Position = 0; object exception2 = formatter.Deserialize(memory); Assert.IsInstanceOf<TestCddbException>(exception2); Assert.AreEqual( exception1.StatusCode, ((TestCddbException)exception2).StatusCode ); Assert.AreEqual( exception1.Message, ((TestCddbException)exception2).Message ); } }