예제 #1
0
        public void ThrowsReplacedExceptionWhenPostHandlingIsThrowNewExceptionAndExceptionShouldBeHandled()
        {
            var originalException = new DBConcurrencyException();

            BusinessException thrownException = ExceptionAssertHelper.Throws <BusinessException>(() =>
                                                                                                 this.exceptionManager.HandleException(originalException, "Replace DBConcurrencyException with BusinessException, ThrowNewException postHandling"));

            Assert.IsNotNull(thrownException);
            Assert.IsTrue(typeof(BusinessException).IsAssignableFrom(thrownException.GetType()));
        }
예제 #2
0
        public void TestCreateHttpClientExcecaoConfiguracao()
        {
            // Reconfigura service para gerar exceção
            BusinessException exception = Assert.ThrowsException <BusinessException>(() =>
            {
                RestClient client = new RestClient("");
            }
                                                                                     );

            Assert.IsNotNull(exception);
            Assert.IsInstanceOfType(exception.GetType(), typeof(BusinessException).GetType());
        }
예제 #3
0
        public void TestCreateHttpClientExcecao()
        {
            IConfiguration config = ConfigurationMock.SetupForFailure();

            this.BaseAddress = config.GetSection("Host").Value;
            BusinessException exception = Assert.ThrowsException <BusinessException>(() =>
            {
                RestClient client = new RestClient(this.BaseAddress);
            }
                                                                                     );

            Assert.IsNotNull(exception);
            Assert.IsInstanceOfType(exception.GetType(), typeof(BusinessException).GetType());
        }
예제 #4
0
        public void Process(Exception ex)
        {
            var bex = new BusinessException();

            if (bex.GetType() == typeof(BusinessException))
            {
                bex = (BusinessException)ex;
            }
            else
            {
                bex = new BusinessException(0, ex);
            }

            ProcessBusinessException(bex);
        }
 internal static StatusCodeResult GetStatusCode(this BusinessException ex) => ExceptionManagement[ex.GetType()];