public void SyntheticSourceIsNotSetIfNoMatch()
        {
            var eventTelemetry = new EventTelemetry("name");
            var source = new TestableSyntheticUserAgentTelemetryInitializer(new Dictionary<string, string>
                {
                    { "User-Agent", "Yan23232dexBooot" }
                });

            source.Filters = this.botSubstrings;

            source.Initialize(eventTelemetry);

            Assert.IsNull(eventTelemetry.Context.Operation.SyntheticSource);
        }
        public void SyntheticSourceIsNotSetIfUserProvidedValue()
        {
            var eventTelemetry = new EventTelemetry("name");
            eventTelemetry.Context.Operation.SyntheticSource = "SOURCE";
            var source = new TestableSyntheticUserAgentTelemetryInitializer(new Dictionary<string, string>
                {
                    { "User-Agent", "YandexBot" }
                });

            source.Filters = this.botSubstrings;

            source.Initialize(eventTelemetry);

            Assert.AreEqual("SOURCE", eventTelemetry.Context.Operation.SyntheticSource);
        }
        private void AssertSyntheticSourceIsSet(string expectedSource, string userAgent)
        {
            var metricTelemetry = new MetricTelemetry("name", 0);
            var source          = new TestableSyntheticUserAgentTelemetryInitializer(new Dictionary <string, string>
            {
                { "User-Agent", userAgent }
            });

            source.Filters.Add(this.botRegex);
            source.Filters.Add(this.yahooBotRegex);
            source.Filters.Add(this.spiderRegex);

            source.Initialize(metricTelemetry);

            Assert.AreEqual(expectedSource, metricTelemetry.Context.Operation.SyntheticSource);
        }
Пример #4
0
        public void SyntheticSourceIsNotSetIfUserProvidedValue()
        {
            var eventTelemetry = new EventTelemetry("name");

            eventTelemetry.Context.Operation.SyntheticSource = "SOURCE";
            var source = new TestableSyntheticUserAgentTelemetryInitializer(new Dictionary <string, string>
            {
                { "User-Agent", "YandexBot" }
            });

            source.Filters = this.botSubstrings;

            source.Initialize(eventTelemetry);

            Assert.AreEqual("SOURCE", eventTelemetry.Context.Operation.SyntheticSource);
        }
        public void SyntheticSourceIsSetToRegexMatchIfNoReadableSourceProvided()
        {
            var metricTelemetry = new MetricTelemetry("name", 0);
            var source          = new TestableSyntheticUserAgentTelemetryInitializer(new Dictionary <string, string>
            {
                { "User-Agent", "YandexBot 102983" }
            });

            source.Filters.Add(new SyntheticUserAgentFilter
            {
                Pattern = "(YottaaMonitor|BrowserMob|HttpMonitor|YandexBot|BingPreview|PagePeeker|ThumbShotsBot|WebThumb|URL2PNG|ZooShot|GomezA|Catchpoint bot|Willow Internet Crawler|Google SketchUp|Read%20Later)",
            });

            source.Initialize(metricTelemetry);

            Assert.AreEqual("YandexBot", metricTelemetry.Context.Operation.SyntheticSource);
        }
Пример #6
0
        public void SyntheticSourceIsSetForMultipleItemsFromSameContext()
        {
            string userAgent = "YottaaMonitor 123";

            var eventTelemetry1 = new EventTelemetry("name1");
            var eventTelemetry2 = new EventTelemetry("name2");
            var source          = new TestableSyntheticUserAgentTelemetryInitializer(new Dictionary <string, string>
            {
                { "User-Agent", userAgent }
            });

            source.Filters = this.botSubstrings;
            source.Initialize(eventTelemetry1);
            source.Initialize(eventTelemetry2);
            Assert.AreEqual("Bot", eventTelemetry2.Context.Operation.SyntheticSource, "Incorrect result for " + userAgent);
            Assert.AreEqual("Bot", eventTelemetry2.Context.Operation.SyntheticSource, "Incorrect result for " + userAgent);
        }
        public void SyntheticSourceIsNotSetIfUserProvidedValue()
        {
            var metricTelemetry = new MetricTelemetry("name", 0);
            metricTelemetry.Context.Operation.SyntheticSource = "SOURCE";
            var source = new TestableSyntheticUserAgentTelemetryInitializer(new Dictionary<string, string>
                {
                    { "User-Agent", "YandexBot" }
                });

            source.Filters.Add(new SyntheticUserAgentFilter
            {
                Pattern = "(YottaaMonitor|BrowserMob|HttpMonitor|YandexBot|BingPreview|PagePeeker|ThumbShotsBot|WebThumb|URL2PNG|ZooShot|GomezA|Catchpoint bot|Willow Internet Crawler|Google SketchUp|Read%20Later)",
            });

            source.Initialize(metricTelemetry);

            Assert.AreEqual("SOURCE", metricTelemetry.Context.Operation.SyntheticSource);
        }
        private void AssertSyntheticSourceIsSet(string expectedSource, string userAgent)
        {
            var metricTelemetry = new MetricTelemetry("name", 0);
            var source = new TestableSyntheticUserAgentTelemetryInitializer(new Dictionary<string, string>
                {
                    { "User-Agent", userAgent }
                });

            source.Filters.Add(this.botRegex);
            source.Filters.Add(this.yahooBotRegex);
            source.Filters.Add(this.spiderRegex);

            source.Initialize(metricTelemetry);

            Assert.AreEqual(expectedSource, metricTelemetry.Context.Operation.SyntheticSource);
        }
        private void AssertSyntheticSourceIsSet(string userAgent)
        {
            var eventTelemetry = new EventTelemetry("name");
            var source = new TestableSyntheticUserAgentTelemetryInitializer(new Dictionary<string, string>
                {
                    { "User-Agent", userAgent }
                });

            source.Filters = this.botSubstrings;

            source.Initialize(eventTelemetry);

            Assert.AreEqual("Bot", eventTelemetry.Context.Operation.SyntheticSource, "Incorrect result for " + userAgent);
        }