public void GetA() { var cl = new TstClient(); var a1 = cl.GetRoot<Root>().AItems.First(); var a2 = cl.GetRoot<Root>().AItems.ToList()[1]; Console.WriteLine(a1); Console.WriteLine(a2); }
public void Mirror() { var cl = new TstClient(); var general = cl.GetRoot<Root>(); var generalMirror = cl.GetRoot<RootMirror>(); foreach (var a in general.AItems) { var a1 = a; Assert.AreEqual(a.Uid, generalMirror.AItems.Single(_mirror => _mirror.Uid == a1.Uid).Uid); } }
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); }
public void IsDirty() { var cl = new TstClient(); var a = cl.GetRoot<Root>().AItems.First(); a.Value = 10; Assert.AreEqual(a.IsDirty, true); }
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 IsRevertable() { var cl = new TstClient(); var a = cl.GetRoot<Root>().AItems.First(); a.Value = 10; Assert.AreEqual(true, cl.GetIsRevertEnabled(a.Uid)); }
public void GetIsUndoEnabledAfterChanges() { var cl = new TstClient(); var a = cl.GetRoot<RootVM>().AItems.First(); a.Value = 10; Assert.AreEqual(true, cl.GetIsUndoEnabled(a.Uid)); }
public void Serialize() { var cl = new TstClient(); var a = cl.GetRoot<Root>().AItems.First(); a.Value = 10; var report = new XReport(a.Uid, a.GetChanges(), (int) a.Kind, EState.SINGLE); var ser = new DataContractSerializer(typeof (XReport) //, new Type[] { typeof(XReportItem<Int32>)} ); var sb = new StringBuilder(); using (var writer = XmlWriter.Create(sb, new XmlWriterSettings {OmitXmlDeclaration = true})) { ser.WriteObject(writer, report); } var xml = sb.ToString(); var resultSerializer = new DataContractSerializer(typeof (XReport) //, new Type[] { typeof(XReportItem<Int32>) } ); XReport deserializedReport; var stream = new MemoryStream(Encoding.UTF8.GetBytes(xml)); { deserializedReport = (XReport) resultSerializer.ReadObject(stream); } var reportHC = report; var deserializedHC = deserializedReport.GetHashCode(); Assert.AreEqual(report.Uid, deserializedReport.Uid); }
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); }
public void Parent() { var cl = new TstClient(); var pr = cl.GetRoot<Root>().ParentItems.First(); foreach (var child in pr.Children) { Assert.AreEqual(pr, child.Parent); } }
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); }
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 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 CheckParent() { var cl = new TstClient(); var root = cl.GetRoot<Root>(); var pr = root.ParentItems.First(); var child = pr.Children.First(); Assert.AreNotEqual(null, child); Assert.AreEqual(pr, child.Parent); }
public void Simple() { var cl = new TstClient(); var root = cl.GetRoot<Root>(); Assert.AreNotEqual(0, root.AItems.Count); Assert.AreNotEqual(0, root.BItems.Count); Assert.AreNotEqual(0, root.ParentItems.Count); Assert.AreNotEqual(0, root.RefItems.Count); }
public void AddNewAndCheckParent() { var cl = new TstClient(); var pr = cl.GetRoot<Root>().ParentItems.First(); var child = new Child {Value = 99.9}; pr.Children.Add(child); Assert.AreEqual(true, pr.Children.Contains(child)); Assert.AreEqual(pr, child.Parent); }
public void GetRef() { var cl = new TstClient(); var root = cl.GetRoot<Root>(); var rf = root.RefItems.First(); var a = rf.Ref; Assert.AreNotEqual(null, a); Assert.IsTrue(root.AItems.Contains(a)); }
public void GetChildRef() { var cl = new TstClient(); var root = cl.GetRoot<Root>(); var rf = root.RefItems.First(); var cr = rf.ChildRef; Assert.AreNotEqual(null, cr); Assert.IsTrue(root.ParentItems.Any(_parent => _parent.Children.Contains(cr))); }
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); }
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)); }
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); }
public void Add() { var cl = new TstClient(); var pr = cl.GetRoot<Root>().ParentItems.First(); var cnt = pr.Children.Count; var child = new Child {Value = 3.0}; pr.Children.Add(child); Assert.AreEqual(cnt + 1, pr.Children.Count); Assert.AreEqual(pr, child.Parent); }
public void RemoveFromAggregated() { var cl = new TstClient(); var root = cl.GetRoot<Root>(); var a = root.AItems.First(); var cnt = root.AItems.Count; root.All.Remove(a); Assert.IsFalse(root.AItems.Contains(a)); Assert.IsFalse(root.AB.Contains(a)); Assert.AreEqual(cnt - 1, root.AItems.Count); }
public void AddToAggregated() { var cl = new TstClient(); var root = cl.GetRoot<Root>(); var a = new A {Value = 99}; var cnt = root.AItems.Count; root.All.Add(a); Assert.IsTrue(root.AItems.Contains(a)); Assert.IsTrue(root.AB.Contains(a)); Assert.AreEqual(cnt + 1, root.AItems.Count); }
public void Simple() { var cl = new TstClient(); var root = cl.GetRoot<Root>(); var allItems = root.AItems.Cast<XObject>().Union(root.BItems).Union(root.ParentItems).Union(root.RefItems).ToList(); Assert.AreEqual(allItems.Count, root.All.Count); foreach (var xObject in allItems) { Assert.IsTrue(root.All.Contains(xObject)); } }
public void MirrorNotification() { var cl = new TstClient(); var avm = cl.GetRoot<RootVM>().AItems.First(); var aMirrorVM = cl.GetRoot<RootMirrorVM>().AItems.First(); var mre = new ManualResetEvent(false); avm.PropertyChanged += delegate(object _sender, PropertyChangedEventArgs _args) { Assert.AreEqual("Value", _args.PropertyName); mre.Set(); }; ThreadPool.QueueUserWorkItem(_state => { aMirrorVM.Value = Int32.MaxValue; }); Assert.AreEqual(true, mre.WaitOne(100)); }
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)); }
public void ObservableCollection() { var cl = new TstClient(); var parent = cl.GetRoot<RootVM>().ParentItems.First(); Wait(100, () => parent.List.Count != parent.ObsCol.Count); foreach (var vm in parent.List) { Assert.AreEqual(true, parent.ObsCol.Contains(vm)); } }
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); }
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); }
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); }
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)); } }
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); }
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); }
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); }
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)); }
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 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); } }
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 Simple() { var cl = new TstClient(); Assert.AreNotEqual(null, cl.GetRoot <RootVM>().AItems.First()); }