Example #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));
            }
        }
Example #2
0
 public void IsRevertable1()
 {
     var cl = new TstClient();
     var a = cl.GetRoot<Root>().AItems.First();
     a.Value = 10;
     cl.Revert(a.Uid);
     Assert.AreEqual(false, cl.GetIsRevertEnabled(a.Uid));
 }
Example #3
0
        public void IsRevertable1()
        {
            var cl = new TstClient();
            var a  = cl.GetRoot <Root>().AItems.First();

            a.Value = 10;
            cl.Revert(a.Uid);
            Assert.AreEqual(false, cl.GetIsRevertEnabled(a.Uid));
        }
Example #4
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);
 }
Example #5
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);
        }
Example #6
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);
 }
Example #7
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);
        }
Example #8
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);
            }
        }
Example #9
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));
        }
Example #10
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);
            }
        }
Example #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));
        }
Example #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));
            }
        }