Skip to content

Commit

Permalink
File scoped namespaces (#1700)
Browse files Browse the repository at this point in the history
<!--- Provide a general summary of your changes in the Title above -->

## Description
<!--- Describe your changes in detail -->
This PR will switch C# files from block-scoped namespaces to file-scoped
namespaces.
Closes #1689.

## Motivation and Context
<!--- Why is this change required? What problem does it solve? -->
<!--- If it fixes an open issue, please link to the issue here. -->
Improves readability.

## How Has This Been Tested?
<!--- Please describe in detail how you tested your changes. -->
<!--- Include details of your testing environment, and the tests you ran
to -->
<!--- see how your change affects other areas of the code, etc. -->
- Confirmed that all unit tests passes.
- Run the app and navigated through all pages.

## Screenshots (if appropriate):

## Types of changes
<!--- What types of changes does your code introduce? Put an `x` in all
the boxes that apply: -->
- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
  • Loading branch information
AndrewKeepCoding authored Jan 27, 2025
1 parent f9b8686 commit 67943f5
Show file tree
Hide file tree
Showing 216 changed files with 18,738 additions and 18,956 deletions.
61 changes: 30 additions & 31 deletions UITests/AxeHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,43 +20,42 @@
using System.Diagnostics;
using System.Linq;

namespace UITests
namespace UITests;

public class AxeHelper
{
public class AxeHelper
public static IScanner AccessibilityScanner;

internal static void InitializeAxe()
{
public static IScanner AccessibilityScanner;
var processes = Process.GetProcessesByName("WinUIGallery");
Assert.IsTrue(processes.Length > 0);

internal static void InitializeAxe()
{
var processes = Process.GetProcessesByName("WinUIGallery");
Assert.IsTrue(processes.Length > 0);
var config = Config.Builder.ForProcessId(processes[0].Id).Build();

var config = Config.Builder.ForProcessId(processes[0].Id).Build();
AccessibilityScanner = ScannerFactory.CreateScanner(config);
}

AccessibilityScanner = ScannerFactory.CreateScanner(config);
}
public static void AssertNoAccessibilityErrors()
{
// Bug 1474: Disabling Rules NameReasonableLength and BoundingRectangleNotNull temporarily
var testResult = AccessibilityScanner.Scan(null).WindowScanOutputs.SelectMany(output => output.Errors)
.Where(rule => rule.Rule.ID != RuleId.NameIsInformative)
.Where(rule => rule.Rule.ID != RuleId.NameExcludesControlType)
.Where(rule => rule.Rule.ID != RuleId.NameExcludesLocalizedControlType)
.Where(rule => rule.Rule.ID != RuleId.SiblingUniqueAndFocusable)
.Where(rule => rule.Rule.ID != RuleId.NameReasonableLength)
.Where(rule => rule.Rule.ID != RuleId.BoundingRectangleNotNull)
.Where(rule => rule.Rule.ID != RuleId.BoundingRectangleNotNullListViewXAML)
.Where(rule => rule.Rule.ID != RuleId.BoundingRectangleNotNullTextBlockXAML)
.Where(rule => rule.Rule.ID != RuleId.NameNotNull)
.Where(rule => rule.Rule.ID != RuleId.ChromiumComponentsShouldUseWebScanner);

public static void AssertNoAccessibilityErrors()
if (testResult.Any())
{
// Bug 1474: Disabling Rules NameReasonableLength and BoundingRectangleNotNull temporarily
var testResult = AccessibilityScanner.Scan(null).WindowScanOutputs.SelectMany(output => output.Errors)
.Where(rule => rule.Rule.ID != RuleId.NameIsInformative)
.Where(rule => rule.Rule.ID != RuleId.NameExcludesControlType)
.Where(rule => rule.Rule.ID != RuleId.NameExcludesLocalizedControlType)
.Where(rule => rule.Rule.ID != RuleId.SiblingUniqueAndFocusable)
.Where(rule => rule.Rule.ID != RuleId.NameReasonableLength)
.Where(rule => rule.Rule.ID != RuleId.BoundingRectangleNotNull)
.Where(rule => rule.Rule.ID != RuleId.BoundingRectangleNotNullListViewXAML)
.Where(rule => rule.Rule.ID != RuleId.BoundingRectangleNotNullTextBlockXAML)
.Where(rule => rule.Rule.ID != RuleId.NameNotNull)
.Where(rule => rule.Rule.ID != RuleId.ChromiumComponentsShouldUseWebScanner);

if (testResult.Any())
{
var mappedResult = testResult.Select(result =>
"Element " + result.Element.Properties["ControlType"] + " violated rule '" + result.Rule.Description + "'.");
Assert.Fail("Failed with the following accessibility errors \r\n" + string.Join("\r\n", mappedResult));
}
var mappedResult = testResult.Select(result =>
"Element " + result.Element.Properties["ControlType"] + " violated rule '" + result.Rule.Description + "'.");
Assert.Fail("Failed with the following accessibility errors \r\n" + string.Join("\r\n", mappedResult));
}
}
}
}
30 changes: 14 additions & 16 deletions UITests/SampleTestTemplate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,22 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium.Appium.Windows;

namespace UITests
namespace UITests;

[TestClass]
public class SampleTestTemplate : TestBase
{
[TestClass]
public class SampleTestTemplate : TestBase
{

private static WindowsElement element1 = null;
private static WindowsElement element2 = null;
private static WindowsElement element1 = null;
private static WindowsElement element2 = null;

public static void ClassInitialize(TestContext context)
{
OpenControlPage("MyControlPage");
Thread.Sleep(1000);
element1 = Session.FindElementByAccessibilityId("Element Locator");
Assert.IsNotNull(element1);
element2 = Session.FindElementByAccessibilityId("Element Locator");
Assert.IsNotNull(element2);
}
public static void ClassInitialize(TestContext context)
{
OpenControlPage("MyControlPage");
Thread.Sleep(1000);
element1 = Session.FindElementByAccessibilityId("Element Locator");
Assert.IsNotNull(element1);
element2 = Session.FindElementByAccessibilityId("Element Locator");
Assert.IsNotNull(element2);
}
}

Loading

0 comments on commit 67943f5

Please sign in to comment.