Пример #1
0
        private static void TestReverse(List <int> comparisonList, UndoableList <int> undoList)
        {
            TestEquals(comparisonList, undoList);

            comparisonList.Reverse();
            undoList.Reverse();

            TestEquals(comparisonList, undoList);

            comparisonList.Reverse();
            Debug.Assert(undoList.Undo());

            TestEquals(comparisonList, undoList);

            comparisonList.Reverse();
            Debug.Assert(undoList.Redo());

            TestEquals(comparisonList, undoList);

            int count = comparisonList.Count / 2;

            comparisonList.Reverse(0, count);
            undoList.Reverse(0, count);

            TestEquals(comparisonList, undoList);

            comparisonList.Reverse(0, count);
            Debug.Assert(undoList.Undo());

            TestEquals(comparisonList, undoList);

            comparisonList.Reverse(0, count);
            Debug.Assert(undoList.Redo());

            TestEquals(comparisonList, undoList);
        }
Пример #2
0
        private static void TestInsert(List <int> comparisonList, UndoableList <int> undoList)
        {
            TestEquals(comparisonList, undoList);

            int index = comparisonList.Count / 2;

            comparisonList.Insert(index, 999);
            undoList.Insert(index, 999);

            comparisonList.RemoveAt(index);
            Debug.Assert(undoList.Undo());

            TestEquals(comparisonList, undoList);

            comparisonList.Insert(index, 999);
            Debug.Assert(undoList.Redo());

            TestEquals(comparisonList, undoList);
        }
Пример #3
0
        private static void TestAdd(List <int> comparisonList, UndoableList <int> undoList)
        {
            TestEquals(comparisonList, undoList);

            Stack <int> redoStack = new Stack <int>();

            while (comparisonList.Count > 0)
            {
                redoStack.Push(comparisonList[comparisonList.Count - 1]);
                comparisonList.RemoveAt(comparisonList.Count - 1);
                Debug.Assert(undoList.Undo());
                TestEquals(comparisonList, undoList);
            }

            while (redoStack.Count > 0)
            {
                comparisonList.Add(redoStack.Pop());
                Debug.Assert(undoList.Redo());
                TestEquals(comparisonList, undoList);
            }
        }
Пример #4
0
        private static void TestInsertRange(List <int> comparisonList, UndoableList <int> undoList)
        {
            TestEquals(comparisonList, undoList);

            int[] range = { 1, 2, 3, 4, 5 };
            int   index = comparisonList.Count / 2;

            comparisonList.InsertRange(index, range);
            undoList.InsertRange(index, range);

            TestEquals(comparisonList, undoList);

            comparisonList.RemoveRange(index, range.Length);
            Debug.Assert(undoList.Undo());

            TestEquals(comparisonList, undoList);

            comparisonList.InsertRange(index, range);
            Debug.Assert(undoList.Redo());

            TestEquals(comparisonList, undoList);
        }