protected void AssertValueChange(TestSetMonitor monitor, int key, string value) { Assert.AreNotEqual(monitor.InnerSet[key], value); monitor.InnerSet[key] = value; monitor.WaitOnUpdate(); Assert.IsNotNull(LastChange); Assert.AreEqual(LastChange.Key, key); Assert.AreEqual(LastChange.Value, value); }
protected void AssertStartup(TestSetMonitor monitor, bool success = true) { Assert.IsNotNull(monitor); if (!success) { Result startup; if (!(startup = monitor.Start())) { return; } monitor.WaitOnUpdate(); AssertIsFailed(monitor); return; } Assert.IsTrue(monitor.Start()); monitor.WaitOnUpdate(); }
protected void AssertValueRemove(TestSetMonitor monitor, int key) { var rc = RemovedCount; Assert.IsNotNull(monitor); var initialStatus = monitor.Status; var innerSet = monitor.InnerSet; Assert.IsTrue(innerSet.ContainsKey(key)); innerSet.Remove(key); monitor.WaitOnUpdate(); Assert.AreEqual(monitor.Status, initialStatus); Assert.IsNotNull(LastRemoved); Assert.AreEqual(LastRemoved.Count, 1); Assert.AreEqual(LastRemoved.FirstOrDefault().Key, key); Assert.AreEqual(RemovedCount, ++rc); }
protected void AssertValueAdd(TestSetMonitor monitor, int key, string value) { Assert.IsNotNull(monitor); var innerSet = monitor.InnerSet; Assert.IsFalse(innerSet.ContainsKey(key)); innerSet.Add(key, value); monitor.WaitOnUpdate(); Assert.IsNotNull(LastAdded); Assert.AreEqual(LastAdded.Count, 1); TestMonitorItem added; Assert.IsNotNull(added = LastAdded.FirstOrDefault()); Assert.AreEqual(added.Key, key); Assert.AreEqual(added.Value, value); }