public void VsSessionHost_SetActiveSection() { // Arrange VsSessionHost testSubject = this.CreateTestSubject(null); // Case 1: Invalid args Exceptions.Expect <ArgumentNullException>(() => testSubject.SetActiveSection(null)); // Case 2: Valid args var section1 = ConfigurableSectionController.CreateDefault(); var section2 = ConfigurableSectionController.CreateDefault(); bool refresh1Called = false; section1.RefreshCommand = new RelayCommand(() => refresh1Called = true); bool refresh2Called = false; section2.RefreshCommand = new RelayCommand(() => refresh2Called = true); // Act (set section1) testSubject.SetActiveSection(section1); refresh1Called.Should().BeFalse(); refresh2Called.Should().BeFalse(); // Assert testSubject.ActiveSection.Should().Be(section1); // Act (set section2) testSubject.ClearActiveSection(); testSubject.SetActiveSection(section2); // Assert testSubject.ActiveSection.Should().Be(section2); refresh1Called.Should().BeFalse(); refresh2Called.Should().BeFalse(); }
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 VsSessionHost_SetActiveSection() { // Setup VsSessionHost testSubject = this.CreateTestSubject(null); // Case 1: Invalid args Exceptions.Expect <ArgumentNullException>(() => testSubject.SetActiveSection(null)); // Case 2: Valid args var section1 = ConfigurableSectionController.CreateDefault(); var section2 = ConfigurableSectionController.CreateDefault(); bool refresh1Called = false; section1.RefreshCommand = new RelayCommand(() => refresh1Called = true); bool refresh2Called = false; section2.RefreshCommand = new RelayCommand(() => refresh2Called = true); // Act (set section1) testSubject.SetActiveSection(section1); Assert.IsFalse(refresh1Called, "Refresh should only be called when bound project was found"); Assert.IsFalse(refresh2Called, "Refresh should only be called when bound project was found"); // Verify Assert.AreSame(section1, testSubject.ActiveSection); // Act (set section2) testSubject.ClearActiveSection(); testSubject.SetActiveSection(section2); // Verify Assert.AreSame(section2, testSubject.ActiveSection); Assert.IsFalse(refresh1Called, "Refresh should only be called when bound project was found"); Assert.IsFalse(refresh2Called, "Refresh should only be called when bound project was found"); }
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"); }
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(); }
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); }