public ProjectRuleSetConflict AddConflict()
        {
            ProjectRuleSetConflict conflict = CreateConflict();

            this.AddConflict(conflict);
            return(conflict);
        }
        public static ProjectRuleSetConflict CreateConflict(string projectFilePath = "project.csproj", string baselineRuleSet = "baseline.ruleset", string projectRuleSet = "project.csproj", int numberOfConflictingRules = 1)
        {
            IEnumerable <string> ids = Enumerable.Range(0, numberOfConflictingRules).Select(i => "id" + i);
            var ruleSet = TestRuleSetHelper.CreateTestRuleSetWithRuleIds(ids);

            var conflict = new ProjectRuleSetConflict(
                new RuleConflictInfo(ruleSet.Rules, new Dictionary <RuleReference, RuleAction>()),
                new RuleSetInformation(projectFilePath, baselineRuleSet, projectRuleSet, null));

            return(conflict);
        }
        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 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 AddConflict(ProjectRuleSetConflict conflict)
 {
     this.currentConflicts.Add(conflict);
 }