Command handler to toggle the <SonarQubeExclude/> project property.
Will toggle between removing the property, and setting it to 'true'.
Inheritance: VsCommandBase
        public void ProjectExcludePropertyToggleCommand_Invoke_SingleProject_TogglesValue()
        {
            // Setup
            OleMenuCommand command = CommandHelper.CreateRandomOleMenuCommand();
            command.Enabled = true;

            var testSubject = new ProjectExcludePropertyToggleCommand(serviceProvider);
            var project = new ProjectMock("projecty.csproj");
            project.SetCSProjectKind();
            this.projectSystem.SelectedProjects = new[] { project };

            // Test case 1: true --toggle--> clears property
            this.SetExcludeProperty(project, true);

            // Act
            testSubject.Invoke(command, null);

            // Verify
            this.VerifyExcludeProperty(project, null);

            // Test case 2: no property --toggle--> true
            this.SetExcludeProperty(project, null);

            // Act
            testSubject.Invoke(command, null);

            // Verify
            this.VerifyExcludeProperty(project, true);
        }
        public void ProjectExcludePropertyToggleCommand_Invoke_MultipleProjects_ConsistentPropValues_TogglesValues()
        {
            // Setup
            OleMenuCommand command = CommandHelper.CreateRandomOleMenuCommand();
            command.Enabled = true;

            var testSubject = new ProjectExcludePropertyToggleCommand(this.serviceProvider);

            var p1 = new ProjectMock("good1.proj");
            var p2 = new ProjectMock("good2.proj");
            p1.SetCSProjectKind();
            p2.SetCSProjectKind();
            this.projectSystem.SelectedProjects = new[] { p1, p2 };

            // Test case 1: all not set --toggle--> all true
            // Act
            testSubject.Invoke(command, null);

            // Verify
            this.VerifyExcludeProperty(p1, true);
            this.VerifyExcludeProperty(p2, true);

            // Test case 2: all true --toggle--> all not set
            // Setup
            this.SetExcludeProperty(p1, true);
            this.SetExcludeProperty(p2, true);

            // Act
            testSubject.Invoke(command, null);

            // Verify
            this.VerifyExcludeProperty(p1, null);
            this.VerifyExcludeProperty(p2, null);
        }
        public void ProjectExcludePropertyToggleCommand_QueryStatus_MultipleProjects_MixedSupportedProject_IsDisabledIsHidden()
        {
            // Setup
            OleMenuCommand command = CommandHelper.CreateRandomOleMenuCommand();

            var testSubject = new ProjectExcludePropertyToggleCommand(this.serviceProvider);

            var unsupportedProject = new ProjectMock("bad.proj");
            var supportedProject = new ProjectMock("good.proj");
            supportedProject.SetCSProjectKind();

            this.projectSystem.SelectedProjects = new[] { unsupportedProject, supportedProject };

            // Act
            testSubject.QueryStatus(command, null);

            // Verify
            Assert.IsFalse(command.Enabled, "Expected command to be disabled");
            Assert.IsFalse(command.Visible, "Expected command to be hidden");
        }
        public void ProjectExcludePropertyToggleCommand_QueryStatus_MultipleProjects_MixedPropValues_IsUnchecked()
        {
            // Setup
            OleMenuCommand command = CommandHelper.CreateRandomOleMenuCommand();

            var testSubject = new ProjectExcludePropertyToggleCommand(this.serviceProvider);

            var p1 = new ProjectMock("good1.proj");
            var p2 = new ProjectMock("good2.proj");
            var p3 = new ProjectMock("good3.proj");
            p1.SetCSProjectKind();
            p2.SetCSProjectKind();
            p3.SetCSProjectKind();
            this.projectSystem.SelectedProjects = new[] { p1, p2, p3 };

            this.SetExcludeProperty(p1, true);
            this.SetExcludeProperty(p2, null);
            this.SetExcludeProperty(p3, false);

            // Act
            testSubject.QueryStatus(command, null);

            // Verify
            Assert.IsFalse(command.Checked, "Expected command to be unchecked");
        }
        public void ProjectExcludePropertyToggleCommand_QueryStatus_MultipleProjects_AllSupportedProjects_IsEnabledIsVisible()
        {
            // Setup
            OleMenuCommand command = CommandHelper.CreateRandomOleMenuCommand();

            var testSubject = new ProjectExcludePropertyToggleCommand(this.serviceProvider);

            var p1 = new ProjectMock("good1.proj");
            var p2 = new ProjectMock("good2.proj");
            p1.SetCSProjectKind();
            p2.SetCSProjectKind();

            this.projectSystem.SelectedProjects = new [] { p1, p2 };

            // Act
            testSubject.QueryStatus(command, null);

            // Verify
            Assert.IsTrue(command.Enabled, "Expected command to be enabled");
            Assert.IsTrue(command.Visible, "Expected command to be visible");
        }
        public void ProjectExcludePropertyToggleCommand_QueryStatus_MultipleProjects_ConsistentPropValues_CheckedStateReflectsValues()
        {
            // Setup
            OleMenuCommand command = CommandHelper.CreateRandomOleMenuCommand();

            var testSubject = new ProjectExcludePropertyToggleCommand(this.serviceProvider);

            var p1 = new ProjectMock("good1.proj");
            var p2 = new ProjectMock("good2.proj");
            p1.SetCSProjectKind();
            p2.SetCSProjectKind();

            this.projectSystem.SelectedProjects = new[] { p1, p2 };

            // Test case 1: no property -> not checked
            // Act
            testSubject.QueryStatus(command, null);

            // Verify
            Assert.IsFalse(command.Checked, "Expected command to be unchecked");

            // Test case 2: all true -> is checked
            this.SetExcludeProperty(p1, true);
            this.SetExcludeProperty(p2, true);

            // Act
            testSubject.QueryStatus(command, null);

            // Verify
            Assert.IsTrue(command.Checked, "Expected command to be checked");
        }
        public void ProjectExcludePropertyToggleCommand_QueryStatus_SingleProject_CheckedStateReflectsValues()
        {
            // Setup
            OleMenuCommand command = CommandHelper.CreateRandomOleMenuCommand();

            var testSubject = new ProjectExcludePropertyToggleCommand(this.serviceProvider);

            var project = new ProjectMock("face.proj");
            project.SetCSProjectKind();

            this.projectSystem.SelectedProjects = new[] { project };

            // Test case 1: no property -> not checked
            // Act
            testSubject.QueryStatus(command, null);

            // Verify
            Assert.IsFalse(command.Checked, "Expected command to be unchecked");

            // Test case 1: true -> is checked
            this.SetExcludeProperty(project, true);

            // Act
            testSubject.QueryStatus(command, null);

            // Verify
            Assert.IsTrue(command.Checked, "Expected command to be checked");
        }
        public void ProjectExcludePropertyToggleCommand_QueryStatus_SingleProject_UnsupportedProject_IsDisabledIsHidden()
        {
            // Setup
            OleMenuCommand command = CommandHelper.CreateRandomOleMenuCommand();

            var testSubject = new ProjectExcludePropertyToggleCommand(serviceProvider);

            var project = new ProjectMock("mcproject.csproj");

            this.projectSystem.SelectedProjects = new[] { project };

            // Act
            testSubject.QueryStatus(command, null);

            // Verify
            Assert.IsFalse(command.Enabled, "Expected command to be disabled");
            Assert.IsFalse(command.Visible, "Expected command to be hidden");
        }
        public void ProjectExcludePropertyToggleCommand_QueryStatus_MissingPropertyManager_IsDisabledIsHidden()
        {
            // Setup
            OleMenuCommand command = CommandHelper.CreateRandomOleMenuCommand();

            var localProvider = new ConfigurableServiceProvider(assertOnUnexpectedServiceRequest: false);

            ProjectExcludePropertyToggleCommand testSubject;
            using (new AssertIgnoreScope()) // we want to be missing the MEF service
            {
                testSubject = new ProjectExcludePropertyToggleCommand(localProvider);
            }

            // Act
            testSubject.QueryStatus(command, null);

            // Verify
            Assert.IsFalse(command.Enabled, "Expected command to be disabled");
            Assert.IsFalse(command.Visible, "Expected command to be hidden");
        }
        public void ProjectExcludePropertyToggleCommand_Invoke_MultipleProjects_MixedPropValues_SetIsExcludedTrue()
        {
            // Setup
            OleMenuCommand command = CommandHelper.CreateRandomOleMenuCommand();
            command.Enabled = true;

            var testSubject = new ProjectExcludePropertyToggleCommand(this.serviceProvider);

            var p1 = new ProjectMock("trueProj.proj");
            var p2 = new ProjectMock("nullProj.proj");
            var p3 = new ProjectMock("trueProj.proj");
            p1.SetCSProjectKind();
            p2.SetCSProjectKind();
            p3.SetCSProjectKind();
            this.projectSystem.SelectedProjects = new[] { p1, p2, p3 };

            this.SetExcludeProperty(p1, true);
            this.SetExcludeProperty(p2, null);
            this.SetExcludeProperty(p3, false);

            // Act
            testSubject.Invoke(command, null);

            // Verify
            this.VerifyExcludeProperty(p1, true);
            this.VerifyExcludeProperty(p2, true);
            this.VerifyExcludeProperty(p3, true);
        }