public void TestSetCountEmpty() { var errorGroupStats = new ErrorGroupStats { AffectedServices = new List <ServiceContext> { new ServiceContext() }, AffectedUsersCount = 3, NumAffectedServices = 2, TimedCounts = new List <TimedCount> { new TimedCount() } }; var objectUnderTest = new ErrorGroupItem(errorGroupStats, null); objectUnderTest.SetCountEmpty(); Assert.AreEqual(0, objectUnderTest.ErrorCount); Assert.IsNull(objectUnderTest.SeenIn); Assert.AreEqual("-", objectUnderTest.AffectedUsersCount); Assert.IsNull(objectUnderTest.TimedCountList); Assert.AreEqual(0, objectUnderTest.ErrorGroup.Count); Assert.IsNull(objectUnderTest.ErrorGroup.NumAffectedServices); Assert.IsNull(objectUnderTest.ErrorGroup.AffectedUsersCount); Assert.IsNull(objectUnderTest.ErrorGroup.TimedCounts); }
public void TestPopulatedInitalConditions() { var firstTime = new DateTime(2001, 1, 1, 1, 1, 1, DateTimeKind.Local); var lastTime = new DateTime(2011, 1, 1, 1, 1, 1, DateTimeKind.Local); const int affectedUsersCount = 3; const int count = 10; const string testServiceName = "TestService"; const int responseStatusCode = 200; const string testMessage = "TestMessage"; var timedCounts = new List <TimedCount> { new TimedCount() }; var errorGroupStats = new ErrorGroupStats { AffectedServices = new List <ServiceContext> { new ServiceContext { Service = testServiceName } }, AffectedUsersCount = affectedUsersCount, Count = count, FirstSeenTime = firstTime, LastSeenTime = lastTime, NumAffectedServices = 2, Representative = new ErrorEvent { Context = new ErrorContext { HttpRequest = new HttpRequestContext { ResponseStatusCode = responseStatusCode } }, Message = testMessage }, Group = new ErrorGroup(), TimedCounts = timedCounts }; var timeRangeItem = new TimeRangeItem( "testTimeRangeCaption", "testTimedCountDuration", ProjectsResource.GroupStatsResource.ListRequest.TimeRangePeriodEnum.PERIOD1DAY, ProjectsResource.EventsResource.ListRequest.TimeRangePeriodEnum.PERIOD1DAY); var objectUnderTest = new ErrorGroupItem(errorGroupStats, timeRangeItem); Assert.IsNotNull(objectUnderTest.ParsedException); Assert.AreEqual(errorGroupStats, objectUnderTest.ErrorGroup); Assert.AreEqual(count, objectUnderTest.ErrorCount); Assert.AreEqual(testServiceName, objectUnderTest.SeenIn); Assert.AreEqual(responseStatusCode, objectUnderTest.Status); Assert.AreEqual(testMessage, objectUnderTest.ErrorMessage); Assert.IsNull(objectUnderTest.FirstStackFrameSummary); Assert.IsNull(objectUnderTest.FirstStackFrame); Assert.AreEqual(firstTime, DateTime.Parse(objectUnderTest.FirstSeenTime)); Assert.AreEqual(lastTime, DateTime.Parse(objectUnderTest.LastSeenTime)); Assert.AreEqual(timeRangeItem, objectUnderTest.GroupTimeRange); CollectionAssert.AreEquivalent(timedCounts, objectUnderTest.TimedCountList.ToList()); Assert.AreEqual(testMessage, objectUnderTest.RawErrorMessage); Assert.AreEqual(affectedUsersCount.ToString(), objectUnderTest.AffectedUsersCount); }
public void TestConstructorErrorOnNullErrorGroup() { try { var objectUnderTest = new ErrorGroupItem(null, null); Assert.Fail(objectUnderTest.ToString()); } catch (ErrorReportingException e) { Assert.IsInstanceOfType(e.InnerException, typeof(ArgumentNullException)); throw; } }
public void BeforeEach() { PackageMock.Setup(p => p.IsWindowActive()).Returns(true); _propertiesChanged = new List <string>(); _errorFrameToSourceLineMock = new Mock <Action <ErrorGroupItem, StackFrame> >(); _showErrorReportingToolWindowMock = new Mock <Func <Task <ErrorReportingToolWindow> > >(); _dataSourceMock = new Mock <IStackdriverErrorReportingDataSource>(); _getPageOfEventsSource = new TaskCompletionSource <ListEventsResponse>(); _dataSourceMock .Setup( ds => ds.GetPageOfEventsAsync( It.IsAny <ErrorGroupStats>(), It.IsAny <EventTimeRangePeriodEnum>(), It.IsAny <string>())) .Returns(() => _getPageOfEventsSource.Task); _getPageOfGroupStatusSource = new TaskCompletionSource <ListGroupStatsResponse>(); _dataSourceMock .Setup( ds => ds.GetPageOfGroupStatusAsync( It.IsAny <GroupTimeRangePeriodEnum>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())).Returns(() => _getPageOfGroupStatusSource.Task); _objectUnderTest = new ErrorReportingDetailViewModel(_dataSourceMock.Object); _objectUnderTest.PropertyChanged += (sender, args) => _propertiesChanged.Add(args.PropertyName); _objectUnderTest.ErrorFrameToSourceLine = _errorFrameToSourceLineMock.Object; _objectUnderTest.ShowErrorReportingToolWindow = _showErrorReportingToolWindowMock.Object; _defaultTimeRangeItem = _objectUnderTest.AllTimeRangeItems.First(); _defaultErrorGroupItem = new ErrorGroupItem( new ErrorGroupStats { Group = new ErrorGroup { GroupId = "" }, TimedCounts = new List <TimedCount>() }, _defaultTimeRangeItem); PackageMock.Setup( p => p.UserPromptService.ActionPrompt( It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <bool>())) .Returns(true); }
/// <summary> /// Navigate from a parsed stack frame to source code line. /// </summary> /// <param name="errorGroupItem">The error group item that will be shown in the source code tooltip.</param> /// <param name="stackFrame">The stack frame that contains the source file and source line number.</param> public static void ErrorFrameToSourceLine( ErrorGroupItem errorGroupItem, ErrorReporting.StackFrame stackFrame) { ThreadHelper.ThrowIfNotOnUIThread(); if (errorGroupItem == null || stackFrame == null || !stackFrame.IsWellParsed) { throw new ArgumentException("Invalid argument"); } ProjectSourceFile projectFile = null; SolutionHelper solution = SolutionHelper.CurrentSolution; if (solution != null) { var items = solution.FindMatchingSourceFile(stackFrame.SourceFile); if (items.Count > 1) { var index = PickFileDialog.PickFileWindow.PromptUser(items.Select(x => x.FullName)); if (index < 0) { return; } projectFile = items.ElementAt(index); } else { projectFile = items.FirstOrDefault(); } } if (projectFile == null) { SourceVersionUtils.FileItemNotFoundPrompt(stackFrame.SourceFile); return; } var window = ShellUtils.Default.Open(projectFile.FullName); if (window == null) { FailedToOpenFilePrompt(stackFrame.SourceFile); return; } ShowToolTip(errorGroupItem, stackFrame, window); }
public void TestInitalConditions() { var errorGroupStats = new ErrorGroupStats(); var objectUnderTest = new ErrorGroupItem(errorGroupStats, null); Assert.IsNull(objectUnderTest.ParsedException); Assert.AreEqual(errorGroupStats, objectUnderTest.ErrorGroup); Assert.AreEqual(0, objectUnderTest.ErrorCount); Assert.IsNull(objectUnderTest.SeenIn); Assert.IsNull(objectUnderTest.Status); Assert.IsNull(objectUnderTest.ErrorMessage); Assert.IsNull(objectUnderTest.FirstStackFrameSummary); Assert.IsNull(objectUnderTest.FirstStackFrame); Assert.AreEqual(DateTime.MinValue, DateTime.Parse(objectUnderTest.FirstSeenTime)); Assert.AreEqual(DateTime.MinValue, DateTime.Parse(objectUnderTest.LastSeenTime)); Assert.IsNull(objectUnderTest.GroupTimeRange); Assert.IsNull(objectUnderTest.TimedCountList); Assert.IsNull(objectUnderTest.RawErrorMessage); Assert.AreEqual("-", objectUnderTest.AffectedUsersCount); }
/// <summary> /// Show the tooltip for an error group stack frame. /// </summary> /// <param name="errorGroupItem">The error group item that will be shown in the source code tooltip.</param> /// <param name="stackFrame">The stack frame that contains the source file and source line number.</param> /// <param name="window">The Visual Studio Document window that opens the source file.</param> public static void ShowToolTip( ErrorGroupItem errorGroupItem, ErrorReporting.StackFrame stackFrame, Window window) { GotoLine(window, (int)stackFrame.LineNumber); IVsTextView textView = GetIVsTextView(window.Document.FullName); var wpfView = GetWpfTextView(textView); if (wpfView == null) { return; } var control = new ErrorFrameTooltipControl(); control.DataContext = new ErrorFrameTooltipViewModel(errorGroupItem); ActiveTagData.SetCurrent( wpfView, stackFrame.LineNumber, control, ""); TryFindTagger(wpfView)?.ShowOrUpdateToolTip(); }