public void Should_not_TrackException_on_null_context()
            {
                // Arrange
                _telemetryClientMock
                .Setup(x => x.TrackException(It.IsAny <Exception>(), null, null))
                .Verifiable();

                // Act
                AttributeUnderTest.OnException(null);

                // Assert
                _telemetryClientMock
                .Verify(x => x.TrackException(It.IsAny <Exception>(), null, null), Times.Never);
            }
            public void Should_not_Track_null_Exception()
            {
                // Arrange
                var context = new ExceptionContext(CreateActionContext(), new List <IFilterMetadata>())
                {
                    Exception = default(Exception)
                };

                _telemetryClientMock
                .Setup(x => x.TrackException(It.IsAny <Exception>(), null, null))
                .Verifiable();

                // Act
                AttributeUnderTest.OnException(context);

                // Assert
                _telemetryClientMock
                .Verify(x => x.TrackException(It.IsAny <Exception>(), null, null), Times.Never);
            }
            public async Task Should_TrackException()
            {
                // Arrange
                var expectedException = new Exception();
                var context           = new ExceptionContext(CreateActionContext(), new List <IFilterMetadata>())
                {
                    Exception = expectedException
                };

                _telemetryClientMock
                .Setup(x => x.TrackException(expectedException, null, null))
                .Verifiable();

                // Act
                await AttributeUnderTest.OnExceptionAsync(context);

                // Assert
                _telemetryClientMock
                .Verify(x => x.TrackException(expectedException, null, null), Times.Once);
            }