Skip to content

Commit

Permalink
feat: open grid records using ordinals (#66)
Browse files Browse the repository at this point in the history
+semver: feature
  • Loading branch information
thathi committed Feb 4, 2021
1 parent 9fc6c46 commit 941bdae
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public static void WhenISelectAllInTheSubgrid(string subGridName)
/// <param name="index">The position of the record.</param>
/// <param name="subGridName">The name of the subgrid.</param>
[When(@"I open the record at position '(\d+)' in the '(.*)' subgrid")]
[When(@"I open the (\d+(?:(?:st)|(?:nd)|(?:rd)|(?:th))) record in the '(.*)' subgrid")]
public static void WhenIOpenTheRecordAtPositionInTheSubgrid(int index, string subGridName)
{
XrmApp.Entity.SubGrid.OpenSubGridRecord(subGridName, index);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class GridSteps : PowerAppsStepDefiner
/// </summary>
/// <param name="index">The position of the record.</param>
[When(@"I open the record at position '(\d+)' in the grid")]
[When(@"I open the (\d+(?:(?:st)|(?:nd)|(?:rd)|(?:th))) record in the grid")]
public static void WhenIOpenTheRecordAtPositionInTheGrid(int index)
{
XrmApp.Grid.OpenRecord(index);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public static void WhenIClickTheNewButtonInTheLookup()
/// </summary>
/// <param name="index">The position of the record.</param>
[When(@"I open the record at position '(\d+)' in the lookup")]
[When(@"I open the (\d+(?:(?:st)|(?:nd)|(?:rd)|(?:th))) record in the lookup")]
public static void WhenIOpenTheRecordAtPositionInTheLookup(int index)
{
XrmApp.Lookup.OpenRecord(index);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class RelatedGridSteps : PowerAppsStepDefiner
/// </summary>
/// <param name="index">The position of the record.</param>
[When(@"I open the record at position '(\d+)' in the related grid")]
[When(@"I open the (\d+(?:(?:st)|(?:nd)|(?:rd)|(?:th))) record in the related grid")]
public static void WhenIOpenTheRecordAtPositionInTheRelatedGrid(int index)
{
XrmApp.Entity.RelatedGrid.OpenGridRow(index);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{
using System;
using System.Linq;
using System.Text.RegularExpressions;
using TechTalk.SpecFlow;

/// <summary>
Expand All @@ -20,5 +21,16 @@ public static string[] TransformCommaSeparatedStringsToArray(string expression)
{
return expression?.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(s => s.Trim()).ToArray();
}

/// <summary>
/// Transforms an ordinal number (e.g. 1st, 2nd, 3rd etc.) to a zero-based index.
/// </summary>
/// <param name="expression">The ordinal number.</param>
/// <returns>The zero-based index.</returns>
[StepArgumentTransformation(@"(\d+(?:(?:st)|(?:nd)|(?:rd)|(?:th)))")]
public static int TransformOrdinalNumberToZeroBasedIndex(string expression)
{
return Convert.ToInt32(Regex.Match(expression, @"\d+").Value) - 1;
}
}
}

0 comments on commit 941bdae

Please sign in to comment.