Esempio n. 1
0
        public void TestChainManager()
        {
            List<int> lst = new List<int>();

            RecorderTester trr = new RecorderTester(lst);
            ChainManager.IniParams p = new ChainManager.IniParams();
            p.RecordCollection.Add(trr);
            ChainManager cm = new ChainManager(p);

            // Start End Test
            cm.StartRecord();

            trr.Add(1);
            trr.Add(2);

            cm.EndRecord();

            List<int> result1 = new List<int> { 1, 2 };

            if (result1.SequenceEqual(lst) == false)
            {
                throw new NotImplementedException();
            }

            cm.StartRecord();

            trr.Add(3);
            trr.Add(4);

            cm.EndRecord();

            List<int> result2 = new List<int> { 1, 2, 3, 4 };

            if (result2.SequenceEqual(lst) == false)
            {
                throw new NotImplementedException();
            }

            // Undo Test
            cm.Undo();

            if (result1.SequenceEqual(lst) == false)
            {
                throw new NotImplementedException();
            }

            // Redo Test
            cm.Redo();

            if (result2.SequenceEqual(lst) == false)
            {
                throw new NotImplementedException();
            }

            // Cut Test
            cm.StartRecord();

            trr.Add(3);
            trr.Add(4);

            cm.CutRecord();

            if (result2.SequenceEqual(lst) == false)
            {
                throw new NotImplementedException();
            }

            // Rollback Test
            cm.Rollback();

            if (result1.SequenceEqual(lst) == false)
            {
                throw new NotImplementedException();
            }
        }