@Test
  public void shouldFindRemovedFiles() throws Exception {
    File newFile = createFileForClass(TestFakeProduct.class);
    assertThat(detector.findChangedFiles(), hasItem(newFile));

    FileUtils.forceDelete(newFile);

    assertTrue(detector.filesWereRemoved());
    assertThat(detector.findChangedFiles(), not(hasItem(newFile)));
  }
 @Test
 public void shouldFindChangedFiles() throws IOException {
   Set<File> files = detector.findChangedFiles();
   assertTrue("Should have found changed files on first run", files.size() > 0);
   assertThat(
       "TestFakeProduct should be in changed list",
       files,
       hasItem(getFileForClass(TestFakeProduct.class)));
   assertTrue(
       "FakeProduct should be in changed list",
       files.contains(getFileForClass(FakeProduct.class)));
   assertTrue("Should have no changed files now", detector.findChangedFiles().isEmpty());
 }
 @Test
 public void shouldDetectChangedFilesByTimeStamp() throws Exception {
   detector =
       new FileChangeDetector() {
         @Override
         protected long getModificationTimestamp(File classFile) {
           return timestamp;
         }
       };
   detector.setClasspathProvider(classpath);
   assertFalse(
       "Should have found changed files on first run", detector.findChangedFiles().isEmpty());
   assertTrue("Timestamp is unchanged", detector.findChangedFiles().isEmpty());
   timestamp += 100;
   assertFalse("Timestamp changed", detector.findChangedFiles().isEmpty());
 }
 @Test
 public void canLookInMultipleClassDirectories() throws Exception {
   File newFile = createFileForClass(TestFakeProduct.class);
   File thisFile = InfinitestTestUtils.getFileForClass(getClass());
   Set<File> changedFiles = detector.findChangedFiles();
   assertThat(changedFiles, hasItem(newFile));
   assertThat(changedFiles, hasItem(thisFile));
 }
  @Before
  public void inContext() throws IOException {
    changeDetector = mock(ChangeDetector.class);
    when(changeDetector.findChangedFiles()).thenThrow(new IOException());

    changeDetector.clear();

    testDetector = new StubTestDetector();
    core = createCore(changeDetector, testDetector);
  }
 @Test
 public void shouldBeTolerantOfDissapearingDirectories() throws Exception {
   detector =
       new FileChangeDetector() {
         @Override
         protected File[] childrenOf(File directory) {
           return null;
         }
       };
   detector.setClasspathProvider(classpath);
   assertEquals(emptySet(), detector.findChangedFiles());
 }
 @Test
 public void shouldHandleStrangeClasspaths() throws Exception {
   ChangeDetector changeDetector = new FileChangeDetector();
   changeDetector.setClasspathProvider(new StandaloneClasspath(new ArrayList<File>(), ""));
   assertTrue(changeDetector.findChangedFiles().isEmpty());
 }