public void FirstInner_IsOfSameType_SameExceptionReturned()
        {
            Exception e = new Exception();

            var actual = e.FirstInner<Exception>();

            Assert.Same(e, actual);
        }
        public void FirstInner_DoesNotHaveInnerException_ReturnsNull()
        {
            Exception e = new Exception();

            Exception actual = e.FirstInner<ArgumentException>();

            Assert.Null(actual);
        }
        public void Handle(Exception exception)
        {
            var concurrencyException = exception.FirstInner<OptimisticConcurrencyException>();
            if (concurrencyException != null)
            {
                throw new ConcurrencyRepositoryViolationException(concurrencyException);
            }

            successor.Handle(exception);
        }
        public void FirstInner_InheritedExceptionFirstInner_InheritedExceptionReturned()
        {
            ArgumentException ae = new ArgumentException();
            ArgumentNullException ane = new ArgumentNullException("", ae);
            Exception e = new Exception("", ane);

            ArgumentException actual = e.FirstInner<ArgumentException>();

            Assert.Same(ane, actual);
        }
        public void Handle(Exception exception)
        {
            var updateException = exception.FirstInner<UpdateException>();
            if (updateException != null)
            {
                throw new RepositoryUpdateException(updateException);
            }

            successor.Handle(exception);
        }
        public void Handle(Exception exception)
        {
            var validationException = exception.FirstInner<DbEntityValidationException>();
            if (validationException != null)
            {
                IEnumerable<DataValidationResult> errors = GetErrors(validationException);
                throw new DataValidationException(validationException.Message, errors, validationException);
            }

            successor.Handle(exception);
        }
        public void Handle(Exception exception)
        {
            var sqlException = exception.FirstInner<SqlException>();
            if (sqlException != null)
            {
                switch (sqlException.Number)
                {
                    case 242:
                        throw new DateTimeRangeRepositoryViolationException(sqlException);
                    case 547:
                        throw new DeleteConstraintRepositoryViolationException(sqlException);
                    case 1205:
                        throw new DeadlockVictimRepositoryViolationException(sqlException);
                    case 2601:
                    case 2627:
                        throw new UniqueConstraintRepositoryViolationException(sqlException);
                    default:
                        throw new RepositoryViolationException(sqlException);
                }
            }

            successor.Handle(exception);
        }