Esempio n. 1
0
        public void Remove_ActiveDocumentViewInViewHostWithNoOtherDocumentViews_ActiveDocumentViewSetToNullAndActiveDocumentViewEventsFired()
        {
            // Setup
            var testView1 = new TestView();
            var testView2 = new TestView();
            var activeDocumentViewChangingCounter = 0;
            var activeDocumentViewChangedCounter  = 0;
            var activeViewChangedCounter          = 0;

            using (var avalonDockViewHost = new AvalonDockViewHost())
            {
                avalonDockViewHost.AddDocumentView(testView1, string.Empty, string.Empty, null);
                avalonDockViewHost.AddToolView(testView2, ToolViewLocation.Left, string.Empty, string.Empty, null);
                SetActiveView(avalonDockViewHost, testView1);

                avalonDockViewHost.ActiveDocumentViewChanging += (sender, args) => activeDocumentViewChangingCounter++;
                avalonDockViewHost.ActiveDocumentViewChanged  += (sender, args) => activeDocumentViewChangedCounter++;
                avalonDockViewHost.ActiveViewChanged          += (sender, args) => activeViewChangedCounter++;

                // Call
                avalonDockViewHost.Remove(testView1);

                // Assert
                Assert.AreEqual(1, activeDocumentViewChangingCounter);
                Assert.AreEqual(1, activeDocumentViewChangedCounter);
                Assert.AreEqual(0, activeViewChangedCounter);
                Assert.IsNull(avalonDockViewHost.ActiveDocumentView);
            }
        }
Esempio n. 2
0
        public void Remove_ToolViewInViewHostWithMultipleViews_ViewRemoved()
        {
            // Setup
            var testView1 = new TestView();
            var testView2 = new TestView();

            using (var avalonDockViewHost = new AvalonDockViewHost())
            {
                avalonDockViewHost.AddToolView(testView1, ToolViewLocation.Left, string.Empty, string.Empty, null);
                avalonDockViewHost.AddToolView(testView2, ToolViewLocation.Left, string.Empty, string.Empty, null);

                // Precondition
                CollectionAssert.AreEqual(
                    new[]
                {
                    testView1,
                    testView2
                },
                    avalonDockViewHost.ToolViews);

                // Call
                avalonDockViewHost.Remove(testView1);

                // Assert
                CollectionAssert.AreEqual(
                    new[]
                {
                    testView2
                },
                    avalonDockViewHost.ToolViews);
            }
        }
Esempio n. 3
0
        public void Remove_DocumentViewInViewHostWithMultipleViews_ViewRemoved()
        {
            // Setup
            var testView1 = new TestView();
            var testView2 = new TestView();

            using (var avalonDockViewHost = new AvalonDockViewHost())
            {
                avalonDockViewHost.AddDocumentView(testView1, string.Empty, string.Empty, null);
                avalonDockViewHost.AddDocumentView(testView2, string.Empty, string.Empty, null);

                // Precondition
                CollectionAssert.AreEqual(
                    new[]
                {
                    testView1,
                    testView2
                },
                    avalonDockViewHost.DocumentViews);
                Assert.IsTrue(IsDocumentViewPresent(avalonDockViewHost, testView1));

                // Call
                avalonDockViewHost.Remove(testView1);

                // Assert
                CollectionAssert.AreEqual(
                    new[]
                {
                    testView2
                },
                    avalonDockViewHost.DocumentViews);
                Assert.IsFalse(IsDocumentViewPresent(avalonDockViewHost, testView1));
            }
        }
Esempio n. 4
0
        public void Remove_ToolViewInViewHostWithMultipleOtherViews_ActiveDocumentViewNotAffectedAndNoActiveViewEventsFired()
        {
            // Setup
            var testView1 = new TestView();
            var testView2 = new TestView();
            var testView3 = new TestView();
            var testView4 = new TestView();
            var testView5 = new TestView();
            var activeDocumentViewChangingCounter = 0;
            var activeDocumentViewChangedCounter  = 0;
            var activeViewChangedCounter          = 0;

            using (var avalonDockViewHost = new AvalonDockViewHost())
            {
                avalonDockViewHost.AddDocumentView(testView1, string.Empty, string.Empty, null);
                avalonDockViewHost.AddDocumentView(testView2, string.Empty, string.Empty, null);
                avalonDockViewHost.AddDocumentView(testView3, string.Empty, string.Empty, null);
                avalonDockViewHost.AddDocumentView(testView4, string.Empty, string.Empty, null);
                avalonDockViewHost.AddToolView(testView5, ToolViewLocation.Left, string.Empty, string.Empty, null);

                SetActiveView(avalonDockViewHost, testView3);
                SetActiveView(avalonDockViewHost, testView5);

                // Precondition
                Assert.AreSame(testView3, avalonDockViewHost.ActiveDocumentView);

                avalonDockViewHost.ActiveDocumentViewChanging += (sender, args) => activeDocumentViewChangingCounter++;
                avalonDockViewHost.ActiveDocumentViewChanged  += (sender, args) => activeDocumentViewChangedCounter++;
                avalonDockViewHost.ActiveViewChanged          += (sender, args) => activeViewChangedCounter++;

                // Call
                avalonDockViewHost.Remove(testView5);

                // Assert
                Assert.AreEqual(0, activeDocumentViewChangingCounter);
                Assert.AreEqual(0, activeDocumentViewChangedCounter);
                Assert.AreEqual(0, activeViewChangedCounter);
                Assert.AreSame(testView3, avalonDockViewHost.ActiveDocumentView);
            }
        }
Esempio n. 5
0
        public void Remove_ToolView_ViewClosedEventsFired()
        {
            // Setup
            var testView          = new TestView();
            var viewClosedCounter = 0;

            using (var avalonDockViewHost = new AvalonDockViewHost())
            {
                avalonDockViewHost.AddToolView(testView, ToolViewLocation.Left, string.Empty, string.Empty, null);

                avalonDockViewHost.ViewClosed += (sender, args) =>
                {
                    Assert.AreSame(testView, args.View);

                    viewClosedCounter++;
                };

                // Call
                avalonDockViewHost.Remove(testView);

                // Assert
                Assert.AreEqual(1, viewClosedCounter);
            }
        }