@Test
  public void testToCommandForSolution() throws Exception {
    StyleCopCommandBuilder styleCopCommandBuilder = StyleCopCommandBuilder.createBuilder(solution);
    styleCopCommandBuilder.setDotnetSdkDirectory(new File("DotnetSdkDir"));
    styleCopCommandBuilder.setStyleCopFolder(new File("StyleCopDir"));
    styleCopCommandBuilder.setConfigFile(
        TestUtils.getResource("/Runner/Command/SimpleRules.StyleCop"));
    styleCopCommandBuilder.setReportFile(new File("target/sonar/report.xml"));
    Command command = styleCopCommandBuilder.toCommand();

    assertThat(command.getExecutable(), endsWith("MSBuild.exe"));
    String[] commands = command.getArguments().toArray(new String[] {});
    assertThat(commands[0], endsWith("solution"));
    assertThat(commands[1], is("/target:StyleCopLaunch"));
    assertThat(commands[2], is("/noconsolelogger"));
    assertThat(commands[3], endsWith("stylecop-msbuild.xml"));

    File report = new File("target/sonar/stylecop-msbuild.xml");
    assertTrue(report.exists());
    report.delete();
  }
  /**
   * Transforms this command object into a array of string that can be passed to the
   * CommandExecutor, and generates the required MSBuild file to execute StyleCop.
   *
   * @return the Command that represent the command to launch.
   */
  public Command toCommand() {
    validate();
    MsBuildFileGenerator msBuildFileGenerator =
        new MsBuildFileGenerator(solution, styleCopConfigFile, styleCopReportFile, styleCopFolder);
    File msBuildFile =
        msBuildFileGenerator.generateFile(styleCopReportFile.getParentFile(), vsProject);

    LOG.debug("- MSBuild path          : " + dotnetSdkDirectory.getAbsolutePath());
    Command command = Command.create(new File(dotnetSdkDirectory, "MSBuild.exe").getAbsolutePath());

    LOG.debug("- Application Root      : " + solution.getSolutionDir().getAbsolutePath());
    command.addArgument("/p:AppRoot=" + solution.getSolutionDir().getAbsolutePath());

    LOG.debug("- Target to run         : StyleCopLaunch");
    command.addArgument("/target:StyleCopLaunch");

    if (!LOG.isDebugEnabled()) {
      command.addArgument("/noconsolelogger");
    }

    LOG.debug("- MSBuild file          : " + msBuildFile.getAbsolutePath());
    command.addArgument(msBuildFile.getAbsolutePath());

    return command;
  }