コード例 #1
0
  @Test
  public void passesEachProjectToRenderer() throws IOException {
    final Project child1 = createChildProject(project, "child1");
    final Project child2 = createChildProject(project, "child2");

    context.checking(
        new Expectations() {
          {
            Sequence sequence = context.sequence("seq");

            one(renderer).startProject(project);
            inSequence(sequence);
            one(generator).run();
            inSequence(sequence);
            one(renderer).completeProject(project);
            inSequence(sequence);
            one(renderer).startProject(child1);
            inSequence(sequence);
            one(generator).run();
            inSequence(sequence);
            one(renderer).completeProject(child1);
            inSequence(sequence);
            one(renderer).startProject(child2);
            inSequence(sequence);
            one(generator).run();
            inSequence(sequence);
            one(renderer).completeProject(child2);
            inSequence(sequence);
            one(renderer).complete();
            inSequence(sequence);
          }
        });

    task.generate();
  }
コード例 #2
0
  @Test
  public void completesRendererAtEndOfGeneration() throws IOException {
    context.checking(
        new Expectations() {
          {
            Sequence sequence = context.sequence("sequence");
            one(renderer).startProject(project);
            inSequence(sequence);
            one(generator).run();
            inSequence(sequence);
            one(renderer).completeProject(project);
            inSequence(sequence);
            one(renderer).complete();
            inSequence(sequence);
          }
        });

    task.generate();
  }
コード例 #3
0
  @Test
  public void createsMissingOutputDirectory() throws IOException {
    final File file = new File(getTestDir(), "missing/missing.txt");
    assertFalse(file.getParentFile().isDirectory());

    context.checking(
        new Expectations() {
          {
            one(renderer).setOutputFile(file);
            one(renderer).startProject(project);
            one(generator).run();
            one(renderer).completeProject(project);
            one(renderer).complete();
          }
        });

    task.setOutputFile(file);
    task.generate();

    assertTrue(file.getParentFile().isDirectory());
  }
コード例 #4
0
  @Test
  public void setsOutputFileNameOnRendererBeforeGeneration() throws IOException {
    final File file = new File(getTestDir(), "report.txt");

    context.checking(
        new Expectations() {
          {
            Sequence sequence = context.sequence("sequence");
            one(renderer).setOutputFile(file);
            inSequence(sequence);
            one(renderer).startProject(project);
            inSequence(sequence);
            one(generator).run();
            inSequence(sequence);
            one(renderer).completeProject(project);
            inSequence(sequence);
            one(renderer).complete();
            inSequence(sequence);
          }
        });

    task.setOutputFile(file);
    task.generate();
  }