コード例 #1
0
    public void TestInnerException() {
      Exception inner = new Exception("This is a test");
      PermissionDeniedException testException = new PermissionDeniedException(
        "Hello World", inner
      );

      Assert.AreSame(inner, testException.InnerException);
    }
コード例 #2
0
    public void TestSerialization() {
      BinaryFormatter formatter = new BinaryFormatter();

      using(MemoryStream memory = new MemoryStream()) {
        PermissionDeniedException exception1 = new PermissionDeniedException(
          "Hello World"
        );

        formatter.Serialize(memory, exception1);
        memory.Position = 0;
        object exception2 = formatter.Deserialize(memory);

        Assert.IsInstanceOf<PermissionDeniedException>(exception2);
        Assert.AreEqual(
          exception1.Message, ((PermissionDeniedException)exception2).Message
        );
      }
    }
コード例 #3
0
    public void TestDefaultConstructor() {
      PermissionDeniedException testException = new PermissionDeniedException();

      string testExceptionString = testException.ToString();
      Assert.IsNotNull(testExceptionString);
    }