Package samples.expectnew

Examples of samples.expectnew.PrimitiveAndWrapperDemo


@PrepareForTest(PrimitiveAndWrapperUser.class)
public class PrimitiveAndWrapperUserTest {

  @Test
  public void testNewWithStrictMocking_ok() throws Exception {
    PrimitiveAndWrapperDemo mock1 = createStrictMockAndExpectNew(PrimitiveAndWrapperDemo.class, new Class<?>[] { Integer.class }, 42);
    PrimitiveAndWrapperDemo mock2 = createStrictMockAndExpectNew(PrimitiveAndWrapperDemo.class, new Class<?>[] { int.class }, 21);

    expect(mock1.getMyInt()).andReturn(10);
    expect(mock2.getMyInt()).andReturn(21);

    replayAll();

    assertEquals(31, new PrimitiveAndWrapperUser().useThem());
View Full Code Here


    verifyAll();
  }

  @Test(expected = AssertionError.class)
  public void testNewWithStrictMocking_notOk() throws Exception {
    PrimitiveAndWrapperDemo mock2 = createStrictMockAndExpectNew(PrimitiveAndWrapperDemo.class, new Class<?>[] { int.class }, 21);
    PrimitiveAndWrapperDemo mock1 = createStrictMockAndExpectNew(PrimitiveAndWrapperDemo.class, new Class<?>[] { Integer.class }, 42);

    expect(mock1.getMyInt()).andReturn(10);
    expect(mock2.getMyInt()).andReturn(21);

    replayAll();

    assertEquals(31, new PrimitiveAndWrapperUser().useThem());
View Full Code Here

    verifyAll();
  }

  @Test
  public void testNewWithNiceMocking() throws Exception {
    PrimitiveAndWrapperDemo mock = createNiceMockAndExpectNew(PrimitiveAndWrapperDemo.class, new Class<?>[] { Integer.class }, 42);
    expect(mock.getMyInt()).andReturn(2);

    replayAll();

    assertEquals(2, new PrimitiveAndWrapperUser().useThem());
View Full Code Here

TOP

Related Classes of samples.expectnew.PrimitiveAndWrapperDemo

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.