コード例 #1
0
        public void TestCtorInfoContext()
        {
            // Stream for serialization.
            using (Stream stream = new MemoryStream())
            {
                // Serialize the instance.
                AuthorizationServiceException serial =
                    new AuthorizationServiceException(message, cause);
                BinaryFormatter formatter = new BinaryFormatter();
                formatter.Serialize(stream, serial);

                // Deserialize the instance.
                stream.Seek(0, SeekOrigin.Begin);
                AuthorizationServiceException deserial =
                    formatter.Deserialize(stream)
                    as AuthorizationServiceException;

                // 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.");
            }
        }
コード例 #2
0
        public void TestCtorMessageInner_Null3()
        {
            AuthorizationServiceException ex =
                new AuthorizationServiceException(null, null);

            Assert.IsNotNull(ex, "A new instance should be created.");

            Assert.IsNull(ex.InnerException, "Invalid inner message.");
        }
コード例 #3
0
        public void TestCtorMessage_Valid()
        {
            Exception ex = new AuthorizationServiceException(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.");
        }
コード例 #4
0
        public void TestCtorMessageInner_Null2()
        {
            Exception ex = new AuthorizationServiceException(null, cause);

            Assert.IsNotNull(ex,
                             "A new instance should be created.");
            Assert.AreEqual(cause, ex.InnerException,
                            "ex.InnerException should be equal to cause.");
        }