@@ -65,8 +65,7 @@ private static bool IsPesterCommand(CommandAst commandAst)
65
65
}
66
66
67
67
// Ensure the first word is a Pester keyword
68
- if ( ! ( commandAst . CommandElements [ 0 ] is StringConstantExpressionAst pesterKeywordAst &&
69
- PesterSymbolReference . PesterKeywords . ContainsKey ( pesterKeywordAst . Value ) ) )
68
+ if ( ! PesterSymbolReference . PesterKeywords . ContainsKey ( commandAst . GetCommandName ( ) ) )
70
69
{
71
70
return false ;
72
71
}
@@ -93,7 +92,9 @@ private static PesterSymbolReference ConvertPesterAstToSymbolReference(ScriptFil
93
92
string commandName = pesterCommandAst . GetCommandName ( ) ;
94
93
95
94
// Search for a name for the test
95
+ // If the test has more than one argument for names, we set it to null
96
96
string testName = null ;
97
+ bool alreadySawName = false ;
97
98
for ( int i = 1 ; i < pesterCommandAst . CommandElements . Count ; i ++ )
98
99
{
99
100
CommandElementAst currentCommandElement = pesterCommandAst . CommandElements [ i ] ;
@@ -104,17 +105,18 @@ private static PesterSymbolReference ConvertPesterAstToSymbolReference(ScriptFil
104
105
i ++ ;
105
106
if ( parameterAst . ParameterName == "Name" && i < pesterCommandAst . CommandElements . Count )
106
107
{
107
- testName = ( pesterCommandAst . CommandElements [ i ] as StringConstantExpressionAst ) ? . Value ;
108
- break ;
108
+ testName = alreadySawName ? null : ( pesterCommandAst . CommandElements [ i ] as StringConstantExpressionAst ) ? . Value ;
109
+ alreadySawName = true ;
109
110
}
110
111
continue ;
111
112
}
112
113
113
114
// Otherwise, if an argument is given with no parameter, we assume it's the name
115
+ // If we've already seen a name, we set the name to null
114
116
if ( pesterCommandAst . CommandElements [ i ] is StringConstantExpressionAst testNameStrAst )
115
117
{
116
- testName = testNameStrAst . Value ;
117
- break ;
118
+ testName = alreadySawName ? null : testNameStrAst . Value ;
119
+ alreadySawName = true ;
118
120
}
119
121
}
120
122
0 commit comments