@Test
  public void shouldReturnBaseSetupWhenProfilingIsNotAllowed() {
    // Given
    final CommandLineSetup baseSetup =
        new CommandLineSetup(
            "someTool",
            Arrays.asList(
                new CommandLineArgument("/arg1", CommandLineArgument.Type.PARAMETER),
                new CommandLineArgument("/arg2", CommandLineArgument.Type.PARAMETER)),
            Collections.singletonList(myCommandLineResource));
    myCtx.checking(
        new Expectations() {
          {
            oneOf(myAssertions).contains(RunnerAssertions.Assertion.PROFILING_IS_NOT_ALLOWED);
            will(returnValue(true));
          }
        });

    final DotTraceSetupBuilder instance = createInstance();

    // When
    final CommandLineSetup setup = instance.build(baseSetup).iterator().next();

    // Then
    myCtx.assertIsSatisfied();
    then(setup).isEqualTo(baseSetup);
  }
  @Test(dataProvider = "runnerParamUseDotTraceCases")
  public void shouldReturnBaseSetupWhenRunnerParamUseDotTraceIsEmptyOrFalse(
      final String useDotTrace) {
    // Given
    final CommandLineSetup baseSetup =
        new CommandLineSetup(
            "someTool",
            Arrays.asList(
                new CommandLineArgument("/arg1", CommandLineArgument.Type.PARAMETER),
                new CommandLineArgument("/arg2", CommandLineArgument.Type.PARAMETER)),
            Collections.singletonList(myCommandLineResource));
    myCtx.checking(
        new Expectations() {
          {
            oneOf(myAssertions).contains(RunnerAssertions.Assertion.PROFILING_IS_NOT_ALLOWED);
            will(returnValue(false));

            oneOf(myRunnerParametersService).tryGetRunnerParameter(Constants.USE_VAR);
            will(returnValue(useDotTrace));
          }
        });

    final DotTraceSetupBuilder instance = createInstance();

    // When
    final CommandLineSetup setup = instance.build(baseSetup).iterator().next();

    // Then
    myCtx.assertIsSatisfied();
    then(setup).isEqualTo(baseSetup);
  }
  @Test
  public void shouldCreateSetupWhenGetSetup() {
    // Given
    final CommandLineSetup baseSetup =
        new CommandLineSetup(
            "someTool",
            Arrays.asList(
                new CommandLineArgument("/arg1", CommandLineArgument.Type.PARAMETER),
                new CommandLineArgument("/arg2", CommandLineArgument.Type.PARAMETER)),
            Collections.singletonList(myCommandLineResource));
    final File cmdFile = new File("cmd");
    final File projectFile = new File("project");
    final File snapshotDir = new File("snapshotRoot");
    final File snapshotFile = new File(snapshotDir, DotTraceSetupBuilder.DOT_TRACE_SNAPSHOT_FILE);
    final File patternsFile = new File("patterns");
    final File reportFile = new File("report");
    final Context ctx = new Context(baseSetup, projectFile, snapshotFile, patternsFile, reportFile);

    myCtx.checking(
        new Expectations() {
          {
            oneOf(myAssertions).contains(RunnerAssertions.Assertion.PROFILING_IS_NOT_ALLOWED);
            will(returnValue(false));

            oneOf(myRunnerParametersService).tryGetRunnerParameter(Constants.USE_VAR);
            will(returnValue("True"));

            oneOf(myFileService).getTempFileName(DotTraceSetupBuilder.DOT_TRACE_CMD_EXT);
            will(returnValue(cmdFile));

            oneOf(myFileService).getTempFileName(DotTraceSetupBuilder.DOT_TRACE_PROJECT_EXT);
            will(returnValue(projectFile));

            oneOf(myFileService).getTempFileName("");
            will(returnValue(snapshotDir));

            oneOf(myFileService).exists(snapshotDir);
            will(returnValue(true));

            oneOf(myFileService).getTempFileName(DotTraceSetupBuilder.DOT_TRACE_PATTERNS_EXT);
            will(returnValue(patternsFile));

            oneOf(myFileService).getTempFileName(DotTraceSetupBuilder.DOT_TRACE_REPORT_EXT);
            will(returnValue(reportFile));

            oneOf(myProjectGenerator).create(ctx);
            will(returnValue("project's content"));

            oneOf(myPatternsGenerator).create(ctx);
            will(returnValue("patterns' content"));

            oneOf(myCmdGenerator).create(ctx);
            will(returnValue("cmd's content"));
          }
        });

    final DotTraceSetupBuilder instance = createInstance();

    // When
    final CommandLineSetup setup = instance.build(baseSetup).iterator().next();

    // Then
    myCtx.assertIsSatisfied();
    then(setup.getToolPath()).isEqualTo(cmdFile.getPath());
    then(setup.getArgs()).isEmpty();
    then(setup.getResources())
        .containsExactly(
            myCommandLineResource,
            new CommandLineFile(myBeforeBuildPublisher, projectFile, "project's content"),
            new CommandLineFile(myBeforeBuildPublisher, patternsFile, "patterns' content"),
            new CommandLineFile(myBeforeBuildPublisher, cmdFile, "cmd's content"),
            new CommandLineArtifact(myDotTraceBuildPublisher, reportFile),
            new CommandLineArtifact(myDotTraceSnapshotsPublisher, snapshotFile));
  }