use of samples.newmocking.MyClass in project powermock by powermock.
the class ExpectNewDemoUsingThePrepareEverythingAnnotationTest method testSimpleMultipleNew_withRange_OK.
@Test
public void testSimpleMultipleNew_withRange_OK() throws Exception {
ExpectNewDemo tested = new ExpectNewDemo();
MyClass myClassMock1 = createMock(MyClass.class);
expectNew(MyClass.class).andReturn(myClassMock1).times(1, 5);
replayAll();
tested.simpleMultipleNew();
verifyAll();
}
use of samples.newmocking.MyClass in project powermock by powermock.
the class ExpectNewDemoUsingThePrepareEverythingAnnotationTest method testSimpleMultipleNew_withAtLeastOnce.
@Test
public void testSimpleMultipleNew_withAtLeastOnce() throws Exception {
ExpectNewDemo tested = new ExpectNewDemo();
MyClass myClassMock1 = createMock(MyClass.class);
expectNew(MyClass.class).andReturn(myClassMock1).atLeastOnce();
replayAll();
tested.simpleMultipleNew();
verifyAll();
}
use of samples.newmocking.MyClass in project powermock by powermock.
the class ExpectNewDemoUsingThePrepareEverythingAnnotationTest method testGetMessageWithArgument.
@Test
public void testGetMessageWithArgument() throws Exception {
ExpectNewDemo tested = new ExpectNewDemo();
MyClass myClassMock = createMock(MyClass.class);
expectNew(MyClass.class).andReturn(myClassMock);
String expected = "Hello altered World";
expect(myClassMock.getMessage("test")).andReturn("Hello altered World");
replayAll();
String actual = tested.getMessageWithArgument();
verifyAll();
assertEquals("Expected and actual did not match", expected, actual);
}
use of samples.newmocking.MyClass in project powermock by powermock.
the class ExpectNewDemoUsingThePrepareEverythingAnnotationTest method testPreviousProblemsWithByteCodeManipulation.
@Test
public void testPreviousProblemsWithByteCodeManipulation() throws Exception {
MyClass myClassMock1 = createMock(MyClass.class);
expect(myClassMock1.getMessage()).andReturn("Hello");
expect(myClassMock1.getMessage()).andReturn("World");
replayAll();
assertEquals("Hello", myClassMock1.getMessage());
assertEquals("World", myClassMock1.getMessage());
verifyAll();
}
use of samples.newmocking.MyClass in project powermock by powermock.
the class ExpectNewDemoUsingThePrepareEverythingAnnotationTest method testGetMessage.
@PrepareEverythingForTest
@Test
public void testGetMessage() throws Exception {
ExpectNewDemo tested = new ExpectNewDemo();
MyClass myClassMock = createMock(MyClass.class);
expectNew(MyClass.class).andReturn(myClassMock);
String expected = "Hello altered World";
expect(myClassMock.getMessage()).andReturn("Hello altered World");
replayAll();
String actual = tested.getMessage();
verifyAll();
assertEquals("Expected and actual did not match", expected, actual);
}
Aggregations