예제 #1
0
        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);
        }
예제 #2
0
파일: TestCommands.cs 프로젝트: Joxx0r/ATF
        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);
        }