Exemplo n.º 1
0
  @Test
  public void test5_mockUpInterfaceImplementationClassesUsingNamedMockUp() {
    new InterfaceMockUp();

    actionI = new ActionImpl1();
    assertEquals(3, actionI.perform(1));
    assertEquals(4, new ActionImpl2().perform(2));
  }
Exemplo n.º 2
0
  @After
  public void checkImplementationClassesAreNoLongerMocked() {
    if (actionI != null) {
      assertEquals(-1, actionI.perform(0));
    }

    assertEquals(-2, new ActionImpl2().perform(0));

    if (actionB != null) {
      assertEquals(-1, actionB.perform(0));
    }

    assertEquals(-2, new ConcreteAction2().perform(0));
    assertEquals(-3, new ConcreteAction3().perform(0));
  }
Exemplo n.º 3
0
  @Test
  public <T extends IAction> void test3_mockUpInterfaceImplementationClassesUsingAnonymousMockUp() {
    actionI = new ActionImpl1();

    new MockUp<T>() {
      @Mock(minInvocations = 2)
      int perform(int i) {
        return i + 1;
      }
    };

    assertEquals(2, actionI.perform(1));
    assertTrue(actionI.notToBeMocked());

    ActionImpl2 impl2 = new ActionImpl2();
    assertEquals(3, impl2.perform(2));
    assertTrue(impl2.notToBeMocked());
  }