public void ConstructorSetsOnBeginAsAHanderForEvent2() { var context = HttpModuleHelper.GetFakeHttpContext(); using (var module = new TestableRequestTrackingTelemetryModule(context)) { module.Initialize(TelemetryConfiguration.CreateDefault()); WebEventsPublisher.Log.OnEnd(); Assert.IsNotNull(context.GetRequestTelemetry()); } }
public void OnEndSetsDurationToPositiveValue() { var context = HttpModuleHelper.GetFakeHttpContext(); var module = new TestableRequestTrackingTelemetryModule(context); module.Initialize(TelemetryConfiguration.CreateDefault()); module.OnBeginRequest(null); module.OnEndRequest(null); Assert.IsTrue(context.GetRequestTelemetry().Duration.TotalMilliseconds >= 0); }
public void OnEndSetsHttpMethod() { var context = HttpModuleHelper.GetFakeHttpContext(); var module = new TestableRequestTrackingTelemetryModule(context); module.Initialize(TelemetryConfiguration.CreateDefault()); module.OnBeginRequest(null); module.OnEndRequest(null); Assert.AreEqual(context.Request.HttpMethod, context.GetRequestTelemetry().HttpMethod); }
public void OnEndCreatesRequestTelemetryIfBeginWasNotCalled() { var context = HttpModuleHelper.GetFakeHttpContext(); using (var module = new TestableRequestTrackingTelemetryModule(context)) { module.Initialize(TelemetryConfiguration.CreateDefault()); module.OnEndRequest(null); Assert.IsNotNull(context.GetRequestTelemetry()); } }
public void OnEndSetsDurationToZeroIfBeginWasNotCalled() { var context = HttpModuleHelper.GetFakeHttpContext(); using (var module = new TestableRequestTrackingTelemetryModule(context)) { module.Initialize(TelemetryConfiguration.CreateDefault()); module.OnEndRequest(null); Assert.AreEqual(0, context.GetRequestTelemetry().Duration.Ticks); } }
public void OnEndSetsUrl() { var context = HttpModuleHelper.GetFakeHttpContext(); using (var module = new TestableRequestTrackingTelemetryModule(context)) { module.Initialize(TelemetryConfiguration.CreateDefault()); module.OnBeginRequest(null); module.OnEndRequest(null); Assert.Equal(context.Request.Url, context.GetRequestTelemetry().Url); } }
public void RequestIdIsAvailableAfterOnBegin() { var context = HttpModuleHelper.GetFakeHttpContext(); var requestTelemetry = context.CreateRequestTelemetryPrivate(); using (var module = new TestableRequestTrackingTelemetryModule(context)) { module.Initialize(TelemetryConfiguration.CreateDefault()); module.OnBeginRequest(null); Assert.IsTrue(!string.IsNullOrEmpty(requestTelemetry.Id)); } }
public void OnBeginRequestSetsTimeIfItWasNotAssignedBefore() { var context = HttpModuleHelper.GetFakeHttpContext(); var requestTelemetry = context.CreateRequestTelemetryPrivate(); requestTelemetry.StartTime = default(DateTimeOffset); using (var module = new TestableRequestTrackingTelemetryModule(context)) { module.Initialize(TelemetryConfiguration.CreateDefault()); module.OnBeginRequest(null); Assert.AreNotEqual(default(DateTimeOffset), requestTelemetry.Timestamp); } }
public void OnEndSetsResponseCode() { var context = HttpModuleHelper.GetFakeHttpContext(); context.Response.StatusCode = 401; using (var module = new TestableRequestTrackingTelemetryModule(context)) { module.Initialize(TelemetryConfiguration.CreateDefault()); module.OnBeginRequest(null); module.OnEndRequest(null); Assert.AreEqual("401", context.GetRequestTelemetry().ResponseCode); } }
public void OnEndDoesNotOverrideHttpMethod() { var context = HttpModuleHelper.GetFakeHttpContext(); using (var module = new TestableRequestTrackingTelemetryModule(context)) { module.Initialize(TelemetryConfiguration.CreateDefault()); module.OnBeginRequest(null); var requestTelemetry = context.GetRequestTelemetry(); requestTelemetry.HttpMethod = "Test"; module.OnEndRequest(null); Assert.AreEqual("Test", requestTelemetry.HttpMethod); } }
public void OnEndDoesNotOverrideUrl() { var context = HttpModuleHelper.GetFakeHttpContext(); using (var module = new TestableRequestTrackingTelemetryModule(context)) { module.Initialize(TelemetryConfiguration.CreateDefault()); module.OnBeginRequest(null); var requestTelemetry = context.GetRequestTelemetry(); requestTelemetry.Url = new Uri("http://test/"); module.OnEndRequest(null); Assert.AreEqual("http://test/", requestTelemetry.Url.OriginalString); } }
public void OnEndDoesNotOverrideResponseCode() { var context = HttpModuleHelper.GetFakeHttpContext(); context.Response.StatusCode = 300; using (var module = new TestableRequestTrackingTelemetryModule(context)) { module.Initialize(TelemetryConfiguration.CreateDefault()); module.OnBeginRequest(null); var requestTelemetry = context.GetRequestTelemetry(); requestTelemetry.ResponseCode = "Test"; module.OnEndRequest(null); Assert.Equal("Test", requestTelemetry.ResponseCode); } }
public void OnEndDoesNotOverrideHttpMethod() { var context = HttpModuleHelper.GetFakeHttpContext(); using (var module = new TestableRequestTrackingTelemetryModule(context)) { module.Initialize(TelemetryConfiguration.CreateDefault()); module.OnBeginRequest(null); var requestTelemetry = context.GetRequestTelemetry(); requestTelemetry.HttpMethod = "Test"; module.OnEndRequest(null); Assert.Equal("Test", requestTelemetry.HttpMethod); } }
public void OnEndSetsUrl() { var context = HttpModuleHelper.GetFakeHttpContext(); using (var module = new TestableRequestTrackingTelemetryModule(context)) { module.Initialize(TelemetryConfiguration.CreateDefault()); module.OnBeginRequest(null); module.OnEndRequest(null); Assert.AreEqual(context.Request.Url, context.GetRequestTelemetry().Url); } }
public void OnEndSetsHttpMethod() { var context = HttpModuleHelper.GetFakeHttpContext(); var module = new TestableRequestTrackingTelemetryModule(context); module.Initialize(TelemetryConfiguration.CreateDefault()); module.OnBeginRequest(null); module.OnEndRequest(null); Assert.Equal(context.Request.HttpMethod, context.GetRequestTelemetry().HttpMethod); }
public void OnEndDoesNotOverrideResponseCode() { var context = HttpModuleHelper.GetFakeHttpContext(); context.Response.StatusCode = 300; using (var module = new TestableRequestTrackingTelemetryModule(context)) { module.Initialize(TelemetryConfiguration.CreateDefault()); module.OnBeginRequest(null); var requestTelemetry = context.GetRequestTelemetry(); requestTelemetry.ResponseCode = "Test"; module.OnEndRequest(null); Assert.AreEqual("Test", requestTelemetry.ResponseCode); } }