public void InitializeSetsOperationNameWhenRequestTelemetryIsMissingInHttpContext()
        {
            var telemetry = CreateRequestTelemetry();

            var source = new TestableOperationNameTelemetryInitializer();

            source.Initialize(telemetry);

            Assert.AreEqual("GET " + HttpModuleHelper.UrlPath, telemetry.Context.Operation.Name);
        }
        public void InitializeSetsExceptionOperationName()
        {
            var exceptionTelemetry = CreateExceptionTelemetry();
            var source             = new TestableOperationNameTelemetryInitializer();

            source.FakeContext.CreateRequestTelemetryPrivate();

            source.Initialize(exceptionTelemetry);

            Assert.AreEqual("GET " + HttpModuleHelper.UrlPath, exceptionTelemetry.Context.Operation.Name);
        }
        public void InitializeDoesNotOverrideCustomerRequestName()
        {
            var source = new TestableOperationNameTelemetryInitializer();

            source.FakeContext.CreateRequestTelemetryPrivate();
            RequestTelemetry customerRequestTelemetry = new RequestTelemetry("name", DateTimeOffset.UtcNow, TimeSpan.FromSeconds(42), "404", true);

            source.Initialize(customerRequestTelemetry);

            Assert.AreEqual("name", customerRequestTelemetry.Name);
        }
        public void InitializeSetsCustomerRequestOperationNameFromRequestIfRequestNameIsNotEmpty()
        {
            var source      = new TestableOperationNameTelemetryInitializer();
            var rootRequest = source.FakeContext.CreateRequestTelemetryPrivate();

            rootRequest.Name = "Test";
            RequestTelemetry customerRequestTelemetry = new RequestTelemetry();

            source.Initialize(customerRequestTelemetry);

            Assert.AreEqual("Test", customerRequestTelemetry.Context.Operation.Name);
        }
        public void InitializeSetsCustomerRequestOperationNameFromContextIfRootRequestNameIsEmpty()
        {
            var source      = new TestableOperationNameTelemetryInitializer();
            var rootRequest = source.FakeContext.CreateRequestTelemetryPrivate();

            Assert.AreEqual(string.Empty, rootRequest.Name);
            RequestTelemetry customerRequestTelemetry = new RequestTelemetry();

            source.Initialize(customerRequestTelemetry);

            Assert.AreEqual("GET " + HttpModuleHelper.UrlPath, customerRequestTelemetry.Context.Operation.Name);
        }
        public void InitializeDoesNotOverrideCustomerOperationName()
        {
            var source = new TestableOperationNameTelemetryInitializer();

            source.FakeContext.CreateRequestTelemetryPrivate();
            var customerTelemetry = new TraceTelemetry("Text");

            customerTelemetry.Context.Operation.Name = "Name";

            source.Initialize(customerTelemetry);

            Assert.AreEqual("Name", customerTelemetry.Context.Operation.Name);
        }
        public void InitializeSetsRequestName()
        {
            var requestTelemetry = CreateRequestTelemetry();
            var source = new TestableOperationNameTelemetryInitializer();
            source.FakeContext.CreateRequestTelemetryPrivate();

            source.Initialize(requestTelemetry);

            Assert.AreEqual("GET " + HttpModuleHelper.UrlPath, requestTelemetry.Name);
        }
        public void InitializeSetsOperationNameWhenRequestTelemetryIsMissingInHttpContext()
        {
            var telemetry = CreateRequestTelemetry();

            var source = new TestableOperationNameTelemetryInitializer();
            source.Initialize(telemetry);

            Assert.AreEqual("GET " + HttpModuleHelper.UrlPath, telemetry.Context.Operation.Name);
        }
        public void InitializeDoesNotOverrideCustomerOperationName()
        {
            var source = new TestableOperationNameTelemetryInitializer();
            source.FakeContext.CreateRequestTelemetryPrivate();
            var customerTelemetry = new TraceTelemetry("Text");
            customerTelemetry.Context.Operation.Name = "Name";

            source.Initialize(customerTelemetry);

            Assert.AreEqual("Name", customerTelemetry.Context.Operation.Name);
        }
        public void InitializeDoesNotOverrideCustomerRequestName()
        {
            var source = new TestableOperationNameTelemetryInitializer();
            source.FakeContext.CreateRequestTelemetryPrivate();
            RequestTelemetry customerRequestTelemetry = new RequestTelemetry("name", DateTimeOffset.UtcNow, TimeSpan.FromSeconds(42), "404", true);

            source.Initialize(customerRequestTelemetry);

            Assert.AreEqual("name", customerRequestTelemetry.Name);
        }
        public void InitializeSetsCustomerRequestOperationNameFromRequestIfRequestNameIsNotEmpty()
        {
            var source = new TestableOperationNameTelemetryInitializer();
            var rootRequest = source.FakeContext.CreateRequestTelemetryPrivate();
            rootRequest.Name = "Test";
            RequestTelemetry customerRequestTelemetry = new RequestTelemetry();

            source.Initialize(customerRequestTelemetry);

            Assert.AreEqual("Test", customerRequestTelemetry.Context.Operation.Name);
        }
        public void InitializeSetsCustomerRequestOperationNameFromContextIfRootRequestNameIsEmpty()
        {
            var source = new TestableOperationNameTelemetryInitializer();
            var rootRequest = source.FakeContext.CreateRequestTelemetryPrivate();
            Assert.AreEqual(string.Empty, rootRequest.Name);
            RequestTelemetry customerRequestTelemetry = new RequestTelemetry();

            source.Initialize(customerRequestTelemetry);

            Assert.AreEqual("GET " + HttpModuleHelper.UrlPath, customerRequestTelemetry.Context.Operation.Name);
        }