-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added option to override regex group matching behavior (#243)
- Loading branch information
1 parent
c85984f
commit 812ffc8
Showing
5 changed files
with
34 additions
and
16 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
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,26 @@ | ||
using Reqnroll.Bindings; | ||
using System.Linq; | ||
using System.Text.RegularExpressions; | ||
|
||
namespace Reqnroll.Infrastructure | ||
{ | ||
public interface IMatchArgumentCalculator | ||
{ | ||
object[] CalculateArguments(Match match, StepInstance stepInstance, IStepDefinitionBinding stepDefinitionBinding); | ||
} | ||
|
||
public class MatchArgumentCalculator : IMatchArgumentCalculator | ||
{ | ||
public object[] CalculateArguments(Match match, StepInstance stepInstance, IStepDefinitionBinding stepDefinitionBinding) | ||
{ | ||
var regexArgs = match.Groups.Cast<Group>().Skip(1).Where(g => g.Success).Select(g => g.Value); | ||
var arguments = regexArgs.Cast<object>().ToList(); | ||
if (stepInstance.MultilineTextArgument != null) | ||
arguments.Add(stepInstance.MultilineTextArgument); | ||
if (stepInstance.TableArgument != null) | ||
arguments.Add(stepInstance.TableArgument); | ||
|
||
return arguments.ToArray(); | ||
} | ||
} | ||
} |
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