-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
71 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
namespace UiTests.VisualStudioCode; | ||
|
||
public record Position(int Line, int Column); |
49 changes: 49 additions & 0 deletions
49
tests/UiTests/VisualStudioCode/VisualStudioPositionElement.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
namespace UiTests.VisualStudioCode; | ||
|
||
using System; | ||
using System.Text.RegularExpressions; | ||
using FlaUI.Core; | ||
using FlaUI.Core.AutomationElements; | ||
using Xunit.Abstractions; | ||
|
||
public partial class VisualStudioPositionElement : AutomationElement | ||
{ | ||
private readonly ITestOutputHelper? _outputHelper; | ||
|
||
public VisualStudioPositionElement(FrameworkAutomationElementBase frameworkAutomationElement) : base(frameworkAutomationElement) | ||
{ | ||
} | ||
|
||
public VisualStudioPositionElement(AutomationElement automationElement, ITestOutputHelper outputHelper) | ||
: base(automationElement) | ||
{ | ||
_outputHelper = outputHelper; | ||
} | ||
|
||
public Position Position | ||
{ | ||
get | ||
{ | ||
var text = Name.Trim(); | ||
|
||
if (string.IsNullOrWhiteSpace(text)) | ||
{ | ||
throw new NotSupportedException("Could not find line and column from empty text"); | ||
} | ||
|
||
Match result = RegexLineCol().Match(text); | ||
if (result.Success) | ||
{ | ||
return new Position( | ||
int.Parse(result.Groups[1].Value), | ||
int.Parse(result.Groups[2].Value)); | ||
} | ||
|
||
throw new NotSupportedException($"Could not find line and column from text '{text}'"); | ||
} | ||
} | ||
|
||
// TODO: also other type Ln 3, Col 4 (3 selected) stuf. | ||
[GeneratedRegex("Ln\\s([0-9]+),\\sCol\\s([0-9]+)", RegexOptions.Compiled | RegexOptions.Singleline)] | ||
private static partial Regex RegexLineCol(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters