public async Task 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 await AttributeUnderTest.OnExceptionAsync(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); }