Skip to content

Commit cdaf78d

Browse files
committed
Fix unit test.
By default, properties are visible, so the `Visible` attribute would not be specified. Therefore, if we cannot parse it, it means it's visible and we should check for the `Category` attribute. Ignore launch profile property pages, as they don't use categories.
1 parent 56654ae commit cdaf78d

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

tests/Microsoft.VisualStudio.ProjectSystem.Managed.UnitTests/ProjectSystem/Rules/ProjectPropertiesRuleTests.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ public sealed class ProjectPropertiesLocalizationRuleTests : XamlRuleTestBase
1111
[MemberData(nameof(GetPropertyPagesRules))]
1212
public void CategoriesShouldBeDefinedOnFile(string ruleName, string fullPath)
1313
{
14+
// These are launch profile files and don't use categories, so let's skip them.
15+
if (ruleName.Contains("ExecutableDebugPropertyPage") || ruleName.Contains("ProjectDebugPropertyPage"))
16+
return;
17+
1418
XElement rule = LoadXamlRule(fullPath, out var namespaceManager);
1519
var categories = new HashSet<string>();
1620
AddCategories();
17-
18-
var propertyElements = rule.XPathSelectElements(@"/msb:Rule", namespaceManager).Elements();
1921

2022
// If the page is an extension, we have to check the base page for categories.
2123
if (ruleName.Contains(".CSharp"))
@@ -27,14 +29,15 @@ public void CategoriesShouldBeDefinedOnFile(string ruleName, string fullPath)
2729
else if (ruleName.Contains(".FSharp"))
2830
AddCategories(".FSharp");
2931

32+
var propertyElements = rule.XPathSelectElements(@"/msb:Rule", namespaceManager).Elements();
3033
foreach (XElement element in propertyElements)
3134
{
3235
// Skip these xml elements.
3336
if (element.Name.LocalName is "Rule.Categories" or "Rule.DataSource" or "Rule.Metadata")
3437
continue;
3538

3639
// Skip if the property is not visible.
37-
if (!bool.TryParse(element.Attribute("Visible")?.Value, out bool isVisible) || !isVisible)
40+
if (bool.TryParse(element.Attribute("Visible")?.Value, out bool isVisible) && !isVisible)
3841
continue;
3942

4043
var categoryAttribute = element.Attribute("Category");

0 commit comments

Comments
 (0)