public void CanProvideFaultWithNullVersion()
        {
            ExceptionShieldingErrorHandler shielding = new ExceptionShieldingErrorHandler();
            Message message = GetDefaultMessage();
            shielding.ProvideFault(new ArithmeticException(), null, ref message);

            MessageFault fault = GetFaultFromMessage(message);
            Assert.IsTrue(fault.Code.IsSenderFault);
        }
        public void CanProvideFaultWithNullException()
        {
            ExceptionShieldingErrorHandler shielding = new ExceptionShieldingErrorHandler();
            Message message = GetDefaultMessage();
            shielding.ProvideFault(null, MessageVersion.Default, ref message);

            MessageFault fault = GetFaultFromMessage(message);
            Assert.IsTrue(fault.Code.IsReceiverFault);
            CheckHandlingInstanceId("DefaultLogs.txt", fault.Reason.ToString());
        }
コード例 #3
0
        public void CanProvideFaultWithNullMessage()
        {
            ExceptionShieldingErrorHandler shielding = new ExceptionShieldingErrorHandler();
            Message message = null;

            shielding.ProvideFault(new ArithmeticException(), MessageVersion.Default, ref message);

            MessageFault fault = GetFaultFromMessage(message);

            Assert.IsTrue(fault.Code.IsSenderFault);
        }
コード例 #4
0
        public void CanProvideFaultWithNullException()
        {
            ExceptionShieldingErrorHandler shielding = new ExceptionShieldingErrorHandler();
            Message message = GetDefaultMessage();

            shielding.ProvideFault(null, MessageVersion.Default, ref message);

            MessageFault fault = GetFaultFromMessage(message);

            Assert.IsTrue(fault.Code.IsReceiverFault);
            CheckHandlingInstanceId("DefaultLogs.txt", fault.Reason.ToString());
        }
コード例 #5
0
        public void CanProvideFaultOnHandledLoggedExceptions()
        {
            ExceptionShieldingErrorHandler shielding = new ExceptionShieldingErrorHandler("HandledLoggedExceptions");
            Message message = GetDefaultMessage();

            shielding.ProvideFault(new ArithmeticException(), MessageVersion.Default, ref message);

            MessageFault fault = GetFaultFromMessage(message);

            Assert.IsTrue(fault.HasDetail);
            Assert.IsTrue(fault.Code.IsSenderFault);
            CheckLoggedMessage("HandledLogs.txt", fault.Reason.ToString());
        }
コード例 #6
0
        public void CanProvideFaultOnExceptionTypeNotFound()
        {
            ExceptionShieldingErrorHandler shielding = new ExceptionShieldingErrorHandler("ExceptionTypeNotFound");
            Message message = GetDefaultMessage();

            shielding.ProvideFault(new Exception(), MessageVersion.Default, ref message);

            MessageFault fault = GetFaultFromMessage(message);

            Assert.IsFalse(fault.HasDetail);
            Assert.IsTrue(fault.Code.IsReceiverFault);
            CheckHandlingInstanceId("DefaultLogs.txt", fault.Reason.ToString());
        }
コード例 #7
0
        public void ShouldReturnReceiverFault()
        {
            ExceptionShieldingErrorHandler shielding = new ExceptionShieldingErrorHandler("CustomPolicy");
            Message   message   = GetDefaultMessage();
            Exception exception = new NotSupportedException("NotSupportedException");

            shielding.ProvideFault(exception, MessageVersion.Default, ref message);

            MessageFault fault = GetFaultFromMessage(message);

            Assert.IsTrue(fault.Code.IsReceiverFault);
            Assert.IsFalse(string.IsNullOrEmpty(fault.Reason.ToString()));
            Assert.IsFalse(fault.HasDetail);
            CheckHandlingInstanceId("DefaultLogs.txt", fault.Reason.ToString());
        }
コード例 #8
0
        public void ShouldGetFaultExceptionWithoutPolicy()
        {
            ExceptionShieldingErrorHandler shielding = new ExceptionShieldingErrorHandler();
            FaultException faultException            = GetFaultException("test", SoapException.ServerFaultCode.Name);
            Message        message = Message.CreateMessage(MessageVersion.Default, faultException.CreateMessageFault(), "");

            shielding.ProvideFault(faultException, MessageVersion.Default, ref message);

            MessageFault actualFault   = GetFaultFromMessage(message);
            MessageFault expectedFault = faultException.CreateMessageFault();

            Assert.AreEqual(expectedFault.Reason.ToString(), actualFault.Reason.ToString());
            Assert.AreEqual(expectedFault.HasDetail, actualFault.HasDetail);
            Assert.AreEqual(expectedFault.Code.IsReceiverFault, actualFault.Code.IsReceiverFault);
        }
コード例 #9
0
        public void CanProvideFaultWithMockHandler()
        {
            ExceptionShieldingErrorHandler shielding = new ExceptionShieldingErrorHandler();
            ArithmeticException            exception = new ArithmeticException("My Exception");
            Message message = GetDefaultMessage();

            shielding.ProvideFault(exception, MessageVersion.Default, ref message);

            MessageFault fault = GetFaultFromMessage(message);

            Assert.IsTrue(fault.Code.IsSenderFault);
            //DataContractSerializer serializer = new DataContractSerializer(typeof(MockFaultContract));
            MockFaultContract details = fault.GetDetail <MockFaultContract>();

            Assert.IsNotNull(details);
            Assert.AreEqual(exception.Message, details.Message);
        }
コード例 #10
0
        public void CanProvideFaultOnCustomPolicyName()
        {
            ExceptionShieldingErrorHandler shielding = new ExceptionShieldingErrorHandler("CustomPolicy");
            Message message = GetDefaultMessage();

            shielding.ProvideFault(new ArgumentException("Arg"), MessageVersion.Default, ref message);

            MessageFault fault = GetFaultFromMessage(message);

            Assert.IsTrue(fault.HasDetail);
            Assert.IsTrue(fault.Code.IsSenderFault);
            //DataContractSerializer serializer = new DataContractSerializer(typeof(MockFaultContract));
            MockFaultContract details = fault.GetDetail <MockFaultContract>();

            Assert.IsNotNull(details);
            Assert.AreEqual("Arg", details.Message);
        }
コード例 #11
0
        public void CanPopulateFaultContractFromExceptionProperties()
        {
            ExceptionShieldingErrorHandler shielding = new ExceptionShieldingErrorHandler();
            Message   message   = GetDefaultMessage();
            Exception exception = new ArgumentNullException("MyMessage");

            shielding.ProvideFault(exception, MessageVersion.Default, ref message);

            MessageFault fault = GetFaultFromMessage(message);

            Assert.IsTrue(fault.HasDetail);
            Assert.IsTrue(fault.Code.IsSenderFault);
            MockFaultContract details = fault.GetDetail <MockFaultContract>();

            Assert.IsNotNull(details);
            Assert.AreEqual(exception.Message, details.Message);
            Assert.IsTrue(details.Id != Guid.Empty);
        }
コード例 #12
0
        public void ShouldReturnSenderFault()
        {
            ExceptionShieldingErrorHandler shielding = new ExceptionShieldingErrorHandler();
            Message   message   = GetDefaultMessage();
            Exception exception = new ArithmeticException("Message");

            shielding.ProvideFault(exception, MessageVersion.Default, ref message);

            MessageFault fault = GetFaultFromMessage(message);

            Assert.IsTrue(fault.Code.IsSenderFault);
            Assert.IsFalse(string.IsNullOrEmpty(fault.Reason.ToString()));
            Assert.IsTrue(fault.HasDetail);
            MockFaultContract details = fault.GetDetail <MockFaultContract>();

            Assert.IsNotNull(details);
            Assert.AreEqual(exception.Message, details.Message);
        }
        public void CanProvideFaultWithMockHandler()
        {
            ExceptionShieldingErrorHandler shielding = new ExceptionShieldingErrorHandler();
            ArithmeticException exception = new ArithmeticException("My Exception");
            Message message = GetDefaultMessage();
            shielding.ProvideFault(exception, MessageVersion.Default, ref message);

            MessageFault fault = GetFaultFromMessage(message);
            Assert.IsTrue(fault.Code.IsSenderFault);
            //DataContractSerializer serializer = new DataContractSerializer(typeof(MockFaultContract));
            MockFaultContract details = fault.GetDetail<MockFaultContract>();
            Assert.IsNotNull(details);
            Assert.AreEqual(exception.Message, details.Message);
        }
        public void CanProvideFaultOnHandledLoggedExceptions()
        {
            ExceptionShieldingErrorHandler shielding = new ExceptionShieldingErrorHandler("HandledLoggedExceptions");
            Message message = GetDefaultMessage();
            shielding.ProvideFault(new ArithmeticException(), MessageVersion.Default, ref message);

            MessageFault fault = GetFaultFromMessage(message);
            Assert.IsTrue(fault.HasDetail);
            Assert.IsTrue(fault.Code.IsSenderFault);
            CheckLoggedMessage("HandledLogs.txt", fault.Reason.ToString());
        }
        public void CanProvideFaultOnExceptionTypeNotFound()
        {
            ExceptionShieldingErrorHandler shielding = new ExceptionShieldingErrorHandler("ExceptionTypeNotFound");
            Message message = GetDefaultMessage();
            shielding.ProvideFault(new Exception(), MessageVersion.Default, ref message);

            MessageFault fault = GetFaultFromMessage(message);
            Assert.IsFalse(fault.HasDetail);
            Assert.IsTrue(fault.Code.IsReceiverFault);
            CheckHandlingInstanceId("DefaultLogs.txt", fault.Reason.ToString());
        }
        public void ShouldReturnReceiverFault()
        {
            ExceptionShieldingErrorHandler shielding = new ExceptionShieldingErrorHandler("CustomPolicy");
            Message message = GetDefaultMessage();
            Exception exception = new NotSupportedException("NotSupportedException");
            shielding.ProvideFault(exception, MessageVersion.Default, ref message);

            MessageFault fault = GetFaultFromMessage(message);
            Assert.IsTrue(fault.Code.IsReceiverFault);
            Assert.IsFalse(string.IsNullOrEmpty(fault.Reason.ToString()));
            Assert.IsFalse(fault.HasDetail);
            CheckHandlingInstanceId("DefaultLogs.txt", fault.Reason.ToString());
        }
        public void ShouldReturnSenderFault()
        {
            ExceptionShieldingErrorHandler shielding = new ExceptionShieldingErrorHandler();
            Message message = GetDefaultMessage();
            Exception exception = new ArithmeticException("Message");
            shielding.ProvideFault(exception, MessageVersion.Default, ref message);

            MessageFault fault = GetFaultFromMessage(message);
            Assert.IsTrue(fault.Code.IsSenderFault);
            Assert.IsFalse(string.IsNullOrEmpty(fault.Reason.ToString()));
            Assert.IsTrue(fault.HasDetail);
            MockFaultContract details = fault.GetDetail<MockFaultContract>();
            Assert.IsNotNull(details);
            Assert.AreEqual(exception.Message, details.Message);
        }
        public void CanPopulateFaultContractFromExceptionProperties()
        {
            ExceptionShieldingErrorHandler shielding = new ExceptionShieldingErrorHandler();
            Message message = GetDefaultMessage();
            Exception exception = new ArgumentNullException("MyMessage");
            shielding.ProvideFault(exception, MessageVersion.Default, ref message);

            MessageFault fault = GetFaultFromMessage(message);
            Assert.IsTrue(fault.HasDetail);
            Assert.IsTrue(fault.Code.IsSenderFault);
            MockFaultContract details = fault.GetDetail<MockFaultContract>();
            Assert.IsNotNull(details);
            Assert.AreEqual(exception.Message, details.Message);
            Assert.IsTrue(details.Id != Guid.Empty);
        }
        public void CanProvideFaultOnCustomPolicyName()
        {
            ExceptionShieldingErrorHandler shielding = new ExceptionShieldingErrorHandler("CustomPolicy");
            Message message = GetDefaultMessage();
            shielding.ProvideFault(new ArgumentException("Arg"), MessageVersion.Default, ref message);

            MessageFault fault = GetFaultFromMessage(message);
            Assert.IsTrue(fault.HasDetail);
            Assert.IsTrue(fault.Code.IsSenderFault);
            //DataContractSerializer serializer = new DataContractSerializer(typeof(MockFaultContract));
            MockFaultContract details = fault.GetDetail<MockFaultContract>();
            Assert.IsNotNull(details);
            Assert.AreEqual("Arg", details.Message);
        }
        public void ShouldGetFaultExceptionWithoutPolicy()
        {
            ExceptionShieldingErrorHandler shielding = new ExceptionShieldingErrorHandler();
            FaultException faultException = GetFaultException("test", SoapException.ServerFaultCode.Name);
            Message message = Message.CreateMessage(MessageVersion.Default, faultException.CreateMessageFault(), "");
            shielding.ProvideFault(faultException, MessageVersion.Default, ref message);

            MessageFault actualFault = GetFaultFromMessage(message);
            MessageFault expectedFault = faultException.CreateMessageFault();
            Assert.AreEqual(expectedFault.Reason.ToString(), actualFault.Reason.ToString());
            Assert.AreEqual(expectedFault.HasDetail, actualFault.HasDetail);
            Assert.AreEqual(expectedFault.Code.IsReceiverFault, actualFault.Code.IsReceiverFault);
        }