public void TestCommandHistory() { PositiveInt x = new PositiveInt(); CommandHistory test = new CommandHistory(); // test initial state Assert.IsTrue(!test.CanUndo); Assert.IsTrue(!test.CanRedo); Assert.IsTrue(!test.Dirty); // test adding command Command cmd = new IncCommand(x); test.Add(cmd); cmd.Do(); Assert.IsTrue(x.Value == 1); Assert.IsTrue(test.CanUndo); Assert.IsTrue(!test.CanRedo); Assert.IsTrue(test.Dirty); test.Undo(); Assert.IsTrue(x.Value == 0); Assert.IsTrue(!test.CanUndo); Assert.IsTrue(test.CanRedo); Assert.IsTrue(!test.Dirty); test.Redo(); Assert.IsTrue(x.Value == 1); Assert.IsTrue(test.CanUndo); Assert.IsTrue(!test.CanRedo); Assert.IsTrue(test.Dirty); test.Dirty = false; Assert.IsTrue(!test.Dirty); cmd = new IncCommand(x); test.Add(cmd); cmd.Do(); Assert.IsTrue(test.Dirty); test.Undo(); Assert.IsTrue(!test.Dirty); test.Dirty = true; Assert.IsTrue(test.Dirty); }