public void setExpectations(Expectations expectations) {
      try {
        expectations.allowing(mock).getCanonicalFile();
        expectations.will(expectations.returnValue(mock));
      } catch (IOException th) {
        // ignore
      }
      expectations.allowing(mock).isFile();
      expectations.will(expectations.returnValue(isFile));
      expectations.allowing(mock).getName();
      expectations.will(expectations.returnValue(name));
      expectations.allowing(mock).exists();
      expectations.will(expectations.returnValue(true));

      ArrayList<File> mockChildren = new ArrayList<File>(children.size());
      for (MockFile child : children) {
        mockChildren.add(child.getMock());
        child.setExpectations(expectations);
      }
      expectations.allowing(mock).listFiles();
      expectations.will(
          expectations.returnValue(mockChildren.toArray(new File[mockChildren.size()])));
    }