Skip to content

Commit

Permalink
Switch to file-scoped namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewKeepCoding committed Dec 13, 2024
1 parent 3785bb5 commit 5f4ff16
Show file tree
Hide file tree
Showing 215 changed files with 18,824 additions and 19,045 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 5f4ff16

Please sign in to comment.