public void AGlobalUndoLimitShouldBeEnforced() { string key = "key"; var mockTask = new MockUnit(); string expectedValue1 = "1"; var target = new UndoService(); target.SetMaximumUndoCount(2, key); Assert.AreEqual(0, target.GetUnitCount(UndoService.UnitType.Repeatable, key), "Repeatable unit count should be 0."); Assert.AreEqual(0, target.GetUnitCount(UndoService.UnitType.Undoable, key), "Undoable unit count should be 0."); Assert.AreEqual(0, target.GetUnitCount(UndoService.UnitType.Redoable, key), "Redoable unit count should be 0."); for (int i = 0; i < 5; i++) { target.PerformUnit(mockTask, expectedValue1, key); } Assert.AreEqual(2, target.GetUnitCount(UndoService.UnitType.Repeatable, key), "Repeatable tasks."); Assert.AreEqual(0, target.GetUnitCount(UndoService.UnitType.Undoable, key), "Undoable tasks."); Assert.AreEqual(0, target.GetUnitCount(UndoService.UnitType.Redoable, key), "Redoable tasks."); MockUndoableUnit mockUndoableUnit = new MockUndoableUnit(); for (int i = 0; i < 5; i++) { target.PerformUnit(mockUndoableUnit, i.ToString(), key); } Assert.AreEqual(2, target.GetUnitCount(UndoService.UnitType.Repeatable, key), "Repeatable tasks."); Assert.AreEqual(2, target.GetUnitCount(UndoService.UnitType.Undoable, key), "Undoable tasks."); }