private void VerifyCommandCheckedStatus(OleMenuCommand command, ProjectTestPropertySetCommand testSubject, bool?actualPropertyValue)
        {
            bool?testSubjectCmdValue   = testSubject.CommandPropertyValue;
            bool propertySameAsCommand = (testSubjectCmdValue == actualPropertyValue);

            if (propertySameAsCommand)
            {
                command.Checked.Should().BeTrue($"Expected command[{testSubjectCmdValue}] to be checked when property is '{actualPropertyValue}'");
            }
            else
            {
                command.Checked.Should().BeFalse($"Expected command[{testSubjectCmdValue}] to be unchecked when property is '{actualPropertyValue}'");
            }
        }
        public void ProjectTestPropertySetCommand_QueryStatus_SingleProject_UnsupportedProject_IsDisabledIsHidden()
        {
            // Arrange
            OleMenuCommand command = CommandHelper.CreateRandomOleMenuCommand();

            var testSubject = new ProjectTestPropertySetCommand(propertyManager, null);

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

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

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

            // Assert
            command.Enabled.Should().BeFalse("Expected command to be disabled");
            command.Visible.Should().BeFalse("Expected command to be hidden");
        }
示例#3
0
        public void ProjectTestPropertySetCommand_QueryStatus_SingleProject_UnsupportedProject_IsDisabledIsHidden()
        {
            // Setup
            OleMenuCommand command = CommandHelper.CreateRandomOleMenuCommand();

            var testSubject = new ProjectTestPropertySetCommand(serviceProvider, null);

            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");
        }
示例#4
0
        public void ProjectTestPropertySetCommand_QueryStatus_MissingPropertyManager_IsDisabledIsHidden()
        {
            // Arrange
            OleMenuCommand command = CommandHelper.CreateRandomOleMenuCommand();

            ProjectTestPropertySetCommand testSubject;

            using (new AssertIgnoreScope()) // we want to be missing the MEF service
            {
                testSubject = new ProjectTestPropertySetCommand(propertyManager, null);
            }

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

            // Assert
            command.Enabled.Should().BeFalse("Expected command to be disabled");
            command.Visible.Should().BeFalse("Expected command to be hidden");
        }
        public void ProjectTestPropertySetCommand_QueryStatus_SingleProject_SupportedProject_IsEnabledIsVisible()
        {
            // Arrange
            OleMenuCommand command = CommandHelper.CreateRandomOleMenuCommand();

            var testSubject = new ProjectTestPropertySetCommand(serviceProvider, null);

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

            project.SetCSProjectKind();

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

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

            // Assert
            command.Enabled.Should().BeTrue("Expected command to be enabled");
            command.Visible.Should().BeTrue("Expected command to be visible");
        }
        public void ProjectTestPropertySetCommand_QueryStatus_MultipleProjects_MixedSupportedProjects_IsDisabledIsHidden()
        {
            // Arrange
            OleMenuCommand command = CommandHelper.CreateRandomOleMenuCommand();

            var testSubject = new ProjectTestPropertySetCommand(this.propertyManager, null);

            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);

            // Assert
            command.Enabled.Should().BeFalse("Expected command to be disabled");
            command.Visible.Should().BeFalse("Expected command to be hidden");
        }
示例#7
0
        public void ProjectTestPropertySetCommand_QueryStatus_MultipleProjects_MixedSupportedProjects_IsDisabledIsHidden()
        {
            // Setup
            OleMenuCommand command = CommandHelper.CreateRandomOleMenuCommand();

            var testSubject = new ProjectTestPropertySetCommand(this.serviceProvider, null);

            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");
        }
示例#8
0
        public void ProjectTestPropertySetCommand_QueryStatus_MissingPropertyManager_IsDisabledIsHidden()
        {
            // Setup
            OleMenuCommand command = CommandHelper.CreateRandomOleMenuCommand();

            var localProvider = new ConfigurableServiceProvider(assertOnUnexpectedServiceRequest: false);

            ProjectTestPropertySetCommand testSubject;

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

            // 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 ProjectTestPropertySetCommand_Invoke_SingleProject_SetsValue()
        {
            // Arrange
            OleMenuCommand command = CommandHelper.CreateRandomOleMenuCommand();

            command.Enabled = true;

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

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

            // Test case 1: test (true)
            // Arrange
            var testSubject1 = new ProjectTestPropertySetCommand(propertyManager, true);

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

            // Assert
            this.VerifyTestProperty(project, true);

            // Test case 2: non-test (false)
            var testSubject2 = new ProjectTestPropertySetCommand(propertyManager, false);

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

            // Assert
            this.VerifyTestProperty(project, false);

            // Test case 3: auto detect (null)
            var testSubject3 = new ProjectTestPropertySetCommand(propertyManager, null);

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

            // Assert
            this.VerifyTestProperty(project, null);
        }
        public void ProjectTestPropertySetCommand_QueryStatus_MultipleProjects_AllSupportedProjects_IsEnabledIsVisible()
        {
            // Arrange
            OleMenuCommand command = CommandHelper.CreateRandomOleMenuCommand();

            var testSubject = new ProjectTestPropertySetCommand(this.propertyManager, null);

            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);

            // Assert
            command.Enabled.Should().BeTrue("Expected command to be enabled");
            command.Visible.Should().BeTrue("Expected command to be visible");
        }
示例#11
0
        public void ProjectTestPropertySetCommand_QueryStatus_MultipleProjects_AllSupportedProjects_IsEnabledIsVisible()
        {
            // Setup
            OleMenuCommand command = CommandHelper.CreateRandomOleMenuCommand();

            var testSubject = new ProjectTestPropertySetCommand(this.serviceProvider, null);

            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 ProjectTestPropertySetCommand_Invoke_MultipleProjects_MixedPropValues_SetsValues()
        {
            // Arrange
            OleMenuCommand command = CommandHelper.CreateRandomOleMenuCommand();

            command.Enabled = true;

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

            p1.SetCSProjectKind();
            p2.SetCSProjectKind();
            p3.SetCSProjectKind();
            this.projectSystem.SelectedProjects = new[] { p1, p2, p3 };

            // Test case 1: test (true)
            // Arrange
            var testSubject1 = new ProjectTestPropertySetCommand(propertyManager, true);

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

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

            // Assert
            this.VerifyTestProperty(p1, true);
            this.VerifyTestProperty(p2, true);
            this.VerifyTestProperty(p3, true);

            // Test case 2: non-test (false)
            var testSubject2 = new ProjectTestPropertySetCommand(propertyManager, false);

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

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

            // Assert
            this.VerifyTestProperty(p1, false);
            this.VerifyTestProperty(p2, false);
            this.VerifyTestProperty(p3, false);

            // Test case 3: auto detect (null)
            var testSubject3 = new ProjectTestPropertySetCommand(propertyManager, null);

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

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

            // Assert
            this.VerifyTestProperty(p1, null);
            this.VerifyTestProperty(p2, null);
            this.VerifyTestProperty(p3, null);
        }