public void ShouldBeInvalidAfterAddingDetail()
 {
     ValidationFault fault = new ValidationFault();
     fault.Add(new ValidationDetail("message", "key", "tag"));
     Assert.IsFalse(fault.IsValid);
     Assert.AreEqual(1, fault.Details.Count);
 }
        public void ShouldBeInvalidAfterAddingDetail()
        {
            ValidationFault fault = new ValidationFault();

            fault.Add(new ValidationDetail("message", "key", "tag"));
            Assert.IsFalse(fault.IsValid);
            Assert.AreEqual(1, fault.Details.Count);
        }
        T exceptionHandling <T>(Token token, Func <T> method)
        {
            testSleep();
            ExceptionHandler.Default.EmailFeaturesEnabled = false;
            try
            {
                localizeThread(token);
                return(method());
            }
            catch (ProfileRankException ex)
            {
                BAServiceException baEx = new BAServiceException(ErrorCode.ProfileRankException, ex.Message);
                baEx.ErrorId = ExceptionHandler.Default.Process(ex);
                throw new FaultException <BAServiceException>(baEx, baEx.Message);
            }
            catch (MaintenanceException ex)
            {
                BAServiceException baEx = new BAServiceException(ErrorCode.MaintenanceException, ex.Message);
                baEx.ErrorId = ExceptionHandler.Default.Process(ex);
                throw new FaultException <BAServiceException>(baEx, baEx.Message);
            }
            catch (FileNotFoundException ex)
            {
                BAServiceException baEx = new BAServiceException(ErrorCode.FileNotFoundException, ex.Message);
                baEx.ErrorId = ExceptionHandler.Default.Process(ex);
                throw new FaultException <BAServiceException>(baEx, baEx.Message);
            }

            catch (ConsistencyException ex)
            {
                BAServiceException baEx = new BAServiceException(ErrorCode.ConsistencyException, ex.Message);
                baEx.ErrorId = ExceptionHandler.Default.Process(ex);
                throw new FaultException <BAServiceException>(baEx, baEx.Message);
            }
            catch (ProfileDeletedException ex)
            {
                BAServiceException baEx = new BAServiceException(ErrorCode.ProfileDeletedException, ex.Message);
                baEx.ErrorId = ExceptionHandler.Default.Process(ex);
                throw new FaultException <BAServiceException>(baEx, baEx.Message);
            }
            catch (UserDeletedException ex)
            {
                BAServiceException baEx = new BAServiceException(ErrorCode.UserDeletedException, ex.Message);
                baEx.ErrorId = ExceptionHandler.Default.Process(ex);
                throw new FaultException <BAServiceException>(baEx, baEx.Message);
            }

            catch (ProfileIsNotActivatedException ex)
            {
                BAServiceException baEx = new BAServiceException(ErrorCode.ProfileIsNotActivatedException, ex.Message);
                baEx.ErrorId = ExceptionHandler.Default.Process(ex);
                throw new FaultException <BAServiceException>(baEx, baEx.Message);
            }
            catch (SecurityException ex)
            {
                BAServiceException baEx = new BAServiceException(ErrorCode.SecurityException, ex.Message);
                baEx.ErrorId = ExceptionHandler.Default.Process(ex);
                throw new FaultException <BAServiceException>(baEx, baEx.Message);
            }
            catch (TrainingIntegrationException ex)
            {
                BAServiceException baEx = new BAServiceException(ErrorCode.TrainingIntegrityException, ex.Message);
                baEx.ErrorId = ExceptionHandler.Default.Process(ex);
                throw new FaultException <BAServiceException>(baEx, baEx.Message);
            }
            catch (DeleteConstraintException ex)
            {
                BAServiceException baEx = new BAServiceException(ErrorCode.DeleteConstraintException, ex.Message);
                baEx.ErrorId = ExceptionHandler.Default.Process(ex);
                throw new FaultException <BAServiceException>(baEx, baEx.Message);
            }
            catch (ObjectIsFavoriteException ex)
            {
                BAServiceException baEx = new BAServiceException(ErrorCode.ObjectIsFavoriteException, ex.Message);
                baEx.ErrorId = ExceptionHandler.Default.Process(ex);
                throw new FaultException <BAServiceException>(baEx, baEx.Message);
            }
            catch (AlreadyOccupiedException ex)
            {
                BAServiceException baEx = new BAServiceException(ErrorCode.AlreadyOccupied, ex.Message);
                baEx.ErrorId = ExceptionHandler.Default.Process(ex);
                throw new FaultException <BAServiceException>(baEx, baEx.Message);
            }
            catch (LicenceException ex)
            {
                BAServiceException baEx = new BAServiceException(ErrorCode.LicenceException, ex.Message);
                baEx.ErrorId = ExceptionHandler.Default.Process(ex);
                throw new FaultException <BAServiceException>(baEx, baEx.Message);
            }
            catch (ProductAlreadyPaidException ex)
            {
                BAServiceException baEx = new BAServiceException(ErrorCode.ProductAlreadyPaid, ex.Message);
                baEx.ErrorId = ExceptionHandler.Default.Process(ex);
                throw new FaultException <BAServiceException>(baEx, baEx.Message);
            }
            catch (ObjectIsNotFavoriteException ex)
            {
                BAServiceException baEx = new BAServiceException(ErrorCode.ObjectIsNotFavoriteException, ex.Message);
                baEx.ErrorId = ExceptionHandler.Default.Process(ex);
                throw new FaultException <BAServiceException>(baEx, baEx.Message);
            }
            catch (ProfileAlreadyFriendException ex)
            {
                BAServiceException baEx = new BAServiceException(ErrorCode.ProfileAlreadyFriendException, ex.Message);
                baEx.ErrorId = ExceptionHandler.Default.Process(ex);
                throw new FaultException <BAServiceException>(baEx, baEx.Message);
            }
            catch (CannotAcceptRejectInvitationDoesntExistException ex)
            {
                BAServiceException baEx = new BAServiceException(ErrorCode.CannotAcceptRejectInvitationDoesntExistException, ex.Message);
                baEx.ErrorId = ExceptionHandler.Default.Process(ex);
                throw new FaultException <BAServiceException>(baEx, baEx.Message);
            }
            catch (DatabaseException adoEx)
            {
                BAServiceException baEx = new BAServiceException(ErrorCode.DatabaseException, adoEx.Message);
                baEx.ErrorId = ExceptionHandler.Default.Process(adoEx);
                throw new FaultException <BAServiceException>(baEx, baEx.Message);
            }
            catch (GenericADOException adoEx)
            {
                BAServiceException baEx = new BAServiceException(ErrorCode.DatabaseException, adoEx.Message);
                baEx.ErrorId = ExceptionHandler.Default.Process(adoEx);
                throw new FaultException <BAServiceException>(baEx, baEx.Message);
            }
            catch (DatabaseVersionException adoEx)
            {
                BAServiceException baEx = new BAServiceException(ErrorCode.DatabaseVersionException, adoEx.Message);
                baEx.ErrorId = ExceptionHandler.Default.Process(adoEx);
                throw new FaultException <BAServiceException>(baEx, baEx.Message);
            }
            catch (ObjectNotFoundException ex)
            {
                BAServiceException baEx = new BAServiceException(ErrorCode.ObjectNotFound, ex.Message);
                baEx.ErrorId = ExceptionHandler.Default.Process(ex);
                throw new FaultException <BAServiceException>(baEx, baEx.Message);
            }
            catch (FaultException <BAServiceException> )
            {
                throw;
            }
            catch (Portable.Exceptions.AuthenticationException ex)
            {
                BAAuthenticationException baEx = new BAAuthenticationException(ex.Message);
                baEx.ErrorId = ExceptionHandler.Default.Process(ex);
                throw new FaultException <BAAuthenticationException>(baEx, baEx.Message);
            }
            catch (InvalidOperationException ex)
            {
                BAServiceException baEx = new BAServiceException(ErrorCode.InvalidOperationException, ex.Message);
                baEx.ErrorId = ExceptionHandler.Default.Process(ex);
                throw new FaultException <BAServiceException>(baEx, baEx.Message);
            }
            catch (ArgumentNullException ex)
            {
                BAServiceException baEx = new BAServiceException(ErrorCode.ArgumentNullException, ex.Message);
                baEx.ErrorId        = ExceptionHandler.Default.Process(ex);
                baEx.AdditionalData = ex.ParamName;
                throw new FaultException <BAServiceException>(baEx, baEx.Message);
            }
            catch (EMailSendException ex)
            {
                BAServiceException baEx = new BAServiceException(ErrorCode.EMailSendException, ex.Message);
                baEx.ErrorId = ExceptionHandler.Default.Process(ex);
                throw new FaultException <BAServiceException>(baEx, baEx.Message);
            }
            catch (NullReferenceException ex)
            {
                BAServiceException baEx = new BAServiceException(ErrorCode.NullReferenceException, ex.Message);
                baEx.ErrorId = ExceptionHandler.Default.Process(ex);
                throw new FaultException <BAServiceException>(baEx, baEx.Message);
            }
            catch (ArgumentOutOfRangeException ex)
            {
                BAServiceException baEx = new BAServiceException(ErrorCode.ArgumentOutOfRange, ex.Message);
                baEx.ErrorId = ExceptionHandler.Default.Process(ex);
                throw new FaultException <BAServiceException>(baEx, baEx.Message);
            }
            catch (UniqueException uniqEx)
            {
                BAServiceException baEx = new BAServiceException(ErrorCode.UniqueException, uniqEx.Message);
                baEx.ErrorId = ExceptionHandler.Default.Process(uniqEx);
                throw new FaultException <BAServiceException>(baEx, baEx.Message);
            }
            catch (CrossProfileOperationException ex)
            {
                BAServiceException baEx = new BAServiceException(ErrorCode.CrossProfileOperation, ex.Message);
                baEx.ErrorId = ExceptionHandler.Default.Process(ex);
                throw new FaultException <BAServiceException>(baEx, baEx.Message);
            }
            catch (UnauthorizedAccessException ex)
            {
                BAServiceException baEx = new BAServiceException(ErrorCode.UnauthorizedAccessException, ex.Message);
                baEx.ErrorId = ExceptionHandler.Default.Process(ex);
                throw new FaultException <BAServiceException>(baEx, baEx.Message);
            }
            catch (ValidationException ex)
            {
                ValidationFault fault = new ValidationFault();
                foreach (var result in ex.Results)
                {
                    ValidationDetail detail = new ValidationDetail(result.Message, result.Key, result.Tag);
                    fault.Add(detail);
                }

                throw new FaultException <ValidationFault>(fault, ex.Message);
            }
            catch (ArgumentException ex)
            {
                BAServiceException baEx = new BAServiceException(ErrorCode.ArgumentException, ex.Message);
                baEx.ErrorId = ExceptionHandler.Default.Process(ex);
                throw new FaultException <BAServiceException>(baEx, baEx.Message);
            }
            catch (StaleObjectStateException ex)
            {
                BAServiceException baEx = new BAServiceException(ErrorCode.OldDataException, "You are trying to change old data. In the database there is a newer version so please take the latest version and try again");
                baEx.ErrorId = ExceptionHandler.Default.Process(ex);
                throw new FaultException <BAServiceException>(baEx, baEx.Message);
            }
            catch (Exception ex)
            {
                BAServiceException baEx = new BAServiceException(ErrorCode.UnexpectedException, ex.Message);
                baEx.ErrorId = ExceptionHandler.Default.Process(ex);
                throw new FaultException <BAServiceException>(baEx, baEx.Message);
            }
        }