Пример #1
0
        public void CapturesConstantArguments()
        {
// ReSharper disable once ReturnValueOfPureMethodIsNotUsed
            var handler = ExceptionFilter.From <string>((c, s) => s.IndexOf('a'));

            Assert.Equal('a', handler.Arguments[0]);
        }
Пример #2
0
        public void CapturesType()
        {
// ReSharper disable once ReturnValueOfPureMethodIsNotUsed
            var handler = ExceptionFilter.From <string>((c, s) => s.IndexOf('c'));

            Assert.Equal(typeof(string), handler.Type);
        }
Пример #3
0
        public void CapturesArgumentReference(char argument)
        {
// ReSharper disable once ReturnValueOfPureMethodIsNotUsed
            var handler = ExceptionFilter.From <string>((c, s) => s.IndexOf(argument));

            Assert.Equal(argument, handler.Arguments[0]);
        }
Пример #4
0
        public void CapturesComplexPropertyReference()
        {
            var thisMethod = GetType().GetMethod("CapturesComplexPropertyReference");

// ReSharper disable once ReturnValueOfPureMethodIsNotUsed
            var handler = ExceptionFilter.From <string>((c, s) => s.StartsWith(thisMethod.Name));

            Assert.Equal(thisMethod.Name, handler.Arguments[0]);
        }
Пример #5
0
        public void CapturesLocalValiableReferences()
        {
// ReSharper disable once ConvertToConstant.Local
            var argument = 'a';

// ReSharper disable once ReturnValueOfPureMethodIsNotUsed
            var handler = ExceptionFilter.From <string>((c, s) => s.IndexOf(argument));

            Assert.Equal(argument, handler.Arguments[0]);
        }
Пример #6
0
        public void CreatesAPlaceholderForExceptionContext()
        {
            var handler = ExceptionFilter.From <ExceptionFilterForMethodFacts>((c, h) => h.Log(c));

            Assert.IsType <ExceptionContext>(handler.Arguments[0]);
        }