Beispiel #1
0
        public async Task Handle_KeepsType()
        {
            var exception        = new MyBeautifulException();
            var exceptionHandler = new RethrowExceptionHandler();

            await Assert.ThrowsAsync <MyBeautifulException>(() => exceptionHandler.HandleAsync(exception, new object(), DummyHandler));
        }
        public static void RethrowExceptionHandler(Type type)
        {
            // Arrange
            var ex      = (Exception)Activator.CreateInstance(type);
            var handler = new RethrowExceptionHandler <ArgumentException>();

            // Act
            Assert.Throws(type, () => handler.HandleException(ex));

            // Assert
        }
        public static void RethrowExceptionHandler_NoMatch(Type type)
        {
            // Arrange
            var ex      = (Exception)Activator.CreateInstance(type);
            var handler = new RethrowExceptionHandler <ArgumentException>();

            // Act
            var result = handler.HandleException(ex);

            // Assert
            Assert.False(result);
        }
Beispiel #4
0
        public async Task Handle_KeepsInstance()
        {
            var exception        = new MyBeautifulException();
            var exceptionHandler = new RethrowExceptionHandler();

            var caught = false;

            try
            {
                await exceptionHandler.HandleAsync(exception, new object(), DummyHandler);
            }
            catch (MyBeautifulException e)
            {
                caught = true;
                Assert.Same(exception, e);
            }

            Assert.True(caught);
        }