public void AccountAlreadyExistsException_ReturnsDefaultErrorMessage() { // Act var error = new AccountAlreadyExistsException(); // Assert Assert.Equal("Account with this email already exists", error.Message); Assert.Equal(typeof(AccountAlreadyExistsException), error.GetType()); }
public void AccountAlreadyExistsException_ReturnsProvidedErrorMessage(string errorMessage) { // Act var error = new AccountAlreadyExistsException(errorMessage); // Arrange Assert.Equal(errorMessage, error.Message); Assert.Equal(typeof(AccountAlreadyExistsException), error.GetType()); }
} // TranslateCmException() /// <summary> /// Translates an outgoing Connection Manager exception into something /// BLL compatible using the return code only. /// </summary> /// <param name="intErrorCode"> /// The return code from a Connection Manager invocation. /// </param> /// <param name="strMessage"> /// Optional message parameter to allow clients to change output /// slightly. /// </param> /// <param name="excInner"> /// Optional exception parameter to allow the attachment of the /// provided exception as an inner exception to the returned value. /// </param> /// <returns> /// The outgoing exception with the appropriate exception key for the /// soap detail block. /// </returns> protected Exception TranslateCmException( int intErrorCode, string strMessage, Exception excInner) { // Default to whatever comes in just in case something falls // through inadvertently Exception excReturn = excInner; // Use the error code to determine the return type switch (Math.Abs(intErrorCode)) { case 1: // an error code of 1 means that its an unspecified error. However, // we can evaluate the text to see if we can handle the error with // a more specific exception then "UnexpectedSystemException". So, we // look at the string and act accordingly. Notice that when looking at // the message text we are walking the error stack looking for a match. Exception inner = excInner; bool handled = false; while (inner != null) { // check for an invalid campaign code. if (inner.Message.IndexOf(__campaignCodeInvalid) >= 0) { excReturn = new InvalidCampaignCodeException(excInner); handled = true; break; } else if (inner.Message.IndexOf(__campaignInvalid) >= 0) { excReturn = new InvalidCampaignCodeException(excInner); handled = true; break; } // no match, so check for an already authorized amount failure. else if (inner.Message.IndexOf(__authorizationRequestFailed) >= 0) { excReturn = new MopAlreadyAuthorizedException(strMessage, excInner); handled = true; break; } // no match, so check for an already authorized amount failure. else if (inner.Message.IndexOf(__prerequisitesNotMet) >= 0) { //excReturn = new PrerequisitesNotMetException(excInner); excReturn = new WorkOrderPrerequisitesException(excInner); handled = true; break; } else if (inner.Message.IndexOf(__serviceRequirementError) >= 0) { excReturn = new WorkOrderCheckInException(excInner); handled = true; break; } else if (inner.Message.IndexOf(__prerequisitesError) >= 0) { excReturn = new WorkOrderPrerequisitesException(excInner); handled = true; break; } // no match, lets grab the inner exception so we can walk the error stack. inner = inner.InnerException; } // we were unable to handle the exception based on the message text value // therefore, throw an unexpected system exception. if (!handled) { excReturn = new UnexpectedSystemException(strMessage, excInner); } break; case 503: excReturn = new AccountInUseException(strMessage, excInner); break; case 525: case 526: excReturn = new MopAuthorizationFailedException(strMessage, excInner); break; case 12: case 3101: case 3102: // these last 2 were added for Ppv excReturn = new InvalidAccountNumberException(strMessage, excInner); break; case 1025: if (null != excInner) { Exception excTemp = excInner.InnerException; if ((null != excTemp) && (excTemp.Message.IndexOf(__cannotIncrementOccupant) >= 0)) { excReturn = new AccountAlreadyExistsException(strMessage, excInner); break; } // ...(__cannotIncrementOccupant)... else { excReturn = new InvalidAccountNumberException(strMessage, excInner); break; } // else } // if( null != excInner ) else { excReturn = new InvalidAccountNumberException(strMessage, excInner); } // else( null != excInner ) break; case 1545: excReturn = new InvalidHouseNumberException(strMessage, excInner); break; case 1655: excReturn = new InvalidBankRoutingNumberException(strMessage, excInner); break; case 1640: excReturn = new InvalidMopAccountInformationException(strMessage, excInner); break; case 1714: // added for OrderFulfillment excReturn = new CannotAllocateTimeSlotException(strMessage, excInner); break; case 1715: // added for Ppv excReturn = new InvalidPinNumberException(strMessage, excInner); break; case 1770: // added for OrderFullfillment excReturn = new FieldLockedException(strMessage, excInner); break; case 1780: // added for OrderFullfillment excReturn = new InvalidSalesReasonException(strMessage, excInner); break; /* * added for Ppv. Legacy was tracking this exception for PayPerView. Normally * I do not see a need for this because it doesn't look like a Ppv Exception; * however it doesn't hurt because the specific exception we are throwing does * make sense for this error. */ case 1822: case 3113: excReturn = new InvalidSetTopBoxIdException(strMessage, excInner); break; case 1835: // rate master not found. however, the rate master could not be // found due to the service code not being mapped to a rate master. // this means that the service code is probably invalid. excReturn = new ProductConfigurationException(strMessage, excInner); break; case 1855: excReturn = new InvalidSiteIdException(strMessage, excInner); break; case 1870: excReturn = new InvalidStatementCodeException(strMessage, excInner); break; /* * added for Ppv...again legacy was tracking it so I am. not sure it is needed * for ppv but it doesn't hurt because the exception we are throwing is specific * and valid for the error response code from icoms. */ case 2065: // added for OrderFullfillment excReturn = new InvalidWorkOrderStatusException(strMessage, excInner); break; case 3100: excReturn = new CreditCheckFailedException(strMessage, excInner); break; case 3109: case 3126: // these 2 added for Ppv excReturn = new PpvEventRestrictedException(strMessage, excInner); break; case 3114: // added for Ppv excReturn = new PpvEventAlreadyOrderedException(strMessage, excInner); break; case 3121: // added for Ppv excReturn = new EquipmentException(strMessage, excInner); break; case 3125: // added for Ppv excReturn = new PinNumberRequiredException(strMessage, excInner); break; case 3122: // added for Ppv excReturn = new PpvExpiredException(strMessage, excInner); break; case 3133: // added for Ppv excReturn = new InvalidPpvEventException(strMessage, excInner); break; case 90000: case 90001: case 90002: case 90003: case 90004: case 90005: case 90006: case 90007: case 90008: case 90009: excReturn = new ServiceAgentUnavailableException(strMessage, excInner); break; default: excReturn = new UnexpectedSystemException(strMessage, excInner); break; } // switch( intErrorCode ) return(excReturn); } // TranslateCmException()