public void OnErrorDoesNotThrowOnNullContext()
 {
     using (var module = new TestableExceptionTrackingTelemetryModule(null))
     {
         module.Initialize(this.configuration);
         Assert.DoesNotThrow(() => module.OnError(null));
     }
 }
        public void OnErrorSetsHandledAtToPlatform()
        {
            var platformContext = HttpModuleHelper.GetFakeHttpContext();
            platformContext.AddError(new Exception());

            using (var module = new TestableExceptionTrackingTelemetryModule(platformContext))
            {
                module.Initialize(this.configuration);
                module.OnError(null);
            }

            Assert.Equal(ExceptionHandledAt.Platform, ((ExceptionTelemetry)this.sendItems[0]).HandledAt);
        }
        public void ConstructorSetsOnErrorAsAHanderForEvent3()
        {
            var platformContext = HttpModuleHelper.GetFakeHttpContext();
            platformContext.AddError(new Exception());

            using (var module = new TestableExceptionTrackingTelemetryModule(platformContext))
            {
                module.Initialize(this.configuration);
                WebEventsPublisher.Log.OnError();
            }

            Assert.Equal(1, this.sendItems.Count);
        }
        public void OnErrorSetsSeverityToCriticalForRequestWithStatusCode500()
        {
            var platformContext = HttpModuleHelper.GetFakeHttpContext();
            platformContext.Response.StatusCode = 500;
            platformContext.AddError(new Exception());

            using (var module = new TestableExceptionTrackingTelemetryModule(platformContext))
            {
                module.Initialize(this.configuration);
                module.OnError(null);
            }

            Assert.AreEqual(SeverityLevel.Critical, ((ExceptionTelemetry)this.sendItems[0]).SeverityLevel);
        }
        public void OnErrorTracksExceptionsThatArePresentInHttpContext()
        {
            var platformContext = HttpModuleHelper.GetFakeHttpContext();
            var exception1 = new Exception("1");
            platformContext.AddError(exception1);
            platformContext.AddError(new Exception("2"));

            using (var module = new TestableExceptionTrackingTelemetryModule(platformContext))
            {
                module.Initialize(this.configuration);
                module.OnError(null);
            }

            Assert.AreEqual(2, this.sendItems.Count);
            Assert.AreEqual(exception1, ((ExceptionTelemetry)this.sendItems[0]).Exception);
        }