コード例 #1
0
        public void Log()
        {
            var mockContextLogger = new Mock <IContextExceptionLogger>();
            var logger            = new GoogleExceptionLogger(mockContextLogger.Object);

            logger.Log(_exception, _context);
            mockContextLogger.Verify(lb => lb.Log(_exception, It.IsAny <HttpContextWrapper>()));
        }
コード例 #2
0
        public void Log()
        {
            var mockAccessor      = new Mock <IHttpContextAccessor>();
            var mockContextLogger = new Mock <IContextExceptionLogger>();
            var logger            = new GoogleExceptionLogger(mockContextLogger.Object, mockAccessor.Object);

            logger.Log(_exception, new DefaultHttpContext());
            mockContextLogger.Verify(lb => lb.Log(_exception, It.IsAny <HttpContextWrapper>()));
        }
コード例 #3
0
        public void Log_NullContext()
        {
            var mockContextLogger = new Mock <IContextExceptionLogger>();
            var logger            = new GoogleExceptionLogger(mockContextLogger.Object);

            HttpContext.Current = null;

            logger.Log(_exception);
            mockContextLogger.Verify(lb => lb.Log(_exception, It.IsAny <HttpContextWrapper>()));
        }
コード例 #4
0
        public void Log_NoContext_NoAccessorContext()
        {
            var mockAccessor = new Mock <IHttpContextAccessor>();

            mockAccessor.Setup(a => a.HttpContext).Returns <DefaultHttpContext>(null);
            var mockContextLogger = new Mock <IContextExceptionLogger>();
            var logger            = new GoogleExceptionLogger(mockContextLogger.Object, mockAccessor.Object);

            logger.Log(_exception);
            mockContextLogger.Verify(lb => lb.Log(_exception, It.IsAny <HttpContextWrapper>()));
        }