コード例 #1
0
ファイル: UndoServiceTests.cs プロジェクト: leijiancd/Codon
        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.");
        }
コード例 #2
0
ファイル: UndoServiceTests.cs プロジェクト: leijiancd/Codon
        void NonUndoableTasksShouldNotBeUndoable(object key)
        {
            var task1  = new MockUnit();
            var target = new UndoService();

            Assert.IsFalse(target.CanUndo(key));
            target.PerformUnit(task1, "1", key);
            Assert.IsFalse(target.CanUndo(key));
        }
コード例 #3
0
ファイル: UndoServiceTests.cs プロジェクト: leijiancd/Codon
        public void NonRepeatableTaskShouldNotBeRepeatable()
        {
            var    task1  = new MockUnit();
            var    target = new UndoService();
            object key    = new object();

            Assert.IsFalse(target.CanRepeat(key));
            target.PerformUnit(task1, "1", key);
            Assert.IsFalse(target.CanRepeat(key));
        }
コード例 #4
0
ファイル: UndoServiceTests.cs プロジェクト: leijiancd/Codon
        public void NonRepeatableGlobalTaskShouldNotBeRepeatable()
        {
            var    task1  = new MockUnit();
            var    target = new UndoService();
            string arg1   = "1";

            Assert.IsFalse(target.CanRepeat(null));
            target.PerformUnit(task1, arg1, null);
            Assert.IsFalse(target.CanRepeat(null));
        }
コード例 #5
0
ファイル: UndoServiceTests.cs プロジェクト: leijiancd/Codon
        public void AGlobalTaskShouldBePerformed()
        {
            var    mockTask       = new MockUnit();
            string expectedValue1 = "1";
            var    target         = new UndoService();

            target.PerformUnit(mockTask, expectedValue1, null);

            Assert.AreEqual(mockTask.LastArgument, expectedValue1);
            Assert.AreEqual(mockTask.ExecutionCount, 1);
        }
コード例 #6
0
ファイル: UndoServiceTests.cs プロジェクト: leijiancd/Codon
        void GetRepeatableTasksShouldReturnRepeatableTasks(object key)
        {
            var task1 = new MockUnit {
                RepeatableTest = true
            };
            var target = new UndoService();
            var list   = target.GetRepeatableUnits(key);

            Assert.IsTrue(list.Count() < 1);
            target.PerformUnit(task1, string.Empty, key);
            list = target.GetRepeatableUnits(key);
            Assert.IsTrue(list.Count() > 0);
        }
コード例 #7
0
ファイル: UndoServiceTests.cs プロジェクト: leijiancd/Codon
        public void RepeatableTaskShouldBeRepeatable()
        {
            var task1 = new MockUnit {
                RepeatableTest = true
            };
            var    target = new UndoService();
            object key    = new object();

            Assert.IsFalse(target.CanRepeat(key));
            target.PerformUnit(task1, "1", key);
            Assert.IsTrue(target.CanRepeat(key));
            target.Repeat(key);
            Assert.IsTrue(task1.ExecutionCount == 2);
        }
コード例 #8
0
ファイル: UndoServiceTests.cs プロジェクト: leijiancd/Codon
        public void RepeatableGlobalTaskShouldBeRepeatable()
        {
            var task1 = new MockUnit {
                RepeatableTest = true
            };
            var    target = new UndoService();
            string arg1   = "1";

            Assert.IsFalse(target.CanRepeat(null));
            target.PerformUnit(task1, arg1, null);
            Assert.IsTrue(target.CanRepeat(null));
            target.Repeat(null);
            Assert.IsTrue(task1.ExecutionCount == 2);
        }
コード例 #9
0
ファイル: UndoServiceTests.cs プロジェクト: leijiancd/Codon
        void PerformingTaskShouldClearUndoableList(object key)
        {
            /* First set up some undoable tasks. */
            var task1  = new MockUndoableUnit();
            var target = new UndoService();

            target.PerformUnit(task1, "1", key);
            Assert.IsTrue(target.CanUndo(key));

            /* Perform a non-undoable unit. This must clear the undoable list. */
            var task2 = new MockUnit {
                RepeatableTest = true
            };

            target.PerformUnit(task2, "1", key);
            Assert.IsFalse(target.CanUndo(key));
        }