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()); }
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()); }