Beispiel #1
0
        internal static void Modify(INode inode, IList <INode> current, Diff <byte[], INode
                                                                              > diff)
        {
            int i = Diff.Search(current, inode.GetKey());

            NUnit.Framework.Assert.IsTrue(i >= 0);
            INodeDirectory oldinode = (INodeDirectory)current[i];
            INodeDirectory newinode = new INodeDirectory(oldinode, false, oldinode.GetFeatures
                                                             ());

            newinode.SetModificationTime(oldinode.GetModificationTime() + 1);
            current.Set(i, newinode);
            if (diff != null)
            {
                //test undo with 1/UNDO_TEST_P probability
                bool   testUndo = Random.Next(UndoTestP) == 0;
                string before   = null;
                if (testUndo)
                {
                    before = diff.ToString();
                }
                Diff.UndoInfo <INode> undoInfo = diff.Modify(oldinode, newinode);
                if (testUndo)
                {
                    string after = diff.ToString();
                    //undo
                    diff.UndoModify(oldinode, newinode, undoInfo);
                    AssertDiff(before, diff);
                    //re-do
                    diff.Modify(oldinode, newinode);
                    AssertDiff(after, diff);
                }
            }
        }