Exemplo n.º 1
0
 /// <summary>
 /// Called when a switch that doesn't take parameters is detected on the command line.
 /// </summary>
 /// <param name="commandLineSwitches"></param>
 /// <param name="parameterlessSwitch"></param>
 /// <param name="switchParameters"></param>
 /// <param name="duplicateSwitchErrorMessage"></param>
 /// <param name="unquotedCommandLineArg"></param>
 private static void GatherParameterlessCommandLineSwitch
 (
     CommandLineSwitches commandLineSwitches,
     CommandLineSwitches.ParameterlessSwitch parameterlessSwitch,
     string switchParameters,
     string duplicateSwitchErrorMessage,
     string unquotedCommandLineArg
 )
 {
     // switch should not have any parameters
     if (switchParameters.Length == 0)
     {
         // check if switch is duplicated, and if that's allowed
         if (!commandLineSwitches.IsParameterlessSwitchSet(parameterlessSwitch) ||
             (duplicateSwitchErrorMessage == null))
         {
             commandLineSwitches.SetParameterlessSwitch(parameterlessSwitch, unquotedCommandLineArg);
         }
         else
         {
             commandLineSwitches.SetSwitchError(duplicateSwitchErrorMessage, unquotedCommandLineArg);
         }
     }
     else
     {
         commandLineSwitches.SetUnexpectedParametersError(unquotedCommandLineArg);
     }
 }
Exemplo n.º 2
0
        public void AppendErrorTests2()
        {
            CommandLineSwitches switchesLeft = new CommandLineSwitches();
            CommandLineSwitches switchesRight = new CommandLineSwitches();

            Assert.False(switchesLeft.HaveErrors());
            Assert.False(switchesRight.HaveErrors());

            switchesLeft.SetUnknownSwitchError("/bogus");
            switchesRight.SetUnexpectedParametersError("/nologo:foo");

            Assert.True(switchesLeft.HaveErrors());
            Assert.True(switchesRight.HaveErrors());

            VerifySwitchError(switchesLeft, "/bogus");
            VerifySwitchError(switchesRight, "/nologo:foo");

            switchesLeft.Append(switchesRight);

            VerifySwitchError(switchesLeft, "/bogus");
            VerifySwitchError(switchesRight, "/nologo:foo");
        }