public void LogAsync_DelegatesToInterfaceLogAsync(bool expectedCanBeHandled)
        {
            // Arrange
            Task expectedTask            = CreateCompletedTask();
            Mock <IExceptionLogger> mock = new Mock <IExceptionLogger>(MockBehavior.Strict);

            mock
            .Setup(h => h.LogAsync(It.IsAny <ExceptionLoggerContext>(), It.IsAny <CancellationToken>()))
            .Returns(expectedTask);

            IExceptionLogger logger = mock.Object;

            using (CancellationTokenSource tokenSource = CreateCancellationTokenSource())
            {
                ExceptionContext  expectedContext           = CreateContext();
                CancellationToken expectedCancellationToken = tokenSource.Token;

                // Act
                Task task = ExceptionLoggerExtensions.LogAsync(logger, expectedContext, expectedCanBeHandled,
                                                               expectedCancellationToken);

                // Assert
                Assert.Same(expectedTask, task);
                task.WaitUntilCompleted();

                mock.Verify(h => h.LogAsync(It.Is <ExceptionLoggerContext>(
                                                c => c.ExceptionContext == expectedContext && c.CanBeHandled == expectedCanBeHandled),
                                            expectedCancellationToken), Times.Once());
            }
        }
        public void LogAsync_IfContextIsNull_Throws()
        {
            // Arrange
            IExceptionLogger  logger            = CreateDummyLogger();
            ExceptionContext  context           = null;
            CancellationToken cancellationToken = CancellationToken.None;

            // Act & Assert
            Assert.ThrowsArgumentNull(() =>
                                      ExceptionLoggerExtensions.LogAsync(logger, context, cancellationToken), "context");
        }
        public void LogAsync_IfLoggerIsNull_Throws()
        {
            // Arrange
            IExceptionLogger  logger            = null;
            ExceptionContext  context           = CreateMinimalValidContext();
            CancellationToken cancellationToken = CancellationToken.None;

            // Act & Assert
            Assert.ThrowsArgumentNull(() =>
                                      ExceptionLoggerExtensions.LogAsync(logger, context, cancellationToken), "logger");
        }