public void StringBasedRepsonsesToRowState(TestCase tc) { Mock <SummaryTextComponent> baseComponent = new Mock <SummaryTextComponent>(); StringBuilder sb = new StringBuilder(); baseComponent.Setup(c => c.BuildSummary()).Returns(sb); Mock <Host> host = ObjectFactory.BuiltObject <Host>(ObjectBuilderType.ClearwaterHost, id); Mock <ILicenseStatus> ls = new Mock <ILicenseStatus>(); ls.Setup(l => l.CurrentState).Returns(tc.State); ls.Setup(l => l.ExpiryDate).Returns(tc.Expiry); ls.Setup(l => l.LicenseExpiresIn).Returns(tc.ExpiresIn); CheckableDataGridViewRow row = new LicenseDataGridViewRow(host.Object, ls.Object); LicenseManagerSummaryLicenseExpiresDecorator decorator = new LicenseManagerSummaryLicenseExpiresDecorator(baseComponent.Object, row); decorator.BuildSummary(); Assert.That(sb.ToString().Contains(Messages.LICENSE_MANAGER_SUMMARY_LICENSE_EXPIRES)); Assert.That(sb.ToString().Contains(tc.Contains)); baseComponent.Verify(c => c.BuildSummary(), Times.Once()); }
/// <summary> /// General method for sort and refresh /// </summary> /// <param name="columnIndex"></param> /// <param name="cycleSortOrder">If true then the sort order will be cycled to the next mdoe before sorting</param> private void SortAndRefresh(int columnIndex, bool cycleSortOrder) { IComparer <CheckableDataGridViewRow> comparer = ComparerForColumn(columnIndex); if (cycleSortOrder) { SetNextSortDirection(columnIndex); } if (CurrentSortDirection == SortDirection.None) { comparer = ComparerForColumn(DefaultSortIndex); } if (comparer == null || columnIndex < 0) { return; } lock (StoredRowsLock) { View.SuspendDrawing(); try { View.DrawAllRowsAsClearedMW(); storedRows.Sort(comparer); if (CurrentSortDirection == SortDirection.Descending) { storedRows.Reverse(); } foreach (CheckableDataGridViewRow row in storedRows) { View.DrawRowMW(row); LicenseDataGridViewRow lRow = row as LicenseDataGridViewRow; if (lRow == null) { continue; } LicenseView.DrawStatusIcon(row.Index, lRow.RowStatus); if (row.Highlighted) { View.DrawRowAsHighlightedMW(true, row.Index); } } } finally { View.ResumeDrawing(); } } }
public void TestExpiredClearwater() { Mock <SummaryTextComponent> baseComponent = new Mock <SummaryTextComponent>(); StringBuilder sb = new StringBuilder(); baseComponent.Setup(c => c.BuildSummary()).Returns(sb); Mock <Host> host = ObjectFactory.BuiltObject <Host>(ObjectBuilderType.ClearwaterHost, id); ObjectManager.MockConnectionFor(id).Setup(c => c.IsConnected).Returns(true); Mock <ILicenseStatus> ls = new Mock <ILicenseStatus>(); ls.Setup(l => l.CurrentState).Returns(LicenseStatus.HostState.Expired); CheckableDataGridViewRow row = new LicenseDataGridViewRow(host.Object, ls.Object); LicenseManagerSummaryLicenseExpiresDecorator decorator = new LicenseManagerSummaryLicenseExpiresDecorator(baseComponent.Object, row); decorator.BuildSummary(); Assert.That(sb.Length, Is.EqualTo(0)); baseComponent.Verify(c => c.BuildSummary(), Times.Once()); }
public int Compare(CheckableDataGridViewRow x, CheckableDataGridViewRow y) { LicenseDataGridViewRow lx = x as LicenseDataGridViewRow; LicenseDataGridViewRow ly = y as LicenseDataGridViewRow; if (lx == null && ly != null) { return(1); } if (lx != null && ly == null) { return(-1); } if (lx == null && ly == null) { return(0); } int nameValue = lx.LicenseName.CompareTo(ly.LicenseName); return(nameValue == 0 ? lx.LicenseProductVersion.CompareTo(ly.LicenseProductVersion) : nameValue); }
public int Compare(CheckableDataGridViewRow x, CheckableDataGridViewRow y) { LicenseDataGridViewRow lx = x as LicenseDataGridViewRow; LicenseDataGridViewRow ly = y as LicenseDataGridViewRow; if (lx == null && ly != null) { return(1); } if (lx != null && ly == null) { return(-1); } if (lx == null && ly == null) { return(0); } int result = lx.CurrentLicenseState.CompareTo(ly.CurrentLicenseState); if (result == 0) { if (lx.CurrentLicenseState == LicenseStatus.HostState.RegularGrace || lx.CurrentLicenseState == LicenseStatus.HostState.UpgradeGrace) { result = lx.LicenseExpires.GetValueOrDefault().CompareTo(ly.LicenseExpires.GetValueOrDefault()); } if (result == 0) { result = lx.XenObject.Name.CompareTo(ly.XenObject.Name); } } return(result); }