Example #1
0
        public void EnumerateProjectProperties_WithConfiguration_MultipleMatches()
        {
            // Arrange
            var project = new ProjectMock("projectfile.proj");

            project.Properties.RegisterKnownProperty("no match1").Value = "value1";
            project.Properties.RegisterKnownProperty("no match2").Value = "value2";

            // Expected results
            CreatePropertyForConfiguration(project, "config1", "prop1", "config1 prop1");
            CreatePropertyForConfiguration(project, "config2", "prop1", "config2 prop1");
            CreatePropertyForConfiguration(project, "config4", "prop1", "config4 prop1");

            // Additional non-matching properties
            CreatePropertyForConfiguration(project, "config1", "prop2", "config1 prop2");
            CreatePropertyForConfiguration(project, "config2", "propXXX", "config2 propXXX");
            CreatePropertyForConfiguration(project, "config3", "prop1aa", "config3 prop1aa");

            // Act
            var result = VsShellUtils.GetProjectProperties(project, "prop1");

            // Assert
            result.Should().NotBeNull();
            result.Count().Should().Be(3);
            result.Select(p => p.Value).Should().BeEquivalentTo(
                new string[] { "config1 prop1", "config2 prop1", "config4 prop1" });
        }
        public void EnumerateProjectProperties_NullConfigManager_ReturnsNull()
        {
            // Arrange
            var project = new ProjectMock("projectfile.proj");

            project.ConfigurationManager = null;

            // Act
            var result = VsShellUtils.GetProjectProperties(project, "anyproperty");

            // Assert
            result.Should().NotBeNull();
            result.Count().Should().Be(0);
        }
        public void EnumerateProjectProperties_SingleMatchingProperty_NoConfiguration()
        {
            // Arrange
            var project = new ProjectMock("projectfile.proj");

            project.ConfigurationManager = null;
            project.Properties.RegisterKnownProperty("AAA").Value = "aaa value";
            project.Properties.RegisterKnownProperty("BBB").Value = "bbb value";
            project.Properties.RegisterKnownProperty("CCC").Value = "ccc value";

            // Act
            var result = VsShellUtils.GetProjectProperties(project, "BBB");

            // Assert
            result.Should().NotBeNull();
            result.Count().Should().Be(1);
            result.First().Value.Should().Be("bbb value");
        }