Esempio n. 1
0
        public async Task LogAsync()
        {
            var mockContextLogger = new Mock <IContextExceptionLogger>();
            var logger            = new GoogleExceptionLogger(mockContextLogger.Object);

            mockContextLogger.Setup(lb => lb.LogAsync(
                                        It.IsAny <Exception>(), It.IsAny <IContextWrapper>(), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult(true));

            await logger.LogAsync(_exception, _context);

            mockContextLogger.Verify(lb => lb.LogAsync(_exception, It.IsAny <HttpContextWrapper>(), It.IsAny <CancellationToken>()));
        }
Esempio n. 2
0
        public async Task LogAsync()
        {
            var mockAccessor      = new Mock <IHttpContextAccessor>();
            var mockContextLogger = new Mock <IContextExceptionLogger>();

            mockContextLogger.Setup(lb => lb.LogAsync(
                                        It.IsAny <Exception>(), It.IsAny <IContextWrapper>(), It.IsAny <CancellationToken>()))
            .Returns(Task.CompletedTask);
            var logger = new GoogleExceptionLogger(mockContextLogger.Object, mockAccessor.Object);

            await logger.LogAsync(_exception, new DefaultHttpContext());

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