Package samples.privatemocking

Examples of samples.privatemocking.PrivateMethodDemo


    assertEquals("Expected and actual did not match", expected, actual);
  }

  @Test
  public void testExpectPrivateWithArrayMatcher() throws Exception {
    PrivateMethodDemo tested = createPartialMock(PrivateMethodDemo.class,
        "doArrayInternal");

    expectPrivate(tested, "doArrayInternal", EasyMock
        .aryEq((Object[]) new String[] { "hello" }));

    replay(tested);

    tested.doArrayStuff("hello");

    verify(tested);
  }
View Full Code Here


    verify(tested);
  }

  @Test
  public void testExpectPrivateWithObjectMatcher() throws Exception {
    PrivateMethodDemo tested = createPartialMock(PrivateMethodDemo.class,
        "doObjectInternal");

    expectPrivate(tested, "doObjectInternal", EasyMock
        .isA(CharSequence.class));

    replay(tested);

    tested.doObjectStuff("hello");

    verify(tested);
  }
View Full Code Here

  public void testExpectPrivateMethodWithVarArgsParameters() throws Exception {
    final String methodToExpect = "varArgsMethod";
    final int expected = 7;
    final int valueA = 2;
    final int valueB = 3;
    PrivateMethodDemo tested = createPartialMock(PrivateMethodDemo.class,
        methodToExpect);

    expectPrivate(tested, methodToExpect, valueA, valueB).andReturn(
        expected);

    replay(tested);

    assertEquals(expected, tested.invokeVarArgsMethod(valueA, valueB));

    verify(tested);
  }
View Full Code Here

  @Test
  public void testExpectPrivateMethodWithoutSpecifyingMethodName_firstArgumentIsOfStringType()
      throws Exception {
    final String expected = "Hello world";
    PrivateMethodDemo tested = createPartialMock(PrivateMethodDemo.class,
        "sayIt");

    expectPrivate(tested, (String) null, "firstName", " ", "lastName")
        .andReturn(expected);

    replay(tested);

    assertEquals(expected, tested.enhancedSay("firstName", "lastName"));

    verify(tested);
  }
View Full Code Here

  @Test
  public void testExpectPrivateMethodWithoutSpecifyingMethodName()
      throws Exception {
    final String expected = "Hello world";
    PrivateMethodDemo tested = createPartialMock(PrivateMethodDemo.class,
        "doSayYear");

    expectPrivate(tested, 22, "name").andReturn(expected);

    replay(tested);

    assertEquals(expected, tested.sayYear("name", 22));

    verify(tested);
  }
View Full Code Here

TOP

Related Classes of samples.privatemocking.PrivateMethodDemo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.