Esempio n. 1
0
        public void SetActiveSection(ISectionController section)
        {
            if (section == null)
            {
                throw new ArgumentNullException(nameof(section));
            }

            Debug.Assert(this.ActiveSection == null, "Already attached. Detach first");
            this.ActiveSection = section;
            this.VisualStateManager.SyncCommandFromActiveSection();

            this.TransferState();

            if (this.resetBindingWhenAttaching)
            {
                this.resetBindingWhenAttaching = false;

                // The connect section activated after the solution is opened,
                // so reset the binding if applicable. No reason to abort since
                // this is the first time after the solution was opened so that
                // we switched to the connect section.
                this.ResetBinding(abortCurrentlyRunningWorklows: false, clearCurrentBinding: false);
            }

            this.OnActiveSectionChanged();
        }
Esempio n. 2
0
        public void VsSessionHost_SyncCommandFromActiveSectionDuringActiveSectionChanges()
        {
            // Arrange
            VsSessionHost      testSubject = this.CreateTestSubject(null);
            ISectionController section     = ConfigurableSectionController.CreateDefault();
            int syncCalled = 0;

            this.stateManager.SyncCommandFromActiveSectionAction = () => syncCalled++;

            // Case 1: SetActiveSection
            this.stateManager.ExpectActiveSection = true;

            // Act
            testSubject.SetActiveSection(section);

            // Assert
            syncCalled.Should().Be(1, "SyncCommandFromActiveSection wasn't called during section activation");

            // Case 2: ClearActiveSection section
            this.stateManager.ExpectActiveSection = false;

            // Act
            testSubject.ClearActiveSection();

            // Assert
            syncCalled.Should().Be(2, "SyncCommandFromActiveSection wasn't called during section deactivation");
        }
        public void SetActiveSection(ISectionController section)
        {
            section.Should().NotBeNull();

            this.ActiveSection = section;

            // Simulate product code
            this.VisualStateManager.SyncCommandFromActiveSection();
        }
        public void SetActiveSection(ISectionController section)
        {
            Assert.IsNotNull(section);

            this.ActiveSection = section;

            // Simulate product code
            this.VisualStateManager.SyncCommandFromActiveSection();
        }
        public void SetActiveSection(ISectionController section)
        {
            Assert.IsNotNull(section);

            this.ActiveSection = section;

            // Simulate product code
            this.VisualStateManager.SyncCommandFromActiveSection();
        }
Esempio n. 6
0
        private void SyncCommands()
        {
            ISectionController section = (ISectionController)this;

            if (section.ViewModel != null)
            {
                section.ViewModel.ConnectCommand     = this.ConnectCommand;
                section.ViewModel.BindCommand        = this.BindCommand;
                section.ViewModel.BrowseToUrlCommand = this.BrowseToUrlCommand;
            }
        }
        public void VsSessionHost_SetActiveSection_TransferState()
        {
            // Setup
            VsSessionHost      testSubject = this.CreateTestSubject(null);
            ISectionController section     = ConfigurableSectionController.CreateDefault();

            // Act
            testSubject.SetActiveSection(section);

            // Verify
            Assert.AreSame(stateManager.ManagedState, testSubject.ActiveSection.ViewModel.State);
        }
Esempio n. 8
0
        public void VsSessionHost_SetActiveSection_TransferState()
        {
            // Arrange
            VsSessionHost      testSubject = this.CreateTestSubject(null);
            ISectionController section     = ConfigurableSectionController.CreateDefault();

            // Act
            testSubject.SetActiveSection(section);

            // Assert
            testSubject.ActiveSection.ViewModel.State.Should().Be(stateManager.ManagedState);
        }
        public void ClearActiveSection()
        {
            if (this.ActiveSection == null) // Can be called multiple times
            {
                return;
            }

            this.ActiveSection.ViewModel.State = null;
            this.ActiveSection = null;
            this.VisualStateManager.SyncCommandFromActiveSection();

            this.OnActiveSectionChanged();
        }
        private static void VerifySectionCommands(ISectionController section, ServerViewModel serverVM)
        {
            AssertExpectedNumberOfCommands(serverVM.Commands, 3);
            VerifyServerViewModelCommand(serverVM, section.RefreshCommand, fixedContext: serverVM, hasIcon: true);
            VerifyServerViewModelCommand(serverVM, section.BrowseToUrlCommand, fixedContext: serverVM.ConnectionInformation.ServerUri.ToString(), hasIcon: true);
            VerifyServerViewModelCommand(serverVM, section.ToggleShowAllProjectsCommand, fixedContext: serverVM, hasIcon: false);

            foreach (ProjectViewModel project in serverVM.Projects)
            {
                AssertExpectedNumberOfCommands(project.Commands, 2);
                VerifyProjectViewModelCommand(project, section.BindCommand, fixedContext: project, hasIcon: true);
                VerifyProjectViewModelCommand(project, section.BrowseToProjectDashboardCommand, fixedContext: project, hasIcon: true);
            }
        }
Esempio n. 11
0
        public void VsSessionHost_ClearActiveSection_ClearState()
        {
            // Arrange
            VsSessionHost      testSubject = this.CreateTestSubject(null);
            ISectionController section     = ConfigurableSectionController.CreateDefault();

            testSubject.SetActiveSection(section);

            // Act
            testSubject.ClearActiveSection();

            // Assert
            testSubject.ActiveSection.Should().BeNull();
            section.ViewModel.State.Should().BeNull();
        }
Esempio n. 12
0
        public void VsSessionHost_SetActiveSection_ChangeHost()
        {
            // Arrange
            VsSessionHost      testSubject = this.CreateTestSubject(null);
            ISectionController section     = ConfigurableSectionController.CreateDefault();

            // Sanity
            this.stepRunner.CurrentHost.Should().BeNull();

            // Act
            testSubject.SetActiveSection(section);

            // Assert
            this.stepRunner.CurrentHost.Should().Be(section.ProgressHost);
        }
        public void VsSessionHost_ClearActiveSection_ClearState()
        {
            // Setup
            VsSessionHost      testSubject = this.CreateTestSubject(null);
            ISectionController section     = ConfigurableSectionController.CreateDefault();

            testSubject.SetActiveSection(section);

            // Act
            testSubject.ClearActiveSection();

            // Verify
            Assert.IsNull(testSubject.ActiveSection);
            Assert.IsNull(section.ViewModel.State);
        }
        public void VsSessionHost_SetActiveSection_ChangeHost()
        {
            // Setup
            VsSessionHost      testSubject = this.CreateTestSubject(null);
            ISectionController section     = ConfigurableSectionController.CreateDefault();

            // Sanity
            this.stepRunner.AssertNoCurrentHost();

            // Act
            testSubject.SetActiveSection(section);

            // Verify
            this.stepRunner.AssertCurrentHost(section.ProgressHost);
        }
Esempio n. 15
0
        private void CleanControllerCommands()
        {
            this.CommandTargets.Clear();

            this.ConnectCommand = null;
            this.RefreshCommand = null;
            this.BindCommand    = null;

            ISectionController section = (ISectionController)this;

            if (section.ViewModel != null)
            {
                section.ViewModel.ConnectCommand     = null;
                section.ViewModel.BindCommand        = null;
                section.ViewModel.BrowseToUrlCommand = null;
            }
        }
Esempio n. 16
0
        public void VsSessionHost_ActiveSectionChangedEvent()
        {
            // Arrange
            VsSessionHost      testSubject  = this.CreateTestSubject(null);
            ISectionController section      = ConfigurableSectionController.CreateDefault();
            ISectionController otherSection = ConfigurableSectionController.CreateDefault();
            int changed = 0;

            testSubject.ActiveSectionChanged += (o, e) => changed++;

            // Act (1st set)
            testSubject.SetActiveSection(section);

            // Assert
            changed.Should().Be(1, "ActiveSectionChanged event was expected to fire");

            // Act (clear)
            testSubject.ClearActiveSection();

            // Assert
            changed.Should().Be(2, "ActiveSectionChanged event was expected to fire");

            // Act (2nd set)
            testSubject.SetActiveSection(otherSection);

            // Assert
            changed.Should().Be(3, "ActiveSectionChanged event was expected to fire");

            // Act (clear)
            testSubject.ClearActiveSection();

            // Assert
            changed.Should().Be(4, "ActiveSectionChanged event was expected to fire");

            // Act (clear again)
            testSubject.ClearActiveSection();

            // Assert
            changed.Should().Be(4, "ActiveSectionChanged event was not expected to fire, since already cleared");
        }
        private static void VerifySectionCommands(ISectionController section, ServerViewModel serverVM)
        {
            AssertExpectedNumberOfCommands(serverVM.Commands, 4);
            VerifyServerViewModelCommand(serverVM, section.DisconnectCommand, fixedContext: serverVM, hasIcon: true);
            VerifyServerViewModelCommand(serverVM, section.RefreshCommand, fixedContext: serverVM, hasIcon: true);
            VerifyServerViewModelCommand(serverVM, section.BrowseToUrlCommand, fixedContext: serverVM.ConnectionInformation.ServerUri, hasIcon: true);
            VerifyServerViewModelCommand(serverVM, section.ToggleShowAllProjectsCommand, fixedContext: serverVM, hasIcon: false);

            foreach (ProjectViewModel project in serverVM.Projects)
            {
                AssertExpectedNumberOfCommands(project.Commands, 2);
                VerifyProjectViewModelCommand(project, section.BindCommand, fixedContext: project, hasIcon: true);
                VerifyProjectViewModelCommand(project, section.BrowseToProjectDashboardCommand, fixedContext: project, hasIcon: true);
            }
        }