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()); }
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); }
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 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); }
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 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 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 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 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); }