Example #1
0
        public void DemoException_Constructor_MessageArgument_Null()
        {
            // This test verifies that the default constructor works.
            // Note: this test is useless except for code coverage since we are testing the constructor with no custom logic.
            var ex = new DemoException(null);

            Assert.AreEqual("Exception of type 'Rightpoint.UnitTesting.Demo.Common.Exceptions.DemoException' was thrown.", ex.Message);
            Assert.IsNull(ex.InnerException);
        }
Example #2
0
        public void DemoException_Constructor_MessageArgument_Valid()
        {
            // This test verifies that the default constructor works.
            // Note: this test is useless except for code coverage since we are testing the constructor with no custom logic.
            var ex = new DemoException("test");

            Assert.AreEqual("test", ex.Message);
            Assert.IsNull(ex.InnerException);
        }
Example #3
0
        public void DemoException_Constructor_MessageAndInnerExArgument_EmptyMessage()
        {
            // This test verifies that the default constructor works.
            // Note: this test is useless except for code coverage since we are testing the constructor with no custom logic.
            var ex = new DemoException(string.Empty, new Exception("Inner"));

            Assert.AreEqual(string.Empty, ex.Message);
            Assert.IsNotNull(ex.InnerException);
            Assert.AreEqual("Inner", ex.InnerException.Message);
            Assert.IsNull(ex.InnerException.InnerException);
        }
Example #4
0
 private void btnStronglyTypedFault_Click(object sender, EventArgs e)
 {
     try
     {
         proxy.ThrowStronglyTypedFault();
     }
     catch (FaultException <DemoException> ex)
     {
         DemoException de = ex.Detail;
         MessageBox.Show(de.GetType() + "\n" + de.Message + " " + de.Value);
     }
     catch (FaultException ex)
     {
         MessageBox.Show(ex.GetType() + "\nMessage: " + ex.Message + "\nCode Name: " + ex.Code.Name);
     }
 }
Example #5
0
        public void DemoException_Constructor_Serialization()
        {
            // This test verifies that the default constructor works.
            // Note: this test is useless except for code coverage since we are testing default serialization.
            DemoException inputException = new DemoException("test", new Exception("Inner"));

            byte[] bytes = BinarySerializer.Serialize(inputException);
            Assert.IsNotNull(bytes);

            DemoException deserializedException = BinarySerializer.Deserialize <DemoException>(bytes);

            Assert.IsNotNull(deserializedException);
            Assert.AreEqual(inputException.Message, deserializedException.Message);
            Assert.IsNotNull(deserializedException.InnerException);
            Assert.AreEqual(typeof(Exception), deserializedException.InnerException.GetType());
            Assert.AreEqual(inputException.InnerException.Message, deserializedException.InnerException.Message);
            Assert.IsNull(deserializedException.InnerException.InnerException);
        }