Beispiel #1
0
        public void Delete0()
        {
            var cl     = new TstClient();
            var rt     = cl.GetRoot <Root>();
            var rf     = rt.RefItems.First();
            var chd    = rf.ChildRef;
            var parent = rt.ParentItems.Single(_parent => _parent.Children.Contains(chd));

            parent.Children.Remove(chd);
            cl.Save(rt);
            Assert.IsFalse(parent.IsDirty);
            Assert.IsFalse(rf.IsDirty);
            Assert.IsFalse(rt.IsDirty);

            var cl2  = new TstClient();
            var rt2  = cl2.GetRoot <Root>();
            var rf2  = rt2.RefItems.First();
            var chd2 = rf2.ChildRef;

            Assert.AreEqual(chd.Uid, chd2.Uid);
            var parent2 = rt2.ParentItems.SingleOrDefault(_parent => _parent.Children.Contains(chd));

            Assert.IsNull(parent2);
            parent2 = rt2.ParentItems.Single(_parent => _parent.Uid == parent.Uid);
            Assert.IsNotNull(parent2);
            parent2.Children.Add(chd2);
            cl2.Save(parent2);
            TstServer.Instance.Reset();

            var cl3  = new TstClient();
            var rt3  = cl3.GetRoot <Root>();
            var rf3  = rt3.RefItems.First();
            var chd3 = rf3.ChildRef;
        }
Beispiel #2
0
        public void TwoClientObservableCollection()
        {
            var cl1       = new TstClient();
            var cl2       = new TstClient();
            var parentVM1 = cl1.GetRoot <RootVM>().ParentItems.First();
            var parentVM2 = cl2.Get <ParentVM>(parentVM1.Uid);

            var mre = new ManualResetEvent(false);

            ThreadPool.QueueUserWorkItem(_state =>
            {
                parentVM2.List.Remove(parentVM2.List.First());
                cl2.Save(parentVM1.Uid);
                mre.Set();
            });
            Assert.AreEqual(true, mre.WaitOne(100));
            cl1.Revert(parentVM1.Uid);

            Wait(100, () => parentVM2.List.Count != parentVM1.ObsCol.Count);

            Assert.AreEqual(parentVM2.List.Count, parentVM1.ObsCol.Count);
            foreach (var vm in parentVM1.List)
            {
                Assert.AreEqual(true, parentVM1.ObsCol.Contains(vm));
            }
        }
Beispiel #3
0
        public void Delete0()
        {
            var cl = new TstClient();
            var rt = cl.GetRoot<Root>();
            var rf = rt.RefItems.First();
            var chd = rf.ChildRef;
            var parent = rt.ParentItems.Single(_parent => _parent.Children.Contains(chd));
            parent.Children.Remove(chd);
            cl.Save(rt);
            Assert.IsFalse(parent.IsDirty);
            Assert.IsFalse(rf.IsDirty);
            Assert.IsFalse(rt.IsDirty);

            var cl2 = new TstClient();
            var rt2 = cl2.GetRoot<Root>();
            var rf2 = rt2.RefItems.First();
            var chd2 = rf2.ChildRef;
            Assert.AreEqual(chd.Uid, chd2.Uid);
            var parent2 = rt2.ParentItems.SingleOrDefault(_parent => _parent.Children.Contains(chd));
            Assert.IsNull(parent2);
            parent2 = rt2.ParentItems.Single(_parent => _parent.Uid == parent.Uid);
            Assert.IsNotNull(parent2);
            parent2.Children.Add(chd2);
            cl2.Save(parent2);
            TstServer.Instance.Reset();

            var cl3 = new TstClient();
            var rt3 = cl3.GetRoot<Root>();
            var rf3 = rt3.RefItems.First();
            var chd3 = rf3.ChildRef;
        }
 public void ListGetIsUndoEnabledAfterAddItemAndSave()
 {
     var cl = new TstClient();
     var root = cl.GetRoot<RootVM>();
     root.AItems.Add(new Avm {Value = 99});
     Assert.AreEqual(true, cl.GetIsUndoEnabled(root.Uid));
     cl.Save(root.Uid);
     Assert.AreEqual(false, cl.GetIsUndoEnabled(root.Uid));
 }
 public void ListGetIsUndoEnabledAfterDeleteItemAndSave()
 {
     var cl = new TstClient();
     var root = cl.GetRoot<RootVM>();
     root.AItems.Remove(root.AItems.First());
     Assert.AreEqual(true, cl.GetIsUndoEnabled(root.Uid));
     cl.Save(root.Uid);
     Assert.AreEqual(false, cl.GetIsUndoEnabled(root.Uid));
 }
 public void GetIsUndoEnabledAfterChangesAndSave()
 {
     var cl = new TstClient();
     var a = cl.GetRoot<RootVM>().AItems.First();
     a.Value = 10;
     Assert.AreEqual(true, cl.GetIsUndoEnabled(a.Uid));
     cl.Save(a.Uid);
     Assert.AreEqual(false, cl.GetIsUndoEnabled(a.Uid));
 }
        public void ListGetIsUndoEnabledAfterDeleteItemAndSave()
        {
            var cl   = new TstClient();
            var root = cl.GetRoot <RootVM>();

            root.AItems.Remove(root.AItems.First());
            Assert.AreEqual(true, cl.GetIsUndoEnabled(root.Uid));
            cl.Save(root.Uid);
            Assert.AreEqual(false, cl.GetIsUndoEnabled(root.Uid));
        }
        public void GetIsUndoEnabledAfterChangesAndSave()
        {
            var cl = new TstClient();
            var a  = cl.GetRoot <RootVM>().AItems.First();

            a.Value = 10;
            Assert.AreEqual(true, cl.GetIsUndoEnabled(a.Uid));
            cl.Save(a.Uid);
            Assert.AreEqual(false, cl.GetIsUndoEnabled(a.Uid));
        }
Beispiel #9
0
 public void Revert()
 {
     var cl1 = new TstClient();
     var a = cl1.GetRoot<Root>().AItems.First();
     a.Value = 10;
     cl1.Save(a.Uid);
     a.Value = 20;
     cl1.Revert(a.Uid);
     Assert.AreEqual(10, a.Value);
 }
Beispiel #10
0
        public void Revert()
        {
            var cl1 = new TstClient();
            var a   = cl1.GetRoot <Root>().AItems.First();

            a.Value = 10;
            cl1.Save(a.Uid);
            a.Value = 20;
            cl1.Revert(a.Uid);
            Assert.AreEqual(10, a.Value);
        }
Beispiel #11
0
 public void SaveAndRevert()
 {
     var cl1 = new TstClient();
     var cl2 = new TstClient();
     var a = cl1.GetRoot<Root>().AItems.First();
     a.Value = 10;
     var am = cl2.Get<AMirror>(a.Uid);
     cl1.Save(a.Uid);
     Assert.AreNotEqual(a.Value, am.Value);
     cl2.Revert(a.Uid);
     Assert.AreEqual(a.Value, am.Value);
 }
        public void ListGetIsUndoEnabledAfterAddItemAndSave()
        {
            var cl   = new TstClient();
            var root = cl.GetRoot <RootVM>();

            root.AItems.Add(new Avm {
                Value = 99
            });
            Assert.AreEqual(true, cl.GetIsUndoEnabled(root.Uid));
            cl.Save(root.Uid);
            Assert.AreEqual(false, cl.GetIsUndoEnabled(root.Uid));
        }
Beispiel #13
0
        public void Saving1()
        {
            var cl1 = new TstClient();
            var cl2 = new TstClient();
            var a   = cl1.GetRoot <Root>().AItems.First();

            a.Value = 10;
            cl1.Save(a.Uid);
            var am = cl2.Get <AMirror>(a.Uid);

            Assert.AreEqual(a.Value, am.Value);
        }
Beispiel #14
0
        public void SaveLoad()
        {
            var cl = new TstClient();
            var a = cl.GetRoot<Root>().AItems.First();
            a.Bytes = new byte[]{1,2,3};
            cl.Save(a);

            TstServer.Instance.Reset();

            var cl1 = new TstClient();
            var rt1 = cl1.GetRoot<Root>();
            var a1 = cl1.GetRoot<Root>().AItems.First();
            Assert.AreEqual(3, a1.Bytes.Length);
        }
Beispiel #15
0
        public void SaveLoad()
        {
            var cl = new TstClient();
            var a  = cl.GetRoot <Root>().AItems.First();

            a.Bytes = new byte[] { 1, 2, 3 };
            cl.Save(a);

            TstServer.Instance.Reset();

            var cl1 = new TstClient();
            var rt1 = cl1.GetRoot <Root>();
            var a1  = cl1.GetRoot <Root>().AItems.First();

            Assert.AreEqual(3, a1.Bytes.Length);
        }
Beispiel #16
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());
        }
Beispiel #17
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());
        }
Beispiel #18
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);
        }
Beispiel #19
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);
        }
Beispiel #20
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);
        }
Beispiel #21
0
        public void TwoClients()
        {
            var cl = new TstClient();
            var cl1 = new TstClient();
            var generalMirror = cl1.GetRoot<RootMirror>();

            var general = cl.GetRoot<RootVM>();
            general.AItems.Remove(general.AItems.First());
            cl.Save(general.Uid);
            cl1.Revert(generalMirror.Uid);
            var waitCounter = 10;
            while (general.AItems.Count != generalMirror.AItems.Count && waitCounter-- > 0)
            {
            }
            Assert.AreEqual(general.AItems.Count, generalMirror.AItems.Count);
            foreach (var a in general.AItems)
            {
                var a1 = a;
                Assert.AreEqual(a.Uid, generalMirror.AItems.Single(_mirror => _mirror.Uid == a1.Uid).Uid);
            }
        }
Beispiel #22
0
        public void TwoClientNotification()
        {
            var clVM   = new TstClient();
            var client = new TstClient();
            var avm    = clVM.GetRoot <RootVM>().AItems.First();
            var a      = client.Get <A>(avm.Uid);

            var mre = new ManualResetEvent(false);

            avm.PropertyChanged += delegate(object _sender, PropertyChangedEventArgs _args)
            {
                Assert.AreEqual("Value", _args.PropertyName);
                mre.Set();
            };
            a.Value = Int32.MaxValue;
            client.Save(avm.Uid);
            ThreadPool.QueueUserWorkItem(_state =>
            {
                clVM.Revert(avm.Uid);
            });
            Assert.AreEqual(true, mre.WaitOne(1000));
        }
Beispiel #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));
        }
Beispiel #24
0
        public void TwoClients()
        {
            var cl            = new TstClient();
            var cl1           = new TstClient();
            var generalMirror = cl1.GetRoot <RootMirror>();

            var general = cl.GetRoot <RootVM>();

            general.AItems.Remove(general.AItems.First());
            cl.Save(general.Uid);
            cl1.Revert(generalMirror.Uid);
            var waitCounter = 10;

            while (general.AItems.Count != generalMirror.AItems.Count && waitCounter-- > 0)
            {
            }
            Assert.AreEqual(general.AItems.Count, generalMirror.AItems.Count);
            foreach (var a in general.AItems)
            {
                var a1 = a;
                Assert.AreEqual(a.Uid, generalMirror.AItems.Single(_mirror => _mirror.Uid == a1.Uid).Uid);
            }
        }
Beispiel #25
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);
        }
Beispiel #26
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));
        }
Beispiel #27
0
        public void TwoClientObservableCollection()
        {
            var cl1 = new TstClient();
            var cl2 = new TstClient();
            var parentVM1 = cl1.GetRoot<RootVM>().ParentItems.First();
            var parentVM2 = cl2.Get<ParentVM>(parentVM1.Uid);

            var mre = new ManualResetEvent(false);
            ThreadPool.QueueUserWorkItem(_state =>
                                         	{
                                         		parentVM2.List.Remove(parentVM2.List.First());
                                         		cl2.Save(parentVM1.Uid);
                                         		mre.Set();
                                         	});
            Assert.AreEqual(true, mre.WaitOne(100));
            cl1.Revert(parentVM1.Uid);

            Wait(100, () => parentVM2.List.Count != parentVM1.ObsCol.Count);

            Assert.AreEqual(parentVM2.List.Count, parentVM1.ObsCol.Count);
            foreach (var vm in parentVM1.List)
            {
                Assert.AreEqual(true, parentVM1.ObsCol.Contains(vm));
            }
        }
Beispiel #28
0
        public void TwoClientNotification()
        {
            var clVM = new TstClient();
            var client = new TstClient();
            var avm = clVM.GetRoot<RootVM>().AItems.First();
            var a = client.Get<A>(avm.Uid);

            var mre = new ManualResetEvent(false);
            avm.PropertyChanged += delegate(object _sender, PropertyChangedEventArgs _args)
                                   	{
                                   		Assert.AreEqual("Value", _args.PropertyName);
                                   		mre.Set();
                                   	};
            a.Value = Int32.MaxValue;
            client.Save(avm.Uid);
            ThreadPool.QueueUserWorkItem(_state =>
                                         	{
                                         		clVM.Revert(avm.Uid);
                                         	});
            Assert.AreEqual(true, mre.WaitOne(1000));
        }