Example #1
0
        public void DisposedTest()
        {
            _manager.Dispose();

            // Can no longer call public methods.
            AssertHelper.ThrowsException <ObjectDisposedException>(_manager.Close);
            AssertHelper.ThrowsException <ObjectDisposedException>(() => _manager.Merge(new TestWorkspace(), new TestWorkspace()));
            AssertHelper.ThrowsException <ObjectDisposedException>(() => _manager.SwitchToWorkspace(new TestWorkspace()));
            AssertHelper.ThrowsException <ObjectDisposedException>(() => _manager.CreateEmptyWorkspace());
            AssertHelper.ThrowsException <ObjectDisposedException>(() => _manager.CreateWorkspaceFromSession(new TestSession()));
        }
Example #2
0
        public void MergeTest()
        {
            // ReSharper disable AccessToModifiedClosure

            // Normal merge. The origin workspace is removed.
            TestWorkspace from   = _manager.CreateEmptyWorkspace();
            TestWorkspace target = _manager.CreateEmptyWorkspace();

            _manager.Merge(from, target);
            Assert.IsFalse(_manager.Workspaces.Contains(from));
            Assert.IsTrue(_manager.Workspaces.Contains(target));

            // Merge with itself, nothing should happen.
            _manager.Merge(target, target);

            // Attempting to merge workspaces not managed by this manager.
            AssertHelper.ThrowsException <ArgumentException>(() => _manager.Merge(new TestWorkspace(), target));
            AssertHelper.ThrowsException <ArgumentException>(() => _manager.Merge(null, target));
            AssertHelper.ThrowsException <ArgumentException>(() => _manager.Merge(target, new TestWorkspace()));
            AssertHelper.ThrowsException <ArgumentException>(() => _manager.Merge(target, null));
            AssertHelper.ThrowsException <ArgumentException>(() => _manager.Merge(null, null));

            // Can't merge startup workspace
            _manager = new TestWorkspaceManager();             // Previous exception disposed the manager.
            target   = _manager.CreateEmptyWorkspace();
            AssertHelper.ThrowsException <ArgumentException>(() => _manager.Merge(_manager.StartupWorkspace, target));

            // Can't merge current desktop.
            _manager = new TestWorkspaceManager();             // Previous exception disposed the manager.
            TestWorkspace current = _manager.CreateEmptyWorkspace();

            target = _manager.CreateEmptyWorkspace();
            _manager.SwitchToWorkspace(current);
            AssertHelper.ThrowsException <ArgumentException>(() => _manager.Merge(current, target));

            // ReSharper restore AccessToModifiedClosure
        }