コード例 #1
0
  public void testCreatesChangeMonitorWhenProjectIsCreated() throws CoreException {
    IProjectChangeMonitorFactory factory = getFactory();
    expect(factory.createProjectChangeMonitor((IProject) anyObject()))
        .andReturn(createMock(IResourceChangeListener.class));
    replay(factory);

    TestHaskellProject prj = new TestHaskellProject("createsChangeMonitorProject", getCorePrefs());
    prj.destroy();

    verify(factory);
  }
コード例 #2
0
  public void testCreatesProjectMonitorsForLoadedWorkspace() throws CoreException {
    TestHaskellProject prj = new TestHaskellProject("myproject", getCorePrefs());

    IProjectChangeMonitorFactory factory = createMock(IProjectChangeMonitorFactory.class);
    expect(factory.createProjectChangeMonitor(prj.getPlatformProject()))
        .andReturn(createNiceMock(IResourceChangeListener.class));
    expect(factory.createProjectChangeMonitor((IProject) anyObject()))
        .andReturn(createNiceMock(IResourceChangeListener.class))
        .atLeastOnce(); // projects might already exist in the workspace
    checkOrder(factory, false);
    replay(factory);

    WorkspaceChangeMonitor mon = new WorkspaceChangeMonitor(factory);
    mon.observeChangesOn(getWorkspace());

    getWorkspace().removeResourceChangeListener(mon);

    verify(factory);
  }
コード例 #3
0
  public void testDelegatesProjectEventsToCorrespondingMonitor() throws CoreException {
    IResourceChangeListener fstMonitor = createNiceMock(IResourceChangeListener.class);
    IResourceChangeListener sndMonitor = createNiceMock(IResourceChangeListener.class);
    expect(getFactory().createProjectChangeMonitor((IProject) anyObject())).andReturn(fstMonitor);
    expect(getFactory().createProjectChangeMonitor((IProject) anyObject())).andReturn(sndMonitor);
    replay(getFactory());

    TestHaskellProject fstPrj = new TestHaskellProject("first-project", getCorePrefs());
    TestHaskellProject sndPrj = new TestHaskellProject("second-project", getCorePrefs());

    try {
      fstMonitor.resourceChanged((IResourceChangeEvent) anyObject());
      replay(fstMonitor, sndMonitor);
      fstPrj.createSourceFile("Factorial.hs", "module Factorial where\n\n");
      verify(getFactory(), fstMonitor, sndMonitor);
    } finally {
      fstPrj.destroy();
      sndPrj.destroy();
    }
  }