Exemplo n.º 1
0
        public void ExceptionNullToString_ShouldReturn_NullText()
        {
            // Arrange
            // Act
            var obj = new ExceptionDetail(null);

            // Assert
            obj.ToString().Should().Be("null");
        }
Exemplo n.º 2
0
        public void ToString_ShouldReturn_SerializedException()
        {
            // Arrange
            var exception = new InvalidOperationException();

            // Act
            var obj = new ExceptionDetail(exception);

            // Assert
            obj.ToString().Should().Be(exception.ToString());
        }
            private void ThrowIfFaultMessage(Message wcfMessage)
            {
                Exception exception;

                if (wcfMessage.IsFault)
                {
                    MessagingClientEtwProvider.TraceClient(() => {
                    });
                    string         action       = wcfMessage.Headers.Action;
                    MessageFault   messageFault = MessageFault.CreateFault(wcfMessage, 65536);
                    FaultConverter property     = this.innerChannel.GetProperty <FaultConverter>();
                    if (property == null || !property.TryCreateException(wcfMessage, messageFault, out exception))
                    {
                        if (!messageFault.HasDetail)
                        {
                            throw Microsoft.ServiceBus.Messaging.FxTrace.Exception.AsWarning(new FaultException(messageFault, action), null);
                        }
                        ExceptionDetail detail = messageFault.GetDetail <ExceptionDetail>();
                        if (!this.clientMode && string.Equals(detail.Type, typeof(CommunicationException).FullName, StringComparison.Ordinal))
                        {
                            MessagingClientEtwProvider.TraceClient(() => MessagingClientEtwProvider.Provider.EventWriteRuntimeChannelFaulting(this.innerChannel.GetType().Name, this.innerChannel.LocalAddress.Uri.AbsoluteUri, this.innerChannel.RemoteAddress.Uri.AbsoluteUri, this.innerChannel.Via.AbsoluteUri, this.innerChannel.Session.Id, string.Concat("ThrowIfFaultMessage: Received CommunicationException as fault message. ", detail.ToString())));
                            base.Fault();
                        }
                        if (!this.includeExceptionDetails)
                        {
                            throw Microsoft.ServiceBus.Messaging.FxTrace.Exception.AsInformation(new FaultException <ExceptionDetailNoStackTrace>(new ExceptionDetailNoStackTrace(detail, true), messageFault.Reason, messageFault.Code, action), null);
                        }
                        throw Microsoft.ServiceBus.Messaging.FxTrace.Exception.AsInformation(new FaultException <ExceptionDetail>(detail, messageFault.Reason, messageFault.Code, action), null);
                    }
                    throw Fx.Exception.AsWarning(exception, null);
                }
            }