public void ServerTooBusyExceptionConstructorTest4()
        {
            string errorMessage           = "This is an error message.";
            ServerTooBusyException target = new ServerTooBusyException(errorMessage);

            Assert.AreEqual(target.Message, errorMessage);
        }
        public void ServerTooBusyExceptionConstructorTest3()
        {
            string message = "Ids Server is too busy.";
            ServerTooBusyException target = new ServerTooBusyException();

            Assert.AreEqual(target.Message, message);
        }
        public void ServerTooBusyExceptionConstructorTest5()
        {
            string errorMessage = "This is an error message.";

            System.Exception       innerException = new ArgumentNullException();
            ServerTooBusyException target         = new ServerTooBusyException(errorMessage, innerException);

            Assert.AreEqual(target.Message, errorMessage);
            Assert.ReferenceEquals(target.InnerException, innerException);
        }
        public void ServerTooBusyExceptionConstructorTest()
        {
            string errorMessage           = "Unauthorized";
            string errorCode              = "401";
            string source                 = "Intuit.Ipp.Test";
            ServerTooBusyException target = new ServerTooBusyException(errorMessage, errorCode, source);

            Assert.AreEqual(target.Message, errorMessage);
            Assert.AreEqual(target.ErrorCode, errorCode);
            Assert.AreEqual(target.Source, source);
        }
        public void OMM_Exception_SubConfiguration_Default_WithData()
        {
            string errorMessage       = DataGenerator.RandomString(50);
            string errorSource        = DataGenerator.RandomString(25);
            ServerTooBusyException ex = new ServerTooBusyException(errorMessage)
            {
                Source = errorSource
            };
            string value = ObjectMessageMap.GetMessage(ex);

            Assert.AreEqual(string.Format(TestResources.UNKNOWN_SERVER_ERROR, errorMessage, errorSource), value);
        }
示例#6
0
        /// <summary>
        /// Indicates whether the specified <see cref="Exception"/> is
        /// related to an endpoint not being available.
        /// </summary>
        /// <param name="exception"></param>
        /// <returns></returns>
        public static bool IsEndpointDown(System.Exception exception)
        {
            if (exception == null)
            {
                throw new ArgumentNullException("exception");
            }

            EndpointNotFoundException endpointNotFoundException = exception as EndpointNotFoundException;

            if (endpointNotFoundException != null)
            {
                return(true);
            }

            ServerTooBusyException serverTooBusyException = exception as ServerTooBusyException;

            if (serverTooBusyException != null)
            {
                WebException webException = serverTooBusyException.InnerException as WebException;
                return(IsEndpointDown(webException));
            }

            TimeoutException timeoutException = exception as TimeoutException;

            if (timeoutException != null)
            {
                return(true);
            }

            DataServiceTransportException dataServiceTransportException = exception as DataServiceTransportException;

            if (dataServiceTransportException != null)
            {
                WebException webException = dataServiceTransportException.InnerException as WebException;
                return(IsEndpointDown(webException));
            }

            DataServiceRequestException dataServiceRequestException = exception as DataServiceRequestException;

            if (dataServiceRequestException != null)
            {
                DataServiceClientException dataServiceClientException =
                    dataServiceRequestException.InnerException as DataServiceClientException;
                if (dataServiceClientException != null)
                {
                    WebException webException = dataServiceClientException.InnerException as WebException;
                    return(IsEndpointDown(webException));
                }
            }

            return(false);
        }
        public void ServerTooBusyExceptionConstructorTest1()
        {
            string errorMessage = "Unauthorized";
            string errorCode    = "401";
            string source       = "Intuit.Ipp.Test";

            System.Exception       innerException = new ArgumentNullException();
            ServerTooBusyException target         = new ServerTooBusyException(errorMessage, errorCode, source, innerException);

            Assert.AreEqual(target.Message, errorMessage);
            Assert.AreEqual(target.ErrorCode, errorCode);
            Assert.AreEqual(target.Source, source);
            Assert.ReferenceEquals(target.InnerException, innerException);
        }
示例#8
0
        public void CandidateService_GetApprenticeshipVacancyDetail_ServerTooBusyException()
        {
            var       candidateId      = Guid.NewGuid();
            const int vacancyId        = 1;
            var       candidateService = new Mock <ICandidateService>();
            var       message          = string.Format("Get vacancy failed for vacancy ID {0} and candidate ID {1}.", vacancyId, candidateId);
            var       exception        = new ServerTooBusyException("The HTTP service located at https://gateway.prod.avms.sfa.bis.gov.uk/services/NASGatewayService/GatewayService.svc is unavailable");
            var       customException  = new CustomException(message, exception, Application.Interfaces.Vacancies.ErrorCodes.GetVacancyDetailsFailed);

            candidateService.Setup(cs => cs.GetApprenticeshipVacancyDetail(candidateId, vacancyId)).Throws(customException);
            var provider = new ApprenticeshipVacancyProviderBuilder().With(candidateService).Build();

            var viewModel = provider.GetVacancyDetailViewModel(candidateId, vacancyId);

            viewModel.ViewModelMessage.Should().Be(ApprenticeshipVacancyDetailPageMessages.GetVacancyDetailFailed);
        }
        public void ServerTooBusyExceptionConstructorTest2()
        {
            string errorMessage = "Unauthorized";
            string errorCode    = "401";
            string source       = "Intuit.Ipp.Test";

            System.Exception       innerException = new ArgumentNullException();
            ServerTooBusyException target         = new ServerTooBusyException(errorMessage, errorCode, source, innerException);
            ServerTooBusyException newTarget      = null;

            using (Stream s = new MemoryStream())
            {
                BinaryFormatter formatter = new BinaryFormatter();
                formatter.Serialize(s, target);
                s.Position = 0; // Reset stream position
                newTarget  = (ServerTooBusyException)formatter.Deserialize(s);
            }

            Assert.IsNotNull(newTarget);
            Assert.AreEqual(newTarget.Message, errorMessage);
            Assert.AreEqual(newTarget.ErrorCode, errorCode);
            Assert.AreEqual(newTarget.Source, source);
            Assert.ReferenceEquals(newTarget.InnerException, innerException);
        }
示例#10
0
            protected override bool OnTryCreateException(Message message, MessageFault fault, out Exception exception)
            {
                exception = null;

                // SOAP MustUnderstand
                if (string.Compare(fault.Code.Namespace, version.Envelope.Namespace, StringComparison.Ordinal) == 0 &&
                    string.Compare(fault.Code.Name, MessageStrings.MustUnderstandFault, StringComparison.Ordinal) == 0)
                {
                    exception = new ProtocolException(fault.Reason.GetMatchingTranslation(CultureInfo.CurrentCulture).Text);
                    return(true);
                }

                bool      checkSender;
                bool      checkReceiver;
                FaultCode code;

                if (version.Envelope == EnvelopeVersion.Soap11)
                {
                    checkSender   = true;
                    checkReceiver = true;
                    code          = fault.Code;
                }
                else
                {
                    checkSender   = fault.Code.IsSenderFault;
                    checkReceiver = fault.Code.IsReceiverFault;
                    code          = fault.Code.SubCode;
                }

                if (code == null)
                {
                    return(false);
                }

                if (code.Namespace == null)
                {
                    return(false);
                }

                if (checkSender)
                {
                    // WS-Addressing
                    if (string.Compare(code.Namespace, version.Addressing.Namespace, StringComparison.Ordinal) == 0)
                    {
                        if (string.Compare(code.Name, AddressingStrings.ActionNotSupported, StringComparison.Ordinal) == 0)
                        {
                            exception = new ActionNotSupportedException(fault.Reason.GetMatchingTranslation(CultureInfo.CurrentCulture).Text);
                            return(true);
                        }
                        else if (string.Compare(code.Name, AddressingStrings.DestinationUnreachable, StringComparison.Ordinal) == 0)
                        {
                            exception = new EndpointNotFoundException(fault.Reason.GetMatchingTranslation(CultureInfo.CurrentCulture).Text);
                            return(true);
                        }
                        else if (string.Compare(code.Name, Addressing10Strings.InvalidAddressingHeader, StringComparison.Ordinal) == 0)
                        {
                            if (code.SubCode != null && string.Compare(code.SubCode.Namespace, version.Addressing.Namespace, StringComparison.Ordinal) == 0 &&
                                string.Compare(code.SubCode.Name, Addressing10Strings.InvalidCardinality, StringComparison.Ordinal) == 0)
                            {
                                exception = new MessageHeaderException(fault.Reason.GetMatchingTranslation(CultureInfo.CurrentCulture).Text, true);
                                return(true);
                            }
                        }
                        else if (version.Addressing == AddressingVersion.WSAddressing10)
                        {
                            if (string.Compare(code.Name, Addressing10Strings.MessageAddressingHeaderRequired, StringComparison.Ordinal) == 0)
                            {
                                exception = new MessageHeaderException(fault.Reason.GetMatchingTranslation(CultureInfo.CurrentCulture).Text);
                                return(true);
                            }
                            else if (string.Compare(code.Name, Addressing10Strings.InvalidAddressingHeader, StringComparison.Ordinal) == 0)
                            {
                                exception = new ProtocolException(fault.Reason.GetMatchingTranslation(CultureInfo.CurrentCulture).Text);
                                return(true);
                            }
                        }
                        else
                        {
                            if (string.Compare(code.Name, Addressing200408Strings.MessageInformationHeaderRequired, StringComparison.Ordinal) == 0)
                            {
                                exception = new ProtocolException(fault.Reason.GetMatchingTranslation(CultureInfo.CurrentCulture).Text);
                                return(true);
                            }
                            else if (string.Compare(code.Name, Addressing200408Strings.InvalidMessageInformationHeader, StringComparison.Ordinal) == 0)
                            {
                                exception = new ProtocolException(fault.Reason.GetMatchingTranslation(CultureInfo.CurrentCulture).Text);
                                return(true);
                            }
                        }
                    }
                }

                if (checkReceiver)
                {
                    // WS-Addressing
                    if (string.Compare(code.Namespace, version.Addressing.Namespace, StringComparison.Ordinal) == 0)
                    {
                        if (string.Compare(code.Name, AddressingStrings.EndpointUnavailable, StringComparison.Ordinal) == 0)
                        {
                            exception = new ServerTooBusyException(fault.Reason.GetMatchingTranslation(CultureInfo.CurrentCulture).Text);
                            return(true);
                        }
                    }
                }

                return(false);
            }
示例#11
0
            protected override bool OnTryCreateException(Message message, MessageFault fault, out Exception exception)
            {
                exception = null;

                // SOAP MustUnderstand
                if (string.Compare(fault.Code.Namespace, _version.Envelope.Namespace, StringComparison.Ordinal) == 0
                    && string.Compare(fault.Code.Name, MessageStrings.MustUnderstandFault, StringComparison.Ordinal) == 0)
                {
                    exception = new ProtocolException(fault.Reason.GetMatchingTranslation(CultureInfo.CurrentCulture).Text);
                    return true;
                }

                bool checkSender;
                bool checkReceiver;
                FaultCode code;

                if (_version.Envelope == EnvelopeVersion.Soap11)
                {
                    checkSender = true;
                    checkReceiver = true;
                    code = fault.Code;
                }
                else
                {
                    checkSender = fault.Code.IsSenderFault;
                    checkReceiver = fault.Code.IsReceiverFault;
                    code = fault.Code.SubCode;
                }

                if (code == null)
                {
                    return false;
                }

                if (code.Namespace == null)
                {
                    return false;
                }

                if (checkSender)
                {
                    // WS-Addressing
                    if (string.Compare(code.Namespace, _version.Addressing.Namespace, StringComparison.Ordinal) == 0)
                    {
                        if (string.Compare(code.Name, AddressingStrings.ActionNotSupported, StringComparison.Ordinal) == 0)
                        {
                            exception = new ActionNotSupportedException(fault.Reason.GetMatchingTranslation(CultureInfo.CurrentCulture).Text);
                            return true;
                        }
                        else if (string.Compare(code.Name, AddressingStrings.DestinationUnreachable, StringComparison.Ordinal) == 0)
                        {
                            exception = new EndpointNotFoundException(fault.Reason.GetMatchingTranslation(CultureInfo.CurrentCulture).Text);
                            return true;
                        }
                        else if (string.Compare(code.Name, Addressing10Strings.InvalidAddressingHeader, StringComparison.Ordinal) == 0)
                        {
                            if (code.SubCode != null && string.Compare(code.SubCode.Namespace, _version.Addressing.Namespace, StringComparison.Ordinal) == 0 &&
                                string.Compare(code.SubCode.Name, Addressing10Strings.InvalidCardinality, StringComparison.Ordinal) == 0)
                            {
                                exception = new MessageHeaderException(fault.Reason.GetMatchingTranslation(CultureInfo.CurrentCulture).Text, true);
                                return true;
                            }
                        }
                        else if (_version.Addressing == AddressingVersion.WSAddressing10)
                        {
                            if (string.Compare(code.Name, Addressing10Strings.MessageAddressingHeaderRequired, StringComparison.Ordinal) == 0)
                            {
                                exception = new MessageHeaderException(fault.Reason.GetMatchingTranslation(CultureInfo.CurrentCulture).Text);
                                return true;
                            }
                            else if (string.Compare(code.Name, Addressing10Strings.InvalidAddressingHeader, StringComparison.Ordinal) == 0)
                            {
                                exception = new ProtocolException(fault.Reason.GetMatchingTranslation(CultureInfo.CurrentCulture).Text);
                                return true;
                            }
                        }
                        else
                        {
                            if (string.Compare(code.Name, Addressing200408Strings.MessageInformationHeaderRequired, StringComparison.Ordinal) == 0)
                            {
                                exception = new ProtocolException(fault.Reason.GetMatchingTranslation(CultureInfo.CurrentCulture).Text);
                                return true;
                            }
                            else if (string.Compare(code.Name, Addressing200408Strings.InvalidMessageInformationHeader, StringComparison.Ordinal) == 0)
                            {
                                exception = new ProtocolException(fault.Reason.GetMatchingTranslation(CultureInfo.CurrentCulture).Text);
                                return true;
                            }
                        }
                    }
                }

                if (checkReceiver)
                {
                    // WS-Addressing
                    if (string.Compare(code.Namespace, _version.Addressing.Namespace, StringComparison.Ordinal) == 0)
                    {
                        if (string.Compare(code.Name, AddressingStrings.EndpointUnavailable, StringComparison.Ordinal) == 0)
                        {
                            exception = new ServerTooBusyException(fault.Reason.GetMatchingTranslation(CultureInfo.CurrentCulture).Text);
                            return true;
                        }
                    }
                }

                return false;
            }
示例#12
0
            protected override bool OnTryCreateException(Message message, MessageFault fault, out Exception exception)
            {
                bool      isSenderFault;
                bool      isReceiverFault;
                FaultCode subCode;

                exception = null;
                if ((string.Compare(fault.Code.Namespace, this.version.Envelope.Namespace, StringComparison.Ordinal) == 0) && (string.Compare(fault.Code.Name, "MustUnderstand", StringComparison.Ordinal) == 0))
                {
                    exception = new ProtocolException(fault.Reason.GetMatchingTranslation(CultureInfo.CurrentCulture).Text);
                    return(true);
                }
                if (this.version.Envelope == EnvelopeVersion.Soap11)
                {
                    isSenderFault   = true;
                    isReceiverFault = true;
                    subCode         = fault.Code;
                }
                else
                {
                    isSenderFault   = fault.Code.IsSenderFault;
                    isReceiverFault = fault.Code.IsReceiverFault;
                    subCode         = fault.Code.SubCode;
                }
                if (subCode != null)
                {
                    if (subCode.Namespace == null)
                    {
                        return(false);
                    }
                    if (isSenderFault && (string.Compare(subCode.Namespace, this.version.Addressing.Namespace, StringComparison.Ordinal) == 0))
                    {
                        if (string.Compare(subCode.Name, "ActionNotSupported", StringComparison.Ordinal) == 0)
                        {
                            exception = new ActionNotSupportedException(fault.Reason.GetMatchingTranslation(CultureInfo.CurrentCulture).Text);
                            return(true);
                        }
                        if (string.Compare(subCode.Name, "DestinationUnreachable", StringComparison.Ordinal) == 0)
                        {
                            exception = new EndpointNotFoundException(fault.Reason.GetMatchingTranslation(CultureInfo.CurrentCulture).Text);
                            return(true);
                        }
                        if (string.Compare(subCode.Name, "InvalidAddressingHeader", StringComparison.Ordinal) == 0)
                        {
                            if (((subCode.SubCode != null) && (string.Compare(subCode.SubCode.Namespace, this.version.Addressing.Namespace, StringComparison.Ordinal) == 0)) && (string.Compare(subCode.SubCode.Name, "InvalidCardinality", StringComparison.Ordinal) == 0))
                            {
                                exception = new MessageHeaderException(fault.Reason.GetMatchingTranslation(CultureInfo.CurrentCulture).Text, true);
                                return(true);
                            }
                        }
                        else if (this.version.Addressing == AddressingVersion.WSAddressing10)
                        {
                            if (string.Compare(subCode.Name, "MessageAddressingHeaderRequired", StringComparison.Ordinal) == 0)
                            {
                                exception = new MessageHeaderException(fault.Reason.GetMatchingTranslation(CultureInfo.CurrentCulture).Text);
                                return(true);
                            }
                            if (string.Compare(subCode.Name, "InvalidAddressingHeader", StringComparison.Ordinal) == 0)
                            {
                                exception = new ProtocolException(fault.Reason.GetMatchingTranslation(CultureInfo.CurrentCulture).Text);
                                return(true);
                            }
                        }
                        else
                        {
                            if (string.Compare(subCode.Name, "MessageInformationHeaderRequired", StringComparison.Ordinal) == 0)
                            {
                                exception = new ProtocolException(fault.Reason.GetMatchingTranslation(CultureInfo.CurrentCulture).Text);
                                return(true);
                            }
                            if (string.Compare(subCode.Name, "InvalidMessageInformationHeader", StringComparison.Ordinal) == 0)
                            {
                                exception = new ProtocolException(fault.Reason.GetMatchingTranslation(CultureInfo.CurrentCulture).Text);
                                return(true);
                            }
                        }
                    }
                    if ((isReceiverFault && (string.Compare(subCode.Namespace, this.version.Addressing.Namespace, StringComparison.Ordinal) == 0)) && (string.Compare(subCode.Name, "EndpointUnavailable", StringComparison.Ordinal) == 0))
                    {
                        exception = new ServerTooBusyException(fault.Reason.GetMatchingTranslation(CultureInfo.CurrentCulture).Text);
                        return(true);
                    }
                }
                return(false);
            }