Package samples.expectnew

Examples of samples.expectnew.ExpectNewDemo.simpleMultipleNew()


        expectNew(MyClass.class).andReturn(myClassMock1).times(3);

        replay(myClassMock1, MyClass.class);

        tested.simpleMultipleNew();

        verify(myClassMock1, MyClass.class);
    }

    @Test
View Full Code Here


        expectNew(MyClass.class).andReturn(myClassMock1).times(4);

        replay(myClassMock1, MyClass.class);

        tested.simpleMultipleNew();

        try {
            verify(myClassMock1, MyClass.class);
            fail("Should throw AssertionError.");
        } catch (AssertionError e) {
View Full Code Here

        expectNew(MyClass.class).andReturn(myClassMock1).times(2);

        replay(myClassMock1, MyClass.class);
        try {
            tested.simpleMultipleNew();
            fail("Should throw AssertionError.");
        } catch (AssertionError e) {
            assertEquals("\n  Unexpected constructor call samples.newmocking.MyClass():"
                    + "\n    samples.newmocking.MyClass(): expected: 2, actual: 3", e.getMessage());
        }
View Full Code Here

        MyClass myClassMock1 = createMock(MyClass.class);

        expectNew(MyClass.class).andReturn(myClassMock1).atLeastOnce();

        replay(myClassMock1, MyClass.class);
        tested.simpleMultipleNew();
        verify(myClassMock1, MyClass.class);
    }

    @Test
    public void testSimpleMultipleNew_withRange_lowerBoundLessThan0() throws Exception {
View Full Code Here

        expectNew(MyClass.class).andReturn(myClassMock1).times(1, 5);

        replay(myClassMock1, MyClass.class);

        tested.simpleMultipleNew();

        verify(myClassMock1, MyClass.class);
    }

    @Test
View Full Code Here

        expectNew(MyClass.class).andReturn(myClassMock1).anyTimes();

        replay(myClassMock1, MyClass.class);

        tested.simpleMultipleNew();

        verify(myClassMock1, MyClass.class);
    }

    @Test
View Full Code Here

        expectNew(MyClass.class).andReturn(myClassMock1).times(5, 7);

        replay(myClassMock1, MyClass.class);

        tested.simpleMultipleNew();

        try {
            verify(myClassMock1, MyClass.class);
            fail("Should throw AssertionError.");
        } catch (AssertionError e) {
View Full Code Here

        MyClass myClassMock = mock(MyClass.class);

        whenNew(MyClass.class).withNoArguments().thenReturn(myClassMock);

        tested.simpleMultipleNew();

        verifyNew(MyClass.class, times(3)).withNoArguments();
    }

    @Test
View Full Code Here

        expectNew(MyClass.class).andReturn(myClassMock1).times(3);

        replayAll();

        tested.simpleMultipleNew();

        verifyAll();
    }

    @Test
View Full Code Here

        expectNew(MyClass.class).andReturn(myClassMock1).times(4);

        replayAll();

        tested.simpleMultipleNew();

        try {
            verifyAll();
            fail("Should throw AssertionError.");
        } catch (AssertionError e) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.