public void BuildWorkspaceAndGetRootNode() { Store store = new Store("xmlfs"); Workspace workspace = new Workspace(store, "ws"); Assert.IsNotNull(workspace.RootNode); Assert.AreEqual("Root", workspace.RootNode.Properties["Name"].Value); }
public void GetChildNames() { Store store = new Store("xmlfs"); var names = store.GetChildNames("/father"); Assert.IsNotNull(names); Assert.AreEqual(3, names.Count()); Assert.IsTrue(names.Contains("child1")); Assert.IsTrue(names.Contains("child2")); Assert.IsTrue(names.Contains("child3")); }
public void GetRemoveExistingNode() { Store store = new Store("xmlfs2"); Assert.IsTrue(Directory.Exists("xmlfs2/father")); Assert.IsTrue(File.Exists("xmlfs2/father.xml")); store.RemoveNode("/father"); Assert.IsFalse(Directory.Exists("xmlfs2/father")); Assert.IsFalse(File.Exists("xmlfs2/father.xml")); }
public void CreateNodesAndSubnodes() { Store store = new Store("xmlfs5"); Workspace workspace = new Workspace(store, "ws"); Session session = new Session(workspace); INode root = session.Workspace.RootNode; using (var tr = session.OpenTransaction()) { for (int k = 1; k <= 10; k++) { INode node = session.CreateNode(root, "node" + k, new Property[] { new Property("Value", k) }); for (int j = 1; j <= 10; j++) session.CreateNode(node, "subnode" + j, new Property[] { new Property("ParentValue", k), new Property("Value", j) }); } tr.Complete(); } for (int k = 1; k <= 10; k++) { Assert.IsTrue(File.Exists("xmlfs5/node" + k + ".xml")); Assert.AreEqual(k, store.LoadProperties("/node" + k)["Value"].Value); for (int j = 1; j <= 10; j++) { Assert.IsTrue(File.Exists("xmlfs5/node" + k + "/subnode" + j + ".xml")); var properties = store.LoadProperties("/node" + k + "/subnode" + j); Assert.AreEqual(k, properties["ParentValue"].Value); Assert.AreEqual(j, properties["Value"].Value); } } }
public void BuildWorkspaceAndGetFatherAndChildren() { Store store = new Store("xmlfs"); Workspace workspace = new Workspace(store, "ws"); var father = workspace.RootNode.ChildNodes["father"]; Assert.IsNotNull(father); Assert.AreEqual("Father", father.Properties["Name"].Value); Assert.AreEqual(600, father.Properties["Age"].Value); Guid guid = new Guid("{42DB2811-074C-4b63-A242-ED827844FCAA}"); Assert.AreEqual(guid, father.Id); var child1 = father.ChildNodes["child1"]; var child2 = father.ChildNodes["child2"]; var child3 = father.ChildNodes["child3"]; Assert.IsNotNull(child1); Assert.IsNotNull(child2); Assert.IsNotNull(child3); }
public void CreateNodes() { Store store = new Store("xmlfs4"); Workspace workspace = new Workspace(store, "ws"); Session session = new Session(workspace); INode root = session.Workspace.RootNode; using (var tr = session.OpenTransaction()) { for (int k = 1; k <= 10; k++) session.CreateNode(root, "node" + k, new Property[] { new Property("Value", k) }); tr.Complete(); } for (int k = 1; k <= 10; k++) { Assert.IsTrue(File.Exists("xmlfs4/node" + k + ".xml")); Assert.AreEqual(k, store.LoadProperties("/node" + k)["Value"].Value); } }
public void SaveAndRetrievePropertiesWithId() { Guid guid = new Guid("{42DB2811-074C-4b63-A242-ED827844FCAA}"); PropertyList properties = new PropertyList(new List<Property>() { new Property("_Id", guid), new Property("Name", "Eve"), new Property("Age", 600), new Property("Male", false), new Property("Hired", new DateTime(2000, 1, 1)), new Property("Height", (double) 10.2), new Property("Salary", (decimal) 200.50) }); Store store = new Store("xmlfs"); store.SaveProperties("/eve", properties); var props = store.LoadProperties("/eve"); Assert.AreEqual(7, props.Count()); Assert.AreEqual(guid, props["_Id"].Value); Assert.AreEqual("Eve", props["Name"].Value); Assert.AreEqual(600, props["Age"].Value); Assert.AreEqual(false, props["Male"].Value); Assert.AreEqual(new DateTime(2000, 1, 1), props["Hired"].Value); Assert.AreEqual((double)10.2, props["Height"].Value); Assert.AreEqual((decimal)200.50, props["Salary"].Value); }
public void GetRootProperties() { Store store = new Store("xmlfs"); var properties = store.LoadProperties("/"); Assert.IsNotNull(properties); Assert.IsNotNull(properties["Name"]); Assert.AreEqual("Root", properties["Name"].Value); }
public void SaveSimpleProperties() { PropertyList properties = new PropertyList(new List<Property>() { new Property("Name", "Adam"), new Property("Age", 800) }); Store store = new Store("xmlfs"); store.SaveProperties("/adam", properties); Assert.IsTrue(File.Exists("xmlfs/adam.xml")); }
public void SaveAndSimpleProperties() { PropertyList properties = new PropertyList(new List<Property>() { new Property("Name", "Abel"), new Property("Age", 400) }); Store store = new Store("xmlfs"); store.SaveProperties("/abel", properties); var props = store.LoadProperties("/abel"); Assert.AreEqual(2, props.Count()); Assert.AreEqual("Abel", props["Name"].Value); Assert.AreEqual(400, props["Age"].Value); }
public void SaveAndRetrievePropertiesWithSimpleTypes() { PropertyList properties = new PropertyList(new List<Property>() { new Property("Name", "Eve"), new Property("Age", 600), new Property("Male", false), new Property("Hired", new DateTime(2000, 1, 1)), new Property("Height", (double) 10.2), new Property("Salary", (decimal) 200.50) }); Store store = new Store("xmlfs"); store.SaveProperties("/eve", properties); var props = store.LoadProperties("/eve"); Assert.AreEqual(6, props.Count()); Assert.AreEqual("Eve", props["Name"].Value); Assert.AreEqual(600, props["Age"].Value); Assert.AreEqual(false, props["Male"].Value); Assert.AreEqual(new DateTime(2000, 1, 1), props["Hired"].Value); Assert.AreEqual((double)10.2, props["Height"].Value); Assert.AreEqual((decimal)200.50, props["Salary"].Value); }
public void CreateNodesAndSubnodesRemoveNodes() { Store store = new Store("xmlfs6"); Workspace workspace = new Workspace(store, "ws"); Session session = new Session(workspace); INode root = session.Workspace.RootNode; using (var tr = session.OpenTransaction()) { for (int k = 1; k <= 10; k++) { INode node = session.CreateNode(root, "node" + k, new Property[] { new Property("Value", k) }); for (int j = 1; j <= 10; j++) session.CreateNode(node, "subnode" + j, new Property[] { new Property("ParentValue", k), new Property("Value", j) }); } tr.Complete(); } using (var tr = session.OpenTransaction()) { for (int k = 1; k <= 10; k++) session.RemoveNode(root.ChildNodes["node" + k]); tr.Complete(); } for (int k = 1; k <= 10; k++) Assert.IsFalse(File.Exists("xmlfs6/node" + k + ".xml")); }
public void SetPropertyValueAndRollback() { Store store = new Store("xmlfs2"); Workspace workspace = new Workspace(store, "ws"); Session session = new Session(workspace); INode node = session.Workspace.RootNode; using (var tr = session.OpenTransaction()) { node["Name"] = "Adam"; Assert.AreEqual("Adam", node["Name"]); } PropertyList properties = store.LoadProperties("/"); Assert.AreEqual("Root", properties["Name"].Value); }
public void RemoveExistingNode() { Store store = new Store("xmlfs3"); Workspace workspace = new Workspace(store, "ws"); Session session = new Session(workspace); INode node = session.Workspace.RootNode; Assert.IsTrue(Directory.Exists("xmlfs3/father")); Assert.IsTrue(File.Exists("xmlfs3/father.xml")); using (var tr = session.OpenTransaction()) { session.RemoveNode(node.ChildNodes["father"]); tr.Complete(); } Assert.IsFalse(Directory.Exists("xmlfs3/father")); Assert.IsFalse(File.Exists("xmlfs3/father.xml")); }