public void TestEquals() { var objectUnderTest = new TimeRangeItem("", "", 0, 0); var equalObject = new TimeRangeItem("", "", 0, 0); var selectedEqualObject = new TimeRangeItem("", "", 0, 0) { IsCurrentSelection = true }; var unequalCaption = new TimeRangeItem("unequal", "", 0, 0); var unequalDuration = new TimeRangeItem("", "unequal", 0, 0); var unequalGroupTimePeriod = new TimeRangeItem("", "", GroupTimeRangePeriodEnum.PERIOD1HOUR, 0); var unequalEventTimePeriod = new TimeRangeItem("", "", 0, EventTimeRangePeriodEnum.PERIOD1HOUR); // ReSharper disable once EqualExpressionComparison Assert.IsTrue(objectUnderTest.Equals(objectUnderTest)); Assert.IsTrue(objectUnderTest.Equals(equalObject)); Assert.IsTrue(selectedEqualObject.Equals(equalObject)); Assert.IsFalse(objectUnderTest.Equals(null)); Assert.IsFalse(objectUnderTest.Equals(new object())); Assert.IsFalse(objectUnderTest.Equals(unequalCaption)); Assert.IsFalse(objectUnderTest.Equals(unequalDuration)); Assert.IsFalse(objectUnderTest.Equals(unequalGroupTimePeriod)); Assert.IsFalse(objectUnderTest.Equals(unequalEventTimePeriod)); }
public void TestUpdateViewNewTimeRange() { TimeRangeItem newTimeRange = _objectUnderTest.AllTimeRangeItems.Skip(1).First(); _objectUnderTest.UpdateView(_defaultErrorGroupItem, newTimeRange); Assert.AreEqual(newTimeRange, _objectUnderTest.SelectedTimeRangeItem); }
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 TestSelectedTimeRangeItemProperty() { var newValue = new TimeRangeItem("", "", 0, 0); _objectUnderTest.SelectedTimeRangeItem = newValue; Assert.AreEqual(newValue, _objectUnderTest.SelectedTimeRangeItem); Assert.IsFalse(_objectUnderTest.IsLoadingComplete); CollectionAssert.Contains(_propertiesChanged, nameof(_objectUnderTest.SelectedTimeRangeItem)); }
public void TestIsCurrentSelectionProperty() { var propertiesChanged = new List <string>(); var objectUnderTest = new TimeRangeItem("", "", 0, 0); objectUnderTest.PropertyChanged += (sender, args) => propertiesChanged.Add(args.PropertyName); objectUnderTest.IsCurrentSelection = true; Assert.IsTrue(objectUnderTest.IsCurrentSelection); CollectionAssert.AreEqual(new[] { nameof(objectUnderTest.IsCurrentSelection) }, propertiesChanged); }
protected override async Task OnInitializedAsync() { await base.OnInitializedAsync(); foreach (var value in Enum.GetValues(typeof(LevelModuleVm.TimeRanges))) { var enumValue = (LevelModuleVm.TimeRanges)value; var item = new TimeRangeItem(enumValue); ComboBoxTimeRangeItems.Add(item); } SelectedComboBoxTimeRangeIndex = Convert.ToInt32(LevelModuleVm.TimeRanges.All); }
public void TestInitalConditions() { const string durationString = "duration"; const string captionString = "caption"; var objectUnderTest = new TimeRangeItem( captionString, durationString, GroupTimeRangePeriodEnum.PERIOD30DAYS, EventTimeRangePeriodEnum.PERIOD1WEEK); Assert.AreEqual(captionString, objectUnderTest.Caption); Assert.AreEqual(GroupTimeRangePeriodEnum.PERIOD30DAYS, objectUnderTest.GroupTimeRange); Assert.AreEqual(EventTimeRangePeriodEnum.PERIOD1WEEK, objectUnderTest.EventTimeRange); Assert.AreEqual(durationString, objectUnderTest.TimedCountDuration); Assert.IsFalse(objectUnderTest.IsCurrentSelection); }
public void TestInitalConditions() { Assert.IsNull(_objectUnderTest.ErrorString); Assert.IsFalse(_objectUnderTest.ShowError); Assert.IsTrue(_objectUnderTest.IsLoadingComplete); Assert.IsFalse(_objectUnderTest.IsRefreshing); Assert.IsFalse(_objectUnderTest.IsLoadingNextPage); CollectionAssert.AreEqual(TimeRangeItem.CreateTimeRanges(), _objectUnderTest.TimeRangeItemList); Assert.AreEqual(_objectUnderTest.TimeRangeItemList.Last(), _objectUnderTest.SelectedTimeRangeItem); Assert.AreEqual(0, _objectUnderTest.GroupStatsView.Count); Assert.IsTrue(_objectUnderTest.OnGotoDetailCommand.CanExecuteCommand); Assert.IsTrue(_objectUnderTest.OnAutoReloadCommand.CanExecuteCommand); Assert.IsNotNull(_objectUnderTest.CurrentTimeRangeCaption); }
public void TestSelectedTimeRangeItemProperty() { _objectUnderTest.UpdateView(_defaultErrorGroupItem, _defaultTimeRangeItem); TimeRangeItem newValue = _objectUnderTest.AllTimeRangeItems.Skip(1).First(); _propertiesChanged.Clear(); _objectUnderTest.SelectedTimeRangeItem = newValue; Assert.AreEqual(newValue, _objectUnderTest.SelectedTimeRangeItem); Assert.IsFalse(_objectUnderTest.IsControlEnabled); Assert.IsTrue(_objectUnderTest.IsGroupLoading); Assert.IsFalse(_objectUnderTest.ShowError); Assert.AreEqual(nameof(_objectUnderTest.SelectedTimeRangeItem), _propertiesChanged.First()); }
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); }
public void TestInitialConditions() { Assert.IsFalse(_objectUnderTest.IsAccountChanged); Assert.IsNull(_objectUnderTest.ErrorString); Assert.IsFalse(_objectUnderTest.ShowError); Assert.IsTrue(_objectUnderTest.IsControlEnabled); Assert.IsFalse(_objectUnderTest.IsGroupLoading); Assert.IsFalse(_objectUnderTest.IsEventLoading); Assert.IsNull(_objectUnderTest.GroupItem); Assert.IsNull(_objectUnderTest.EventItemCollection); Assert.IsNull(_objectUnderTest.SelectedTimeRangeItem); CollectionAssert.AreEqual(TimeRangeItem.CreateTimeRanges(), _objectUnderTest.AllTimeRangeItems.ToList()); Assert.IsTrue(_objectUnderTest.OnBackToOverViewCommand.CanExecuteCommand); Assert.IsTrue(_objectUnderTest.OnGotoSourceCommand.CanExecuteCommand); Assert.IsTrue(_objectUnderTest.OnAutoReloadCommand.CanExecuteCommand); }
public void TestGetHashCode() { var objectUnderTest = new TimeRangeItem("", "", 0, 0); var equalObject = new TimeRangeItem("", "", 0, 0); var selectedEqualObject = new TimeRangeItem("", "", 0, 0) { IsCurrentSelection = true }; var unequalCaption = new TimeRangeItem("unequal", "", 0, 0); var unequalDuration = new TimeRangeItem("", "unequal", 0, 0); var unequalGroupTimePeriod = new TimeRangeItem("", "", GroupTimeRangePeriodEnum.PERIOD1HOUR, 0); var unequalEventTimePeriod = new TimeRangeItem("", "", 0, EventTimeRangePeriodEnum.PERIOD1HOUR); Assert.AreEqual(objectUnderTest.GetHashCode(), objectUnderTest.GetHashCode()); Assert.AreEqual(equalObject.GetHashCode(), objectUnderTest.GetHashCode()); Assert.AreEqual(selectedEqualObject.GetHashCode(), objectUnderTest.GetHashCode()); Assert.AreNotEqual(objectUnderTest.GetHashCode(), unequalCaption.GetHashCode()); Assert.AreNotEqual(objectUnderTest.GetHashCode(), unequalDuration.GetHashCode()); Assert.AreNotEqual(objectUnderTest.GetHashCode(), unequalGroupTimePeriod.GetHashCode()); Assert.AreNotEqual(objectUnderTest.GetHashCode(), unequalEventTimePeriod.GetHashCode()); Assert.AreNotEqual(0, objectUnderTest.GetHashCode()); }
public void TestUpdateViewInvalidTimeRange() { var invalidTimeRange = new TimeRangeItem("", "", 0, 0); _objectUnderTest.UpdateView(_defaultErrorGroupItem, invalidTimeRange); }