@@ -65,8 +65,7 @@ private static bool IsPesterCommand(CommandAst commandAst)
6565 }
6666
6767 // 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 ( ) ) )
7069 {
7170 return false ;
7271 }
@@ -93,7 +92,9 @@ private static PesterSymbolReference ConvertPesterAstToSymbolReference(ScriptFil
9392 string commandName = pesterCommandAst . GetCommandName ( ) ;
9493
9594 // Search for a name for the test
95+ // If the test has more than one argument for names, we set it to null
9696 string testName = null ;
97+ bool alreadySawName = false ;
9798 for ( int i = 1 ; i < pesterCommandAst . CommandElements . Count ; i ++ )
9899 {
99100 CommandElementAst currentCommandElement = pesterCommandAst . CommandElements [ i ] ;
@@ -104,17 +105,18 @@ private static PesterSymbolReference ConvertPesterAstToSymbolReference(ScriptFil
104105 i ++ ;
105106 if ( parameterAst . ParameterName == "Name" && i < pesterCommandAst . CommandElements . Count )
106107 {
107- testName = ( pesterCommandAst . CommandElements [ i ] as StringConstantExpressionAst ) ? . Value ;
108- break ;
108+ testName = alreadySawName ? null : ( pesterCommandAst . CommandElements [ i ] as StringConstantExpressionAst ) ? . Value ;
109+ alreadySawName = true ;
109110 }
110111 continue ;
111112 }
112113
113114 // 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
114116 if ( pesterCommandAst . CommandElements [ i ] is StringConstantExpressionAst testNameStrAst )
115117 {
116- testName = testNameStrAst . Value ;
117- break ;
118+ testName = alreadySawName ? null : testNameStrAst . Value ;
119+ alreadySawName = true ;
118120 }
119121 }
120122
0 commit comments