public void CreateWorkspaceWithRootNode() { Workspace workspace = new Workspace("repository", (PropertyList) null); Assert.IsNotNull(workspace.RootNode); Assert.AreEqual("repository", workspace.Name); }
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 CreateRootNode() { Workspace workspace = new Workspace("ws2", new List<Property>() { new Property("Name", "Eve"), new Property("Age", 600) }); Assert.IsNull(workspace.RootNode.Parent); Assert.AreEqual(string.Empty, workspace.RootNode.Name); }
public void RegisterAndRetrieveWorkspace() { WorkspaceRegistry registry = new WorkspaceRegistry(); IWorkspace workspace = new Workspace("ws1", null); registry.RegisterWorkspace(workspace); Assert.IsNotNull(registry.Workspaces); Assert.AreEqual(1, registry.Workspaces.Count()); var ws = registry["ws1"]; Assert.IsNotNull(ws); Assert.AreEqual("ws1", ws.Name); Assert.AreEqual(workspace, ws); Assert.IsNull(registry["ws2"]); }
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 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")); }