Пример #1
0
        //TODO merge with settings service
        public Profile(string source)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(source))
                {
                    return;
                }

                XmlSerializer serializer = new XmlSerializer(typeof(Profile));
                StringReader  sr         = new StringReader(source);
                Profile       p          = serializer.Deserialize(sr) as Profile;

                if (p != null)
                {
                    foreach (KeyBinding k in p)
                    {
                        Add(k);
                    }
                }
            }
            catch (Exception ex) {
                TelemetryService.TrackException(ex);
            }
        }
Пример #2
0
        public void TrackException(Exception ex)
        {
            bool isDebug = IsDebugRun();

            if (!isDebug)
            {
                TelemetryService.TrackException(ex, isDebug);
            }
        }
Пример #3
0
        public void TrackTestExecution(string projectTrackInfo)
        {
            bool isDebug = IsDebugRun();

            try
            {
                if (!isDebug)
                {
                    projectTrackInfo = $"{projectTrackInfo}  Framework";

                    var assemblyFacade      = new AssemblyFacade();
                    var callingAssemblies   = assemblyFacade.GetAssembliesCallChain();
                    var testProjectAssembly = callingAssemblies[3];

                    if (callingAssemblies.Any(x => x.FullName.Contains("SpecFlow")))
                    {
                        projectTrackInfo = $"{projectTrackInfo} SpecFlow";
                    }

                    if (testProjectAssembly.FullName.Contains("GettingStarted"))
                    {
                        projectTrackInfo = $"{projectTrackInfo} GettingStarted";
                    }

                    var            testInfoProvider = new TestInfoProvider();
                    EventTelemetry eventTelemetry   = default;
                    int            mstestTestsCount = testInfoProvider.CountBellatrixTests(testProjectAssembly, _msTestClassAttributeName, _msTestTestAttributeName);
                    int            nunitTestsCount  = testInfoProvider.CountBellatrixTests(testProjectAssembly, _nunitTestFixtureAttributeName, _nunitTestAttributeName);
                    if (mstestTestsCount > 0)
                    {
                        eventTelemetry      = new EventTelemetry();
                        eventTelemetry.Name = "MSTest Test Run";
                        eventTelemetry.Metrics.Add(projectTrackInfo, mstestTestsCount);
                    }

                    if (nunitTestsCount > 0)
                    {
                        eventTelemetry      = new EventTelemetry();
                        eventTelemetry.Name = "NUnit Test Run";
                        eventTelemetry.Metrics.Add(projectTrackInfo, nunitTestsCount);
                    }

                    TelemetryService.TrackEvent(eventTelemetry, isDebug);
                }
            }
            catch (Exception ex)
            {
                TelemetryService.TrackException(ex, isDebug);
            }
        }
        public async Task TrackException_ShouldAddException()
        {
            var exception = new Exception("Some message");

            exception.Data["bob"]  = "John";
            exception.Data["Jill"] = "Jack";

            await _telemetryService.TrackException(_httpContext, exception);

            var telemetryException = _exceptionRepository.Entities.Single();

            Assert.Equal(_dateTimeServiceStub.Now, telemetryException.Timestamp);
            Assert.Equal(_httpContext.Request.GetDisplayUrl(), telemetryException.Url);
            Assert.Equal(_httpContext.Request.Method, telemetryException.Method);
            Assert.Equal("Some message", telemetryException.Message);
            Assert.Equal("{\"bob\":\"John\",\"Jill\":\"Jack\"}", telemetryException.Data);
            Assert.Equal(exception.StackTrace, telemetryException.StackTrace);
        }