コード例 #1
0
    public void TestSimpleConstructor() {
      CddbException testException = new TestCddbException(123);

      Assert.AreEqual(123, testException.StatusCode);

      string testExceptionString = testException.ToString();
      Assert.IsNotNull(testExceptionString);
    }
コード例 #2
0
        public void TestInnerException()
        {
            Exception     inner         = new Exception("This is a test");
            CddbException testException = new TestCddbException(
                456, "Hello World", inner
                );

            Assert.AreSame(inner, testException.InnerException);
        }
コード例 #3
0
        public void TestSimpleConstructor()
        {
            CddbException testException = new TestCddbException(123);

            Assert.AreEqual(123, testException.StatusCode);

            string testExceptionString = testException.ToString();

            Assert.IsNotNull(testExceptionString);
        }
コード例 #4
0
        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
                    );
            }
        }
コード例 #5
0
    public void TestInnerException() {
      Exception inner = new Exception("This is a test");
      CddbException testException = new TestCddbException(
        456, "Hello World", inner
      );

      Assert.AreSame(inner, testException.InnerException);
    }
コード例 #6
0
    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
        );
      }
    }