Ich möchte IDBCommand mit NSsubstitute ersetzen. I substitue Feld Command müssen, und ich habeNSubstitute für IDBCommand und Fehler CA2100
string settedCommandText=string.Empty;
IDbCommand fakeCommand = Substitute.For<IDbCommand>();
command.CommandText =Arg.Do<string>(x => settedCommandText = x);
Gut, aber Compiler throw Fehler:
CA2100 The query string passed to 'IDbCommand.CommandText.set(string)' in 'DriverTest.RevertCommandSendRevertInstruction()' could contain the following variables 'Arg.Do(...)'. If any of these variables could come from user input, consider using a stored procedure or a parameterized SQL query instead of building the query with string concatenations.
Wie kann ich diesen Code neu schreiben, ohne diesen Fehler zu unterdrücken. Ich möchte nicht verwenden System.Diagnostics.CodeAnalysis.SuppressMessage
Ich glaube nicht, dass Sie den Arg.Do brauchen. Setzen Sie die Eigenschaft 'fakeCommand.CommandText' nur nach der Testaktion auf. –