public void CloseNonExistControlThrows()
        {
            TestableRootWorkItem workItem  = new TestableRootWorkItem();
            WindowWorkspace      workspace = workItem.Workspaces.AddNew <WindowWorkspace>();
            MockWPFSmartPart     smartPart = workItem.SmartParts.AddNew <MockWPFSmartPart>();

            workspace.Close(smartPart);
        }
예제 #2
0
        //[ExpectedException(typeof(ArgumentException))]
        public void CloseNonExistControlThrows()
        {
            TestableRootWorkItem workItem  = new TestableRootWorkItem();
            WindowWorkspace      workspace = workItem.Workspaces.AddNew <WindowWorkspace>();
            MockSmartPart        smartPart = workItem.SmartParts.AddNew <MockSmartPart>();

            //workspace.Close(smartPart);
            Assert.That(() => workspace.Close(smartPart),
                        Throws.TypeOf <ArgumentException>());
        }
        public void CloseSmartPartDoesNotDisposeIt()
        {
            TestableRootWorkItem workItem  = new TestableRootWorkItem();
            WindowWorkspace      workspace = workItem.Workspaces.AddNew <WindowWorkspace>();
            MockWPFSmartPart     smartPart = workItem.SmartParts.AddNew <MockWPFSmartPart>();

            workspace.Show(smartPart);
            workspace.Close(smartPart);

            Assert.IsFalse(smartPart.IsDisposed);
        }
        public void CloseRemovesWindow()
        {
            TestableRootWorkItem workItem  = new TestableRootWorkItem();
            WindowWorkspace      workspace = workItem.Workspaces.AddNew <WindowWorkspace>();
            MockWPFSmartPart     smartPart = workItem.SmartParts.AddNew <MockWPFSmartPart>();

            workspace.Show(smartPart);
            workspace.Close(smartPart);

            Assert.IsFalse(workspace.Windows.ContainsKey(smartPart.ElementHost));
        }
        public void CloseRemovesEntriesInWindowsAndSmartParts()
        {
            TestableRootWorkItem workItem  = new TestableRootWorkItem();
            WindowWorkspace      workspace = workItem.Workspaces.AddNew <WindowWorkspace>();
            MockWPFSmartPart     smartPart = workItem.SmartParts.AddNew <MockWPFSmartPart>();

            workspace.Show(smartPart);

            workspace.Close(smartPart);

            Assert.AreEqual(0, workspace.Windows.Count);
        }
        public void CanCancelSmartPartClosing()
        {
            TestableRootWorkItem workItem  = new TestableRootWorkItem();
            WindowWorkspace      workspace = workItem.Workspaces.AddNew <WindowWorkspace>();
            MockWPFSmartPart     smartPart = workItem.SmartParts.AddNew <MockWPFSmartPart>();

            workspace.Show(smartPart);
            workspace.SmartPartClosing += delegate(object sender, WorkspaceCancelEventArgs args) { args.Cancel = true; };

            workspace.Close(smartPart);

            Assert.IsFalse(smartPart.IsDisposed, "Smart Part Was Disposed");
        }
        public void WorkspaceFiresSmartPartClosing()
        {
            TestableRootWorkItem workItem  = new TestableRootWorkItem();
            WindowWorkspace      workspace = workItem.Workspaces.AddNew <WindowWorkspace>();
            MockWPFSmartPart     smartPart = workItem.SmartParts.AddNew <MockWPFSmartPart>();

            bool closing = false;

            workspace.Show(smartPart);
            workspace.SmartPartClosing += delegate { closing = true; };

            workspace.Close(smartPart);

            Assert.IsTrue(closing);
        }
        public void CloseDisposesAndClosesWindow()
        {
            TestableRootWorkItem workItem  = new TestableRootWorkItem();
            WindowWorkspace      workspace = workItem.Workspaces.AddNew <WindowWorkspace>();
            MockWPFSmartPart     smartPart = workItem.SmartParts.AddNew <MockWPFSmartPart>();

            workspace.Show(smartPart);

            Form form = workspace.Windows[smartPart.ElementHost];

            workspace.Close(smartPart);

            Assert.IsTrue(form.IsDisposed, "Form not disposed");
            Assert.IsFalse(form.Visible, "Form is visible");
            Assert.IsFalse(smartPart.IsDisposed);
        }