static void TestHistoryBasics() { DocList <IDocLeaf> testDoc = new DocList <IDocLeaf>(); History.Instance.Root = testDoc; UnitTest.Test(History.Instance.HasUndo == false); UnitTest.Test(History.Instance.HasRedo == false); DocObj <int> testInt = new DocObj <int>(0); testDoc.Add(testInt); UnitTest.Test(History.Instance.HasUndo == true); UnitTest.Test(History.Instance.HasRedo == false); testInt.Value = 1; UnitTest.Test(testInt.Value == 1); testInt.Value = 2; UnitTest.Test(testInt.Value == 2); testInt.Value = 3; UnitTest.Test(testInt.Value == 3); History.Instance.Undo(); UnitTest.Test(testInt.Value == 0); UnitTest.Test(History.Instance.HasRedo == true); History.Instance.Redo(); UnitTest.Test(testInt.Value == 3); }
static void TestPathBasics() { IDocLeaf doc = DocNode.Create <TestDocument>(); string pathToMyInt = "TestList.2"; DocObj <int> myInt = PathUtils.ChildByPath <DocObj <int> >( doc as IDocNode, pathToMyInt); UnitTest.Test(myInt.Value == 2); UnitTest.Test(PathUtils.PathByChild(myInt) == pathToMyInt); string pathToMyBool = "TestBool"; DocObj <bool> myBool = PathUtils.ChildByPath <DocObj <bool> >( doc as IDocNode, pathToMyBool); UnitTest.Test(myBool.Value == true); UnitTest.Test(PathUtils.PathByChild(myBool) == pathToMyBool); string pathToMyInt2 = "SubDoc.TestInt0"; DocObj <int> myInt2 = PathUtils.ChildByPath <DocObj <int> >( doc as IDocNode, pathToMyInt2); UnitTest.Test(myInt2.Value == 2); UnitTest.Test(PathUtils.PathByChild(myInt2) == pathToMyInt2); }
static void TestDocObjSerialization() { DocObj <int> obj0 = new DocObj <int>(777); DocObj <int> obj1 = SerializeDeserialize(obj0); UnitTest.Test(obj0.Value == obj1.Value); }
static void Test_DocObj_String() { DocObj <string> obj = new DocObj <string>(); obj.Value = "Hello"; UnitTest.Test(obj.Value == "Hello"); obj.Value = "World"; UnitTest.Test(obj.Value == "World"); }
static void Test_DocObj_Int() { DocObj <int> obj = new DocObj <int>(); obj.Value = 1; UnitTest.Test(obj.Value == 1); obj.Value = 2; UnitTest.Test(obj.Value == 2); }
static void Test_DocObj_Notifier() { DocObj <int> obj = new DocObj <int>(); PropertyChangedTest pct = new PropertyChangedTest(); obj.PropertyChanged += pct.PropertyChanged; obj.Value = 1; pct.TestWasCalledOnce(); }
static void Test_DocObj_ByteArray() { DocObj <byte[]> obj = new DocObj <byte[]>(); byte[] arr0 = { 0, 1, 2 }; obj.Value = arr0; UnitTest.Test(ArrayUtils.IsEqual(obj.Value, arr0)); byte[] arr1 = { 3, 4, 5 }; obj.Value = arr1; UnitTest.Test(ArrayUtils.IsEqual(obj.Value, arr1)); }
public TestDocument() { TestList = new DocList <IDocLeaf>(); TestList.Add(new DocObj <int>(0)); TestList.Add(new DocObj <int>(1)); TestList.Add(new DocObj <int>(2)); TestBool = new DocObj <bool>(true); SubDoc = new TestSubDoc(); TestRef = new DocObj <int>(); }
static void TestDocListHooks() { DocList <IDocLeaf> list = new DocList <IDocLeaf>(); list.Hook += TestDocListHook; DocObj <string> obj0 = new DocObj <string>("Hello World"); DocObj <string> obj1 = new DocObj <string>("Hello World"); list.Add(obj0); list.Remove(obj0); list.Add(obj0); list.Add(obj1); list.Clear(); list.Clear(); }
static void TestDocListCollectionChanged() { DocList <IDocLeaf> list = new DocList <IDocLeaf>(); list.CollectionChanged += TestDocListOnCollectionChanged; ((INotifyPropertyChanged)list).PropertyChanged += TestDocListOnCollectionChanged2; DocObj <string> obj0 = new DocObj <string>("Hello World"); DocObj <string> obj1 = new DocObj <string>("Hello World"); list.Add(obj0); list.Remove(obj0); list.Add(obj0); list.Add(obj1); list.Clear(); list.Clear(); }
static void TestHistoryTransactions() { DocList <IDocLeaf> testDoc = new DocList <IDocLeaf>(); History.Instance.Root = testDoc; UnitTest.Test(History.Instance.HasUndo == false); UnitTest.Test(History.Instance.HasRedo == false); History.Instance.ExecuteInTransaction( delegate() { DocObj <int> testInt0 = new DocObj <int>(0); testDoc.Add(testInt0); UnitTest.Test(History.Instance.HasUndo == false); UnitTest.Test(History.Instance.HasRedo == false); DocObj <int> testInt1 = new DocObj <int>(1); testDoc.Add(testInt1); UnitTest.Test(History.Instance.HasUndo == false); UnitTest.Test(History.Instance.HasRedo == false); }, 0, "TestHistoryTransactions"); UnitTest.Test(testDoc.Count == 2); UnitTest.Test(History.Instance.HasUndo == true); UnitTest.Test(History.Instance.HasRedo == false); History.Instance.Undo(); UnitTest.Test(testDoc.Count == 0); UnitTest.Test(History.Instance.HasUndo == false); UnitTest.Test(History.Instance.HasRedo == true); History.Instance.Redo(); UnitTest.Test(testDoc.Count == 2); UnitTest.Test(History.Instance.HasUndo == true); UnitTest.Test(History.Instance.HasRedo == false); }
public TestSubDoc() { TestInt0 = new DocObj <int>(2); TestInt1 = new DocObj <int>(4); }