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_FixConflictsCommandExecution() { // Setup var testSubject = new RuleSetConflictsController(this.host); this.ConfigureServiceProviderForFixConflictsCommandExecution(); this.host.VisualStateManager.IsBusy = false; this.host.VisualStateManager.SetBoundProject(new Integration.Service.ProjectInformation()); 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); // Verify this.sccFS.AssertFileExists(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); }