Example #1
0
        public void Constructor_DerfensivelyCopiesSet()
        {
            // Arrange

            var ignored = new HashSet <Type>();
            var handler = new IgnoredExceptionHandler(ignored);

            // Act

            ignored.Add(typeof(ArgumentOutOfRangeException));
            var isIgnored = handler.IsExceptionIgnored(typeof(ArgumentOutOfRangeException));

            // Assert

            Assert.False(isIgnored);
        }
Example #2
0
        public void IsExceptionIgnored_AllowsExceptionsNotInSet()
        {
            // Arrange

            var ignored = new HashSet <Type>
            {
                typeof(ArgumentNullException)
            };
            var handler = new IgnoredExceptionHandler(ignored);

            // Act

            var isIgnored = handler.IsExceptionIgnored(typeof(InvalidOperationException));

            // Assert

            Assert.False(isIgnored);
        }
Example #3
0
        public void IsExceptionIgnored_RequiresSpecificExceptionsAndDoesntIgnoreInherited()
        {
            // Arrange

            var ignored = new HashSet <Type>
            {
                typeof(ArgumentException)
            };
            var handler = new IgnoredExceptionHandler(ignored);

            // Act

            var isIgnored = handler.IsExceptionIgnored(typeof(ArgumentNullException));

            // Assert

            Assert.False(isIgnored);
        }
Example #4
0
        public void IsExceptionIgnored_IgnoresExceptionsFromSet()
        {
            // Arrange

            var ignored = new HashSet <Type>
            {
                typeof(ArgumentNullException)
            };
            var handler = new IgnoredExceptionHandler(ignored);

            // Act

            var isIgnored = handler.IsExceptionIgnored(typeof(ArgumentNullException));

            // Assert

            Assert.True(isIgnored);
        }