Пример #1
0
 public void Undo0()
 {
     var cl = new TstClient();
     var a = cl.GetRoot<RootVM>().AItems.First();
     var init = a.Value;
     a.Value = 10;
     a.Value = 20;
     cl.Undo(a.Uid);
     Assert.AreEqual(10, a.Value);
     cl.Undo(a.Uid);
     Assert.AreEqual(init, a.Value);
 }
Пример #2
0
        public void Undo0()
        {
            var cl   = new TstClient();
            var a    = cl.GetRoot <RootVM>().AItems.First();
            var init = a.Value;

            a.Value = 10;
            a.Value = 20;
            cl.Undo(a.Uid);
            Assert.AreEqual(10, a.Value);
            cl.Undo(a.Uid);
            Assert.AreEqual(init, a.Value);
        }
Пример #3
0
 public void Undo2()
 {
     var cl = new TstClient();
     var rt = cl.GetRoot<Root>();
     var cnt = rt.AItems.Count;
     var a = new A {Value = 1};
     rt.AItems.Add(a);
     a.Value = 2;
     cl.Undo(rt.Uid);
     Assert.AreEqual(1, a.Value);
     cl.Undo(rt.Uid);
     Assert.AreEqual(cnt, rt.AItems.Count);
 }
Пример #4
0
 public void GetIsUndoEnabledAfterChangesAndUndo()
 {
     var cl = new TstClient();
     var a = cl.GetRoot<RootVM>().AItems.First();
     a.Value = 10;
     Assert.AreEqual(true, cl.GetIsUndoEnabled(a.Uid));
     a.Value = 20;
     Assert.AreEqual(true, cl.GetIsUndoEnabled(a.Uid));
     cl.Undo(a.Uid);
     Assert.AreEqual(true, cl.GetIsUndoEnabled(a.Uid));
     cl.Undo(a.Uid);
     Assert.AreEqual(false, cl.GetIsUndoEnabled(a.Uid));
 }
Пример #5
0
        public void GetIsUndoEnabledAfterChangesAndUndo()
        {
            var cl = new TstClient();
            var a  = cl.GetRoot <RootVM>().AItems.First();

            a.Value = 10;
            Assert.AreEqual(true, cl.GetIsUndoEnabled(a.Uid));
            a.Value = 20;
            Assert.AreEqual(true, cl.GetIsUndoEnabled(a.Uid));
            cl.Undo(a.Uid);
            Assert.AreEqual(true, cl.GetIsUndoEnabled(a.Uid));
            cl.Undo(a.Uid);
            Assert.AreEqual(false, cl.GetIsUndoEnabled(a.Uid));
        }
Пример #6
0
        public void Undo2()
        {
            var cl  = new TstClient();
            var rt  = cl.GetRoot <Root>();
            var cnt = rt.AItems.Count;
            var a   = new A {
                Value = 1
            };

            rt.AItems.Add(a);
            a.Value = 2;
            cl.Undo(rt.Uid);
            Assert.AreEqual(1, a.Value);
            cl.Undo(rt.Uid);
            Assert.AreEqual(cnt, rt.AItems.Count);
        }
Пример #7
0
 public void Undo3()
 {
     var cl = new TstClient();
     var rt = cl.GetRoot<Root>();
     var cnt = rt.AItems.Count;
     rt.AItems.Add(new A {Value = 99});
     rt.AItems.Last().Value = 100;
     rt.AItems.Add(new A {Value = 101});
     cl.Undo(rt.Uid);
     Assert.AreEqual(cnt + 1, rt.AItems.Count);
     Assert.AreEqual(100, rt.AItems.Last().Value);
     cl.Undo(rt.Uid);
     Assert.AreEqual(99, rt.AItems.Last().Value);
     cl.Undo(rt.Uid);
     Assert.AreEqual(cnt, rt.AItems.Count);
 }
Пример #8
0
        public void ListRedo1()
        {
            var cl = new TstClient();
            var root = cl.GetRoot<Root>();

            var cnt = root.AItems.Count;
            root.AItems.Add(new A {Value = 5});
            root.AItems.Last().Value = 10;
            cl.Undo(root.Uid);
            Assert.AreEqual(5, root.AItems.Last().Value);
            cl.Undo(root.Uid);
            Assert.AreEqual(cnt, root.AItems.Count);
            cl.Redo(root.Uid);
            Assert.AreEqual(cnt + 1, root.AItems.Count);
            Assert.AreEqual(5, root.AItems.Last().Value);
            cl.Redo(root.Uid);
            Assert.AreEqual(10, root.AItems.Last().Value);
        }
Пример #9
0
 public void AddUpdateAndRedo()
 {
     var cl = new TstClient();
     var root = cl.GetRoot<Root>();
     var cnt = root.BItems.Count;
     root.BItems.Add(new B {Value = "A"});
     root.BItems.Last().Value = "AA";
     cl.Undo(root.Uid);
     Assert.AreEqual("A", root.BItems.Last().Value);
     Assert.AreEqual(cnt + 1, root.BItems.Count);
     cl.Undo(root.Uid);
     Assert.AreEqual(cnt, root.BItems.Count);
     cl.Redo(root.Uid);
     Assert.AreEqual("A", root.BItems.Last().Value);
     Assert.AreEqual(cnt + 1, root.BItems.Count);
     cl.Redo(root.Uid);
     Assert.AreEqual("AA", root.BItems.Last().Value);
 }
Пример #10
0
 public void Undo()
 {
     var cl = new TstClient();
     var pr = cl.GetRoot<Root>().ParentItems.First();
     var clientSideChild = new Child {Value = 3.0};
     pr.Children.Add(clientSideChild);
     cl.Undo(pr.Uid);
     Assert.AreEqual(2, pr.Children.Count);
 }
Пример #11
0
        public void RemoveAndUndoList()
        {
            var cl1 = new TstClient();
            var rt1 = cl1.GetRoot <Root>();

            var cl2 = new TstClient();
            var rt2 = cl2.GetRoot <Root>();

            var cnt = rt1.AItems.Count;

            rt1.AItems.Remove(rt1.AItems.First());
            rt2.AItems.Remove(rt2.AItems.First());
            cl1.Save(rt1.Uid);
            Wait(100, () => rt1.IsDirty);
            cl2.Undo(rt2.Uid);
            Assert.AreEqual(cnt, rt2.AItems.Count);
            cl2.Undo(rt2.Uid);
            Assert.AreEqual(rt1.AItems.Count, rt2.AItems.Count);
        }
Пример #12
0
 public void GetIsRedoEnabled0()
 {
     var cl = new TstClient();
     var a = cl.GetRoot<Root>().AItems.First();
     a.Value = 10;
     cl.Undo(a.Uid);
     Assert.AreEqual(true, cl.GetIsRedoEnabled(a.Uid));
     cl.Redo(a.Uid);
     Assert.AreEqual(false, cl.GetIsRedoEnabled(a.Uid));
 }
Пример #13
0
        public void RemoveAndUndoList()
        {
            var cl1 = new TstClient();
            var rt1 = cl1.GetRoot<Root>();

            var cl2 = new TstClient();
            var rt2 = cl2.GetRoot<Root>();

            var cnt = rt1.AItems.Count;

            rt1.AItems.Remove(rt1.AItems.First());
            rt2.AItems.Remove(rt2.AItems.First());
            cl1.Save(rt1.Uid);
            Wait(100, () => rt1.IsDirty);
            cl2.Undo(rt2.Uid);
            Assert.AreEqual(cnt, rt2.AItems.Count);
            cl2.Undo(rt2.Uid);
            Assert.AreEqual(rt1.AItems.Count, rt2.AItems.Count);
        }
Пример #14
0
        public void AddAndUndoList()
        {
            var cl1 = new TstClient();
            var rt1 = cl1.GetRoot<Root>();

            var cl2 = new TstClient();
            var rt2 = cl2.GetRoot<Root>();

            var aValue = rt1.AItems.Last().Value;

            rt1.AItems.Add(new A {Value = 100});
            rt2.AItems.Add(new A {Value = 200});
            cl1.Save(rt1.Uid);
            Wait(100, () => rt1.IsDirty);
            cl2.Undo(rt2.Uid);
            Assert.AreEqual(aValue, rt2.AItems.Last().Value);
            cl2.Undo(rt2.Uid);
            Assert.AreEqual(rt1.AItems.Count, rt2.AItems.Count);
            Assert.AreEqual(rt1.AItems.Last().Value, rt2.AItems.Last().Value);
        }
Пример #15
0
 public void Undo1()
 {
     var cl = new TstClient();
     var rt = cl.GetRoot<Root>();
     var cnt = rt.AItems.Count;
     rt.AItems.Add(new A {Value = 1});
     Assert.IsTrue(cl.GetIsUndoEnabled(rt.Uid));
     cl.Undo(rt.Uid);
     Assert.AreEqual(cnt, rt.AItems.Count);
     Assert.IsFalse(cl.GetIsUndoEnabled(rt.Uid));
 }
Пример #16
0
        public void GetIsRedoEnabled0()
        {
            var cl = new TstClient();
            var a  = cl.GetRoot <Root>().AItems.First();

            a.Value = 10;
            cl.Undo(a.Uid);
            Assert.AreEqual(true, cl.GetIsRedoEnabled(a.Uid));
            cl.Redo(a.Uid);
            Assert.AreEqual(false, cl.GetIsRedoEnabled(a.Uid));
        }
Пример #17
0
        public void ListRedo1()
        {
            var cl   = new TstClient();
            var root = cl.GetRoot <Root>();

            var cnt = root.AItems.Count;

            root.AItems.Add(new A {
                Value = 5
            });
            root.AItems.Last().Value = 10;
            cl.Undo(root.Uid);
            Assert.AreEqual(5, root.AItems.Last().Value);
            cl.Undo(root.Uid);
            Assert.AreEqual(cnt, root.AItems.Count);
            cl.Redo(root.Uid);
            Assert.AreEqual(cnt + 1, root.AItems.Count);
            Assert.AreEqual(5, root.AItems.Last().Value);
            cl.Redo(root.Uid);
            Assert.AreEqual(10, root.AItems.Last().Value);
        }
Пример #18
0
        public void AddUpdateAndRedo()
        {
            var cl   = new TstClient();
            var root = cl.GetRoot <Root>();
            var cnt  = root.BItems.Count;

            root.BItems.Add(new B {
                Value = "A"
            });
            root.BItems.Last().Value = "AA";
            cl.Undo(root.Uid);
            Assert.AreEqual("A", root.BItems.Last().Value);
            Assert.AreEqual(cnt + 1, root.BItems.Count);
            cl.Undo(root.Uid);
            Assert.AreEqual(cnt, root.BItems.Count);
            cl.Redo(root.Uid);
            Assert.AreEqual("A", root.BItems.Last().Value);
            Assert.AreEqual(cnt + 1, root.BItems.Count);
            cl.Redo(root.Uid);
            Assert.AreEqual("AA", root.BItems.Last().Value);
        }
Пример #19
0
        public void Undo()
        {
            var cl = new TstClient();
            var pr = cl.GetRoot <Root>().ParentItems.First();
            var clientSideChild = new Child {
                Value = 3.0
            };

            pr.Children.Add(clientSideChild);
            cl.Undo(pr.Uid);
            Assert.AreEqual(2, pr.Children.Count);
        }
Пример #20
0
        public void Undo3()
        {
            var cl  = new TstClient();
            var rt  = cl.GetRoot <Root>();
            var cnt = rt.AItems.Count;

            rt.AItems.Add(new A {
                Value = 99
            });
            rt.AItems.Last().Value = 100;
            rt.AItems.Add(new A {
                Value = 101
            });
            cl.Undo(rt.Uid);
            Assert.AreEqual(cnt + 1, rt.AItems.Count);
            Assert.AreEqual(100, rt.AItems.Last().Value);
            cl.Undo(rt.Uid);
            Assert.AreEqual(99, rt.AItems.Last().Value);
            cl.Undo(rt.Uid);
            Assert.AreEqual(cnt, rt.AItems.Count);
        }
Пример #21
0
 public void Redo()
 {
     var cl = new TstClient();
     var pr = cl.GetRoot<Root>().ParentItems.First();
     var child = new Child {Value = 3.0};
     var cnt = pr.Children.Count;
     pr.Children.Add(child);
     cl.Undo(pr.Uid);
     Assert.AreEqual(cnt, pr.Children.Count);
     cl.Redo(pr.Uid);
     Assert.AreEqual(true, pr.Children.SingleOrDefault(_child => _child.Uid == child.Uid) != null);
 }
Пример #22
0
        public void ListRedo()
        {
            var cl = new TstClient();
            var root = cl.GetRoot<Root>();

            var cnt = root.AItems.Count;
            root.AItems.Add(new A());

            cl.Undo(root.Uid);
            Assert.AreEqual(cnt, root.AItems.Count);

            cl.Redo(root.Uid);
            Assert.AreEqual(cnt + 1, root.AItems.Count);
        }
Пример #23
0
        public void SaveAndUndo2()
        {
            var cl1 = new TstClient();
            var rt1 = cl1.GetRoot <Root>();

            var cl2 = new TstClient();
            var rt2 = cl2.GetRoot <Root>();

            var a1 = rt1.AItems.First();
            var a2 = rt2.AItems.First();

            var val = a1.Value;

            a2.Value = val + 2;
            a1.Value = val + 1;
            cl1.Save(a1);
            Assert.AreEqual(val + 2, a2.Value);
            cl2.Undo(a2);
            Assert.AreEqual(val, a2.Value);
            cl2.Undo(a2);
            Assert.AreEqual(val + 1, a2.Value);
            Assert.IsFalse(cl2.GetIsUndoEnabled(a2.Uid));
        }
 public void GetRefIsRedoEnabledChanged()
 {
     var cl = new TstClient();
     var root = cl.GetRoot<Root>();
     root.Revert();
     var refObject = root.RefItems.First();
     var a = refObject.Ref;
     Assert.AreEqual(false, cl.GetIsRedoEnabled(root));
     Assert.AreEqual(false, cl.GetIsRedoEnabled(refObject));
     a.Value = 9;
     cl.Undo(a);
     Assert.AreEqual(false, cl.GetIsRedoEnabled(refObject));
     Assert.AreEqual(true, cl.GetIsRedoEnabled(root));
 }
 public void GetParentIsRedoEnabledChanged()
 {
     var cl = new TstClient();
     var root = cl.GetRoot<Root>();
     root.Revert();
     var prnt = root.ParentItems.First();
     var chld = prnt.Children.First();
     Assert.AreEqual(false, cl.GetIsRedoEnabled(root));
     Assert.AreEqual(false, cl.GetIsRedoEnabled(prnt));
     chld.Value = 9.9;
     cl.Undo(chld);
     Assert.AreEqual(true, cl.GetIsRedoEnabled(prnt));
     Assert.AreEqual(true, cl.GetIsRedoEnabled(root));
 }
Пример #26
0
        public void Undo1()
        {
            var cl  = new TstClient();
            var rt  = cl.GetRoot <Root>();
            var cnt = rt.AItems.Count;

            rt.AItems.Add(new A {
                Value = 1
            });
            Assert.IsTrue(cl.GetIsUndoEnabled(rt.Uid));
            cl.Undo(rt.Uid);
            Assert.AreEqual(cnt, rt.AItems.Count);
            Assert.IsFalse(cl.GetIsUndoEnabled(rt.Uid));
        }
Пример #27
0
        public void Redo()
        {
            var cl    = new TstClient();
            var pr    = cl.GetRoot <Root>().ParentItems.First();
            var child = new Child {
                Value = 3.0
            };
            var cnt = pr.Children.Count;

            pr.Children.Add(child);
            cl.Undo(pr.Uid);
            Assert.AreEqual(cnt, pr.Children.Count);
            cl.Redo(pr.Uid);
            Assert.AreEqual(true, pr.Children.SingleOrDefault(_child => _child.Uid == child.Uid) != null);
        }
Пример #28
0
        public void ListRedo()
        {
            var cl   = new TstClient();
            var root = cl.GetRoot <Root>();

            var cnt = root.AItems.Count;

            root.AItems.Add(new A());

            cl.Undo(root.Uid);
            Assert.AreEqual(cnt, root.AItems.Count);

            cl.Redo(root.Uid);
            Assert.AreEqual(cnt + 1, root.AItems.Count);
        }
Пример #29
0
        public void AddAndUndoList()
        {
            var cl1 = new TstClient();
            var rt1 = cl1.GetRoot <Root>();

            var cl2 = new TstClient();
            var rt2 = cl2.GetRoot <Root>();

            var aValue = rt1.AItems.Last().Value;

            rt1.AItems.Add(new A {
                Value = 100
            });
            rt2.AItems.Add(new A {
                Value = 200
            });
            cl1.Save(rt1.Uid);
            Wait(100, () => rt1.IsDirty);
            cl2.Undo(rt2.Uid);
            Assert.AreEqual(aValue, rt2.AItems.Last().Value);
            cl2.Undo(rt2.Uid);
            Assert.AreEqual(rt1.AItems.Count, rt2.AItems.Count);
            Assert.AreEqual(rt1.AItems.Last().Value, rt2.AItems.Last().Value);
        }
        public void GetRefIsRedoEnabledChanged()
        {
            var cl   = new TstClient();
            var root = cl.GetRoot <Root>();

            root.Revert();
            var refObject = root.RefItems.First();
            var a         = refObject.Ref;

            Assert.AreEqual(false, cl.GetIsRedoEnabled(root));
            Assert.AreEqual(false, cl.GetIsRedoEnabled(refObject));
            a.Value = 9;
            cl.Undo(a);
            Assert.AreEqual(false, cl.GetIsRedoEnabled(refObject));
            Assert.AreEqual(true, cl.GetIsRedoEnabled(root));
        }
        public void GetParentIsRedoEnabledChanged()
        {
            var cl   = new TstClient();
            var root = cl.GetRoot <Root>();

            root.Revert();
            var prnt = root.ParentItems.First();
            var chld = prnt.Children.First();

            Assert.AreEqual(false, cl.GetIsRedoEnabled(root));
            Assert.AreEqual(false, cl.GetIsRedoEnabled(prnt));
            chld.Value = 9.9;
            cl.Undo(chld);
            Assert.AreEqual(true, cl.GetIsRedoEnabled(prnt));
            Assert.AreEqual(true, cl.GetIsRedoEnabled(root));
        }
Пример #32
0
        public void ChangeAMirror()
        {
            var cl = new TstClient();
            var rf = cl.GetRoot<Root>().RefItems.First();
            Assert.AreEqual(cl.GetRoot<Root>().AItems.First(), rf.Ref);

            var a2 = cl.GetRoot<Root>().AItems.ToList()[1];
            rf.Ref = a2;
            var rfm = cl.Get<RefMirror>(rf.Uid);
            Assert.AreEqual(rfm.Ref, rf.Ref);
            Assert.AreEqual(rfm.IsDirty, true);

            cl.Undo(rf.Uid);
            Assert.AreEqual(cl.GetRoot<Root>().AItems.First(), rf.Ref);
            Assert.AreEqual(cl.GetRoot<Root>().AItems.First(), rfm.Ref);
        }
Пример #33
0
        public void SaveAndUndo()
        {
            var cl1 = new TstClient();
            var rt1 = cl1.GetRoot <Root>();

            var cl2 = new TstClient();
            var rt2 = cl2.GetRoot <Root>();

            Assert.AreEqual(rt1.RefItems.First().Ref, rt1.AItems.First());
            Assert.AreNotEqual(rt1.RefItems.First().Ref, rt1.AItems.ToList()[1]);
            rt1.RefItems.First().Ref = rt1.AItems.ToList()[1];
            rt2.RefItems.First().Ref = rt2.AItems.ToList()[1];
            cl1.Save(rt1);
            cl2.Undo(rt2);
            Assert.AreEqual(rt2.RefItems.First().Ref.Uid, rt2.AItems.First().Uid);
            Assert.AreEqual(rt2.RefItems.First().Ref, rt2.AItems.First());
        }
Пример #34
0
        public void SaveAndUndo()
        {
            var cl1 = new TstClient();
            var rt1 = cl1.GetRoot<Root>();

            var cl2 = new TstClient();
            var rt2 = cl2.GetRoot<Root>();

            Assert.AreEqual(rt1.RefItems.First().Ref, rt1.AItems.First());
            Assert.AreNotEqual(rt1.RefItems.First().Ref, rt1.AItems.ToList()[1]);
            rt1.RefItems.First().Ref = rt1.AItems.ToList()[1];
            rt2.RefItems.First().Ref = rt2.AItems.ToList()[1];
            cl1.Save(rt1);
            cl2.Undo(rt2);
            Assert.AreEqual(rt2.RefItems.First().Ref.Uid, rt2.AItems.First().Uid);
            Assert.AreEqual(rt2.RefItems.First().Ref, rt2.AItems.First());
        }
Пример #35
0
        public void ChangeAMirror()
        {
            var cl = new TstClient();
            var rf = cl.GetRoot <Root>().RefItems.First();

            Assert.AreEqual(cl.GetRoot <Root>().AItems.First(), rf.Ref);


            var a2 = cl.GetRoot <Root>().AItems.ToList()[1];

            rf.Ref = a2;
            var rfm = cl.Get <RefMirror>(rf.Uid);

            Assert.AreEqual(rfm.Ref, rf.Ref);
            Assert.AreEqual(rfm.IsDirty, true);

            cl.Undo(rf.Uid);
            Assert.AreEqual(cl.GetRoot <Root>().AItems.First(), rf.Ref);
            Assert.AreEqual(cl.GetRoot <Root>().AItems.First(), rfm.Ref);
        }
Пример #36
0
        public void SaveAndUndo2()
        {
            var cl1 = new TstClient();
            var rt1 = cl1.GetRoot<Root>();

            var cl2 = new TstClient();
            var rt2 = cl2.GetRoot<Root>();

            var a1 = rt1.AItems.First();
            var a2 = rt2.AItems.First();

            var val = a1.Value;
            a2.Value = val + 2;
            a1.Value = val + 1;
            cl1.Save(a1);
            Assert.AreEqual(val + 2, a2.Value);
            cl2.Undo(a2);
            Assert.AreEqual(val, a2.Value);
            cl2.Undo(a2);
            Assert.AreEqual(val + 1, a2.Value);
            Assert.IsFalse(cl2.GetIsUndoEnabled(a2.Uid));
        }