Skip to content

Commit

Permalink
Modified CucumberExpressionParameterTypeRegistry to lookup enums by t…
Browse files Browse the repository at this point in the history
…ype FullName.
  • Loading branch information
clrudolphi committed Apr 12, 2024
1 parent cdff1f5 commit cba2383
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,14 @@ public IParameterType LookupByTypeName(string name)
{
if (_parameterTypesByName.Value.TryGetValue(name, out var parameterType))
return parameterType;
//enum keys contain the Fullname of the type, try matching on the short name:
var matchingEnums = _parameterTypesByName.Value.Where(kvp => kvp.Key.EndsWith(name) && kvp.Value.ParameterType.IsEnum).ToArray();
if (matchingEnums.Length == 0) { return null; }
if (matchingEnums.Length == 1) { return matchingEnums[0].Value; }
if (matchingEnums.Length > 1)
{
throw new ApplicationException($"Ambigous Enum Parameters share the same short name '{name}'. Use the Enum's FullName in the Cucumber Expression.");
}
return null;
}

Expand Down

0 comments on commit cba2383

Please sign in to comment.