Beispiel #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()));
        }
Beispiel #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());
        }
Beispiel #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());
        }
Beispiel #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()];