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 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 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 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 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 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 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 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); } }
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); } }