public void UndoRedo() { UndoMgr undomgr = new UndoMgr(5); ObjectStore <TestObject> objstore = new ObjectStore <TestObject>(undomgr); undomgr.BeginCommand(57, "Command1"); objstore.Add(new TestObject(5, "hello", 5.4F)); objstore.Add(new TestObject(7, "hi", 3.4F)); objstore.Add(new TestObject(9, "bat", 9.9F)); undomgr.EndCommand(57); undomgr.BeginCommand(58, "Command2"); objstore.Add(new TestObject(11, "foo", 1.4F)); objstore.Replace(new Id <TestObject>(2), new TestObject(8, "goodbye", 9.4F)); objstore.Remove(new Id <TestObject>(1)); undomgr.EndCommand(58); TestUtil.TestEnumerableAnyOrder(objstore.All, new TestObject[] { new TestObject(9, "bat", 9.9F), new TestObject(11, "foo", 1.4F), new TestObject(8, "goodbye", 9.4F) }); undomgr.Undo(); TestUtil.TestEnumerableAnyOrder(objstore.All, new TestObject[] { new TestObject(5, "hello", 5.4F), new TestObject(7, "hi", 3.4F), new TestObject(9, "bat", 9.9F) }); undomgr.Undo(); TestUtil.TestEnumerableAnyOrder(objstore.All, new TestObject[] { }); undomgr.Redo(); TestUtil.TestEnumerableAnyOrder(objstore.All, new TestObject[] { new TestObject(5, "hello", 5.4F), new TestObject(7, "hi", 3.4F), new TestObject(9, "bat", 9.9F) }); undomgr.Redo(); TestUtil.TestEnumerableAnyOrder(objstore.All, new TestObject[] { new TestObject(9, "bat", 9.9F), new TestObject(11, "foo", 1.4F), new TestObject(8, "goodbye", 9.4F) }); }
public void ChangeNum() { int changeNum; Id <TestObject> id; TestObject o; UndoMgr undomgr = new UndoMgr(5); ObjectStore <TestObject> objstore = new ObjectStore <TestObject>(undomgr); changeNum = objstore.ChangeNum; undomgr.BeginCommand(57, "Command1"); o = new TestObject(5, "hello", 5.4F); id = objstore.Add(o); Assert.IsTrue(changeNum < objstore.ChangeNum); changeNum = objstore.ChangeNum; objstore.Remove(new Id <TestObject>(1)); Assert.IsTrue(changeNum < objstore.ChangeNum); changeNum = objstore.ChangeNum; id = objstore.Add(o); Assert.IsTrue(changeNum < objstore.ChangeNum); changeNum = objstore.ChangeNum; objstore.Replace(new Id <TestObject>(2), o); Assert.IsTrue(changeNum < objstore.ChangeNum); changeNum = objstore.ChangeNum; undomgr.EndCommand(57); undomgr.Undo(); Assert.IsTrue(changeNum < objstore.ChangeNum); changeNum = objstore.ChangeNum; undomgr.Redo(); Assert.IsTrue(changeNum < objstore.ChangeNum); changeNum = objstore.ChangeNum; }
public void UndoRedo() { UndoMgr undomgr = new UndoMgr(5); ObjectStore<TestObject> objstore = new ObjectStore<TestObject>(undomgr); undomgr.BeginCommand(57, "Command1"); objstore.Add(new TestObject(5, "hello", 5.4F)); objstore.Add(new TestObject(7, "hi", 3.4F)); objstore.Add(new TestObject(9, "bat", 9.9F)); undomgr.EndCommand(57); undomgr.BeginCommand(58, "Command2"); objstore.Add(new TestObject(11, "foo", 1.4F)); objstore.Replace(new Id<TestObject>(2), new TestObject(8, "goodbye", 9.4F)); objstore.Remove(new Id<TestObject>(1)); undomgr.EndCommand(58); TestUtil.TestEnumerableAnyOrder(objstore.All, new TestObject[] { new TestObject(9, "bat", 9.9F), new TestObject(11, "foo", 1.4F), new TestObject(8, "goodbye", 9.4F) }); undomgr.Undo(); TestUtil.TestEnumerableAnyOrder(objstore.All, new TestObject[] { new TestObject(5, "hello", 5.4F), new TestObject(7, "hi", 3.4F), new TestObject(9, "bat", 9.9F) }); undomgr.Undo(); TestUtil.TestEnumerableAnyOrder(objstore.All, new TestObject[] { }); undomgr.Redo(); TestUtil.TestEnumerableAnyOrder(objstore.All, new TestObject[] { new TestObject(5, "hello", 5.4F), new TestObject(7, "hi", 3.4F), new TestObject(9, "bat", 9.9F) }); undomgr.Redo(); TestUtil.TestEnumerableAnyOrder(objstore.All, new TestObject[] { new TestObject(9, "bat", 9.9F), new TestObject(11, "foo", 1.4F), new TestObject(8, "goodbye", 9.4F) }); }
public void ChangeNum() { int changeNum; Id<TestObject> id; TestObject o; UndoMgr undomgr = new UndoMgr(5); ObjectStore<TestObject> objstore = new ObjectStore<TestObject>(undomgr); changeNum = objstore.ChangeNum; undomgr.BeginCommand(57, "Command1"); o = new TestObject(5, "hello", 5.4F); id = objstore.Add(o); Assert.IsTrue(changeNum < objstore.ChangeNum); changeNum = objstore.ChangeNum; objstore.Remove(new Id<TestObject>(1)); Assert.IsTrue(changeNum < objstore.ChangeNum); changeNum = objstore.ChangeNum; id = objstore.Add(o); Assert.IsTrue(changeNum < objstore.ChangeNum); changeNum = objstore.ChangeNum; objstore.Replace(new Id<TestObject>(2), o); Assert.IsTrue(changeNum < objstore.ChangeNum); changeNum = objstore.ChangeNum; undomgr.EndCommand(57); undomgr.Undo(); Assert.IsTrue(changeNum < objstore.ChangeNum); changeNum = objstore.ChangeNum; undomgr.Redo(); Assert.IsTrue(changeNum < objstore.ChangeNum); changeNum = objstore.ChangeNum; }