public void RuleSetConflictsController_FixConflictsCommandExecution() { // Arrange var testSubject = new RuleSetConflictsController(this.host, this.conflictsManager); this.ConfigureServiceProviderForFixConflictsCommandExecution(); this.host.VisualStateManager.IsBusy = false; this.host.VisualStateManager.SetBoundProject(new Uri("http://foo"), null, "project123"); var section = ConfigurableSectionController.CreateDefault(); this.host.SetActiveSection(section); ConfigurableUserNotification notifications = (ConfigurableUserNotification)section.UserNotifications; ProjectRuleSetConflict[] conflicts = new[] { ConfigurableConflictsManager.CreateConflict() }; RuleSet fixedRuleSet = TestRuleSetHelper.CreateTestRuleSet(3); fixedRuleSet.FilePath = "MyFixedRules.ruleset"; RuleSetInspectorTestDataProvider inspectorData = new RuleSetInspectorTestDataProvider(); var weakenedRulesMap = new Dictionary <RuleReference, RuleAction>(); inspectorData.FindConflictsResult = new RuleConflictInfo(new RuleReference[0], weakenedRulesMap); inspectorData.FixConflictsResult = new FixedRuleSetInfo(fixedRuleSet, new[] { "reset.ruleset" }, new[] { "deletedRuleId1" }); this.ruleSetInspector.FindConflictingRulesAction = inspectorData.FindConflictingRulesAction; this.ruleSetInspector.FixConflictingRulesAction = inspectorData.FixConflictingRulesAction; ICommand fixMeCommand = testSubject.CreateFixConflictsCommand(conflicts); section.UserNotifications.ShowNotificationWarning("fix me", NotificationIds.RuleSetConflictsId, fixMeCommand); // Act fixMeCommand.Execute(null); // Assert this.sccFS.files.Should().ContainKey(fixedRuleSet.FilePath); this.rsSerializer.AssertRuleSetsAreSame(fixedRuleSet.FilePath, fixedRuleSet); this.outputWindowPane.AssertOutputStrings(1); this.outputWindowPane.AssertMessageContainsAllWordsCaseSensitive(0, words: new[] { fixedRuleSet.FilePath, "deletedRuleId1", "reset.ruleset" }, splitter: new[] { '\n', '\r', '\t', '\'', ':' }); notifications.AssertNoNotification(NotificationIds.RuleSetConflictsId); }
public void RuleSetConflictsController_CheckForConflicts() { // Setup var conflictsMananger = new ConfigurableConflictsManager(); this.serviceProvider.RegisterService(typeof(IConflictsManager), conflictsMananger); var testSubject = new RuleSetConflictsController(this.host); bool result; // Case 1: No conflicts // Act result = testSubject.CheckForConflicts(); // Verify Assert.IsFalse(result, "Not expecting any conflicts"); this.outputWindowPane.AssertOutputStrings(0); // Case 2: Has conflicts, no active section ProjectRuleSetConflict conflict = conflictsMananger.AddConflict(); // Act result = testSubject.CheckForConflicts(); // Verify Assert.IsTrue(result, "Conflicts expected"); this.outputWindowPane.AssertOutputStrings(1); this.outputWindowPane.AssertMessageContainsAllWordsCaseSensitive(0, new[] { conflict.Conflict.MissingRules.Single().FullId }); // Case 3: Has conflicts, has active section var section = ConfigurableSectionController.CreateDefault(); this.host.SetActiveSection(section); // Act result = testSubject.CheckForConflicts(); // Verify Assert.IsTrue(result, "Conflicts expected"); ((ConfigurableUserNotification)section.UserNotifications).AssertNotification(NotificationIds.RuleSetConflictsId); this.outputWindowPane.AssertOutputStrings(2); this.outputWindowPane.AssertMessageContainsAllWordsCaseSensitive(1, new[] { conflict.Conflict.MissingRules.Single().FullId }); }
public void ErrorListInfoBarController_InfoBar_ClickButton_HasActiveSection_NavigatesToSection() { // Arrange this.SetBindingMode(SonarLintMode.LegacyConnected); var testSubject = new ErrorListInfoBarController(this.host, this.unboundProjectFinder); this.ConfigureLoadedSolution(); this.host.SetActiveSection(ConfigurableSectionController.CreateDefault()); testSubject.Refresh(); RunAsyncAction(); // Sanity ConfigurableInfoBar infoBar = this.infoBarManager.AssertHasAttachedInfoBar(ErrorListInfoBarController.ErrorListToolWindowGuid); VerifyInfoBar(infoBar); // Act infoBar.SimulateButtonClickEvent(); // Assert this.teamExplorerController.ShowConnectionsPageCallsCount.Should().Be(1); }
public void RuleSetConflictsController_Clear() { // Arrange var testSubject = new RuleSetConflictsController(this.host, this.conflictsManager); // Case 1: No active section (should not crash) testSubject.Clear(); // Case 2: Has active section var section = ConfigurableSectionController.CreateDefault(); this.host.SetActiveSection(section); ConfigurableUserNotification notifications = (ConfigurableUserNotification)section.UserNotifications; section.UserNotifications.ShowNotificationWarning("message", NotificationIds.RuleSetConflictsId, null); // Act testSubject.Clear(); // Assert notifications.AssertNoNotification(NotificationIds.RuleSetConflictsId); }
public void RuleSetConflictsController_CheckForConflicts() { // Arrange var testSubject = new RuleSetConflictsController(this.host, this.conflictsManager); bool result; // Case 1: No conflicts // Act result = testSubject.CheckForConflicts(); // Assert result.Should().BeFalse("Not expecting any conflicts"); this.outputWindowPane.AssertOutputStrings(0); // Case 2: Has conflicts, no active section ProjectRuleSetConflict conflict = conflictsManager.AddConflict(); // Act result = testSubject.CheckForConflicts(); // Assert result.Should().BeTrue("Conflicts expected"); this.outputWindowPane.AssertOutputStrings(1); this.outputWindowPane.AssertMessageContainsAllWordsCaseSensitive(0, new[] { conflict.Conflict.MissingRules.Single().FullId }); // Case 3: Has conflicts, has active section var section = ConfigurableSectionController.CreateDefault(); this.host.SetActiveSection(section); // Act result = testSubject.CheckForConflicts(); // Assert result.Should().BeTrue("Conflicts expected"); ((ConfigurableUserNotification)section.UserNotifications).AssertNotification(NotificationIds.RuleSetConflictsId); this.outputWindowPane.AssertOutputStrings(2); this.outputWindowPane.AssertMessageContainsAllWordsCaseSensitive(1, new[] { conflict.Conflict.MissingRules.Single().FullId }); }
public void ErrorListInfoBarController_InfoBar_ClickButton_HasActiveSection_NavigatesToSection() { // Setup this.IsActiveSolutionBound = true; var testSubject = new ErrorListInfoBarController(this.host); this.ConfigureLoadedSolution(); this.host.SetActiveSection(ConfigurableSectionController.CreateDefault()); testSubject.Refresh(); RunAsyncAction(); // Sanity ConfigurableInfoBar infoBar = this.infoBarManager.AssertHasAttachedInfoBar(ErrorListInfoBarController.ErrorListToolWindowGuid); VerifyInfoBar(infoBar); // Act infoBar.SimulateButtonClickEvent(); // Verify this.teamExplorerController.AssertExpectedNumCallsShowConnectionsPage(1); }