Exemplo n.º 1
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));
            }
        }
Exemplo n.º 2
0
        public void ChangeAMirror()
        {
            var cl = new TstClient();
            var a = cl.GetRoot<Root>().AItems.First();
            a.Value = 10;

            var am = cl.Get<AMirror>(a.Uid);
            Assert.AreEqual(a.Value, am.Value);
            Assert.AreEqual(am.IsDirty, true);
        }
Exemplo n.º 3
0
        public void Simple()
        {
            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);

            Assert.AreNotEqual(a.Value, am.Value);
        }
Exemplo n.º 4
0
        public void ChangeAMirror()
        {
            var cl = new TstClient();
            var a  = cl.GetRoot <Root>().AItems.First();

            a.Value = 10;

            var am = cl.Get <AMirror>(a.Uid);

            Assert.AreEqual(a.Value, am.Value);
            Assert.AreEqual(am.IsDirty, true);
        }
Exemplo n.º 5
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);
 }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
0
 public void MirrorObservableCollection()
 {
     var cl = new TstClient();
     var parent = cl.GetRoot<RootVM>().ParentItems.First();
     var parentM = cl.Get<ParentMirrorVM>(parent.Uid);
     var mre = new ManualResetEvent(false);
     ThreadPool.QueueUserWorkItem(_state =>
                                  	{
                                  		parentM.List.Remove(parentM.List.First());
                                  		mre.Set();
                                  	});
     Assert.AreEqual(true, mre.WaitOne(100));
     Wait(100, () => parentM.List.Count != parent.ObsCol.Count);
     foreach (var vm in parent.List)
     {
         Assert.AreEqual(true, parent.ObsCol.Contains(vm));
     }
 }
Exemplo n.º 8
0
        public void MirrorObservableCollection()
        {
            var cl      = new TstClient();
            var parent  = cl.GetRoot <RootVM>().ParentItems.First();
            var parentM = cl.Get <ParentMirrorVM>(parent.Uid);
            var mre     = new ManualResetEvent(false);

            ThreadPool.QueueUserWorkItem(_state =>
            {
                parentM.List.Remove(parentM.List.First());
                mre.Set();
            });
            Assert.AreEqual(true, mre.WaitOne(100));
            Wait(100, () => parentM.List.Count != parent.ObsCol.Count);
            foreach (var vm in parent.List)
            {
                Assert.AreEqual(true, parent.ObsCol.Contains(vm));
            }
        }
Exemplo n.º 9
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);
        }
Exemplo n.º 10
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));
        }
Exemplo n.º 11
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));
        }
Exemplo n.º 12
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));
            }
        }