Package samples.expectnew

Examples of samples.expectnew.ExpectNewServiceUser


    public void testNewWithConstructorUsingParameterTypesAndArguments() throws Exception {
        final int numberOfTimes = 2;
        final String expected = "used";

        ExpectNewDemo tested = new ExpectNewDemo();
        ExpectNewServiceUser expectNewServiceImplMock = mock(ExpectNewServiceUser.class);
        Service serviceMock = mock(Service.class);

        whenNew(constructor(ExpectNewServiceUser.class, Service.class, int.class)).withArguments(serviceMock, numberOfTimes).thenReturn(
                expectNewServiceImplMock);
        when(expectNewServiceImplMock.useService()).thenReturn(expected);

        assertEquals(expected, tested.newWithArguments(serviceMock, numberOfTimes));

        verifyNew(ExpectNewServiceUser.class).withArguments(serviceMock, numberOfTimes);
    }
View Full Code Here


    public void testNewUsingConstructorWithArguments() throws Exception {
        final int numberOfTimes = 2;
        final String expected = "used";

        ExpectNewDemo tested = new ExpectNewDemo();
        ExpectNewServiceUser expectNewServiceImplMock = mock(ExpectNewServiceUser.class);
        Service serviceMock = mock(Service.class);

        whenNew(constructor(ExpectNewServiceUser.class)).withArguments(serviceMock, numberOfTimes).thenReturn(expectNewServiceImplMock);
        when(expectNewServiceImplMock.useService()).thenReturn(expected);

        assertEquals(expected, tested.newWithArguments(serviceMock, numberOfTimes));

        verifyNew(ExpectNewServiceUser.class).withArguments(serviceMock, numberOfTimes);
    }
View Full Code Here

    public void testNewWithWrongArgument() throws Exception {
        final int numberOfTimes = 2;
        final String expected = "used";

        ExpectNewDemo tested = new ExpectNewDemo();
        ExpectNewServiceUser expectNewServiceImplMock = mock(ExpectNewServiceUser.class);
        Service serviceMock = mock(Service.class);

        whenNew(ExpectNewServiceUser.class).withArguments(serviceMock, numberOfTimes).thenReturn(expectNewServiceImplMock);
        when(expectNewServiceImplMock.useService()).thenReturn(expected);

        assertEquals(expected, tested.newWithWrongArguments(serviceMock, numberOfTimes));

        verifyNew(ExpectNewServiceUser.class).withArguments(serviceMock, numberOfTimes);
        /*
 
View Full Code Here

    public void testNewWithArguments() throws Exception {
        final int numberOfTimes = 2;
        final String expected = "used";

        ExpectNewDemo tested = new ExpectNewDemo();
        ExpectNewServiceUser expectNewServiceImplMock = createMock(ExpectNewServiceUser.class);
        Service serviceMock = createMock(Service.class);

        expectNew(ExpectNewServiceUser.class, serviceMock, numberOfTimes).andReturn(expectNewServiceImplMock);
        expect(expectNewServiceImplMock.useService()).andReturn(expected);

        replay(expectNewServiceImplMock, serviceMock, ExpectNewServiceUser.class);

        assertEquals(expected, tested.newWithArguments(serviceMock, numberOfTimes));
View Full Code Here

    public void testNewWithWrongArgument() throws Exception {
        final int numberOfTimes = 2;
        final String expected = "used";

        ExpectNewDemo tested = new ExpectNewDemo();
        ExpectNewServiceUser expectNewServiceImplMock = createMock(ExpectNewServiceUser.class);
        Service serviceMock = createMock(Service.class);

        expectNew(ExpectNewServiceUser.class, serviceMock, numberOfTimes).andReturn(expectNewServiceImplMock);
        expect(expectNewServiceImplMock.useService()).andReturn(expected);

        replay(expectNewServiceImplMock, serviceMock, ExpectNewServiceUser.class);

        try {
            assertEquals(expected, tested.newWithWrongArguments(serviceMock, numberOfTimes));
View Full Code Here

  public void testNewWithArguments() throws Exception {
    final int numberOfTimes = 2;
    final String expected = "used";

    ExpectNewDemo tested = new ExpectNewDemo();
    ExpectNewServiceUser expectNewServiceImplMock = mock(ExpectNewServiceUser.class);
    Service serviceMock = mock(Service.class);

    whenNew(ExpectNewServiceUser.class).withArguments(serviceMock, numberOfTimes).thenReturn(
        expectNewServiceImplMock);
    when(expectNewServiceImplMock.useService()).thenReturn(expected);

    assertEquals(expected, tested.newWithArguments(serviceMock, numberOfTimes));

    verifyNew(ExpectNewServiceUser.class).withArguments(serviceMock, numberOfTimes);
  }
View Full Code Here

  public void testNewWithParameterTypesAndArguments() throws Exception {
    final int numberOfTimes = 2;
    final String expected = "used";

    ExpectNewDemo tested = new ExpectNewDemo();
    ExpectNewServiceUser expectNewServiceImplMock = mock(ExpectNewServiceUser.class);
    Service serviceMock = mock(Service.class);

    whenNew(ExpectNewServiceUser.class).withParameterTypes(Service.class, int.class)
        .withArguments(serviceMock, numberOfTimes).thenReturn(expectNewServiceImplMock);
    when(expectNewServiceImplMock.useService()).thenReturn(expected);

    assertEquals(expected, tested.newWithArguments(serviceMock, numberOfTimes));

    verifyNew(ExpectNewServiceUser.class).withArguments(serviceMock, numberOfTimes);
  }
View Full Code Here

  public void testNewWithConstructorUsingParameterTypesAndArguments() throws Exception {
    final int numberOfTimes = 2;
    final String expected = "used";

    ExpectNewDemo tested = new ExpectNewDemo();
    ExpectNewServiceUser expectNewServiceImplMock = mock(ExpectNewServiceUser.class);
    Service serviceMock = mock(Service.class);

    whenNew(constructor(ExpectNewServiceUser.class, Service.class, int.class)).withArguments(serviceMock,
        numberOfTimes).thenReturn(expectNewServiceImplMock);
    when(expectNewServiceImplMock.useService()).thenReturn(expected);

    assertEquals(expected, tested.newWithArguments(serviceMock, numberOfTimes));

    verifyNew(ExpectNewServiceUser.class).withArguments(serviceMock, numberOfTimes);
  }
View Full Code Here

  public void testReplayAllWithExpectNewWhenTheClassBeingConstructedIsNotPreparedForTest() throws Exception {
    final int numberOfTimes = 2;
    final String expected = "used";

    ExpectNewDemo tested = new ExpectNewDemo();
    ExpectNewServiceUser expectNewServiceImplMock = createMock(ExpectNewServiceUser.class);
    Service serviceMock = createMock(Service.class);

    expectNew(ExpectNewServiceUser.class, serviceMock, numberOfTimes).andReturn(expectNewServiceImplMock);
    expect(expectNewServiceImplMock.useService()).andReturn(expected);

    replayAll();

    assertEquals(expected, tested.newWithArguments(serviceMock, numberOfTimes));
View Full Code Here

  public void testReplayAllWithAdditionalMocks() throws Exception {
    final int numberOfTimes = 2;
    final String expected = "used";

    ExpectNewDemo tested = new ExpectNewDemo();
    ExpectNewServiceUser expectNewServiceImplMock = EasyMock.createMock(ExpectNewServiceUser.class);
    Service serviceMock = createMock(Service.class);

    expectNew(ExpectNewServiceUser.class, serviceMock, numberOfTimes).andReturn(expectNewServiceImplMock);
    expect(expectNewServiceImplMock.useService()).andReturn(expected);

    replayAll(expectNewServiceImplMock);

    assertEquals(expected, tested.newWithArguments(serviceMock, numberOfTimes));
View Full Code Here

TOP

Related Classes of samples.expectnew.ExpectNewServiceUser

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.