Exemplo n.º 1
0
        [Test] public void GetResourceWorkspaces()
        {
            IResource folder    = _storage.NewResource("Folder");
            IResource workspace = _workspaceManager.CreateWorkspace("Test");

            _workspaceManager.AddResourceToWorkspace(workspace, folder);

            IResourceList workspaces = _workspaceManager.GetResourceWorkspaces(folder);

            Assert.AreEqual(1, workspaces.Count);
            Assert.AreEqual(workspace, workspaces [0]);

            IResource person = _storage.NewResource("Person");

            person.AddLink(_propAuthor, folder);

            workspaces = _workspaceManager.GetResourceWorkspaces(person);
            Assert.AreEqual(1, workspaces.Count);
            Assert.AreEqual(workspace, workspaces [0]);

            IResource folder2 = _storage.NewResource("Folder");

            _workspaceManager.AddResourceToWorkspaceRecursive(workspace, folder2);
            IResource childFolder = _storage.NewResource("Folder");

            childFolder.AddLink("Parent", folder2);

            workspaces = _workspaceManager.GetResourceWorkspaces(childFolder);
            Assert.AreEqual(1, workspaces.Count);

            IResource person2 = _storage.NewResource("Person");

            person2.AddLink(_propAuthor, childFolder);

            workspaces = _workspaceManager.GetResourceWorkspaces(person2);
            Assert.AreEqual(1, workspaces.Count);
            Assert.AreEqual(workspace, workspaces [0]);

            _workspaceManager.RemoveResourceFromWorkspace(workspace, childFolder);

            workspaces = _workspaceManager.GetResourceWorkspaces(person2);
            Assert.AreEqual(0, workspaces.Count);

            _workspaceManager.AddResourceToWorkspace(workspace, childFolder);

            workspaces = _workspaceManager.GetResourceWorkspaces(person2);
            Assert.AreEqual(1, workspaces.Count);

            _workspaceManager.RemoveResourceFromWorkspace(workspace, folder2);

            workspaces = _workspaceManager.GetResourceWorkspaces(person2);
            Assert.AreEqual(0, workspaces.Count);
        }
Exemplo n.º 2
0
        [Test] public void LoadWorkspaceData()
        {
            IResource folder    = _storage.NewResource("Folder");
            IResource workspace = _workspaceManager.CreateWorkspace("Test");

            _workspaceManager.AddResourceToWorkspace(workspace, folder);

            IResource person = _storage.NewResource("Person");

            person.AddLink(_propAuthor, folder);

            _storage.Close();
            _storage = new TestResourceStore(true);

            _workspaceManager = new WorkspaceManager(_storage, new ResourceTreeManager(_storage),
                                                     _core.PluginLoader);

            IResourceList workspaces = _workspaceManager.GetResourceWorkspaces(person);

            Assert.AreEqual(1, workspaces.Count);
            Assert.AreEqual("Test", workspaces [0].DisplayName);
        }