Package org.jbehave.core.mock

Examples of org.jbehave.core.mock.Mock


  }
 
  public void shouldIgnoreRequestsToDropOrMoveGlyphWhenGameNotRunning() {
        StubHeartbeat heartbeat = new StubHeartbeat();
        PseudoRandomGlyphFactory factory = new PseudoRandomGlyphFactory(42, 7, 13); // T, Z, S, J...
        Mock glyphListener = mock(GlyphListener.class);
        Game game = new Game(factory, heartbeat, 7, 13);
        game.addGlyphListener((GlyphListener) glyphListener);
       
        glyphListener.stubs("reportGlyphMovement").never();
       
        heartbeat.beat();
        game.requestGlyphMovement(GlyphMovement.DOWN);
        game.requestGlyphMovement(GlyphMovement.LEFT);
        game.requestGlyphMovement(GlyphMovement.RIGHT);
View Full Code Here


   
    public void shouldCauseGlyphSegmentsToBeAddedToPitThenCreateNewGlyphWhenGlyphCannotMoveDown() {
        // Given...
       
        StubHeartbeat heartbeat = new StubHeartbeat();
        Mock glyphFactoryMock = mock(GlyphFactory.class);
       
        LivingGlyph firstGlyph = new LivingGlyph(GlyphType.T, new StubCollisionDetector(13), 3);
        LivingGlyph secondGlyph = new LivingGlyph(GlyphType.S, CollisionDetector.NULL, 3);
        Junk junk = new Junk(7, 13);
       
        glyphFactoryMock.expects("nextGlyph").inOrder()
            .with(new Matcher[] {isA(CollisionDetector.class), isA(ListenerSet.class)})
            .will(returnValue(firstGlyph), returnValue(secondGlyph));
        glyphFactoryMock.expects("createJunk").with(isA(ListenerSet.class)).will(returnValue(junk));

        Segments segmentsForTShapeOnFloor = droppedToFloor(GlyphType.T.getSegments(0).movedRight(3), 13);
       
        Game game = new Game((GlyphFactory) glyphFactoryMock, heartbeat, 7, 13);
        game.requestStartGame();
View Full Code Here

   
    public void shouldEndGameAndStopHeartbeatWhenTheNewGlyphOverlapsTheJunk() {
        StubHeartbeat heartbeat = new StubHeartbeat();
        Game game = new Game(new PseudoRandomGlyphFactory(42, 7, 2), heartbeat, 7, 2); // pit is only 2 deep!
      
        Mock gameListener = mock(GameListener.class);
        game.requestStartGame();
       
        gameListener.expects("reportGameStateChanged").with(GameState.RUNNING);
        gameListener.expects("reportGameStateChanged").with(GameState.OVER);
        game.addGameListener((GameListener) gameListener);
       
       
        heartbeat.beat(); // first glyph falls; cannot add second glyph as it overlaps
       
View Full Code Here

        }
    }
   
    public void shouldAddListenersToTheGlyphsThatItCreates() {
        ListenerSet listenerSet = new ListenerSet();
        Mock listener = mock(GlyphListener.class);
        listenerSet.addListener((Listener) listener);
       
        PseudoRandomGlyphFactory factory = new PseudoRandomGlyphFactory(42, 7, 13);
        LivingGlyph glyph = factory.nextGlyph(CollisionDetector.NULL, listenerSet);
        Junk junk = factory.createJunk(listenerSet);
       
        listener.expects("reportGlyphMovement").times(2); // once for junk change, once for glyph change
       
        junk.absorb(glyph);
    }
View Full Code Here

/** set overdraft limit = 0 */
public class AccountDoesNotHaveOverdraftPermission extends GivenUsingMiniMock {

    public void setUp(World world) {
        Mock account = (Mock) world.get("account", mock(Account.class));
        account.stubs("getOverdraftLimit").withNoArguments().will(returnValue(0));
    }
View Full Code Here

        frame.setName(AFrame.FRAME_NAME);
       
        JButton button = new JButton("Press Me!");
        button.setName("a.button");
       
        Mock actionListener = mock(ActionListener.class);
        actionListener.expects("actionPerformed");
       
        button.addActionListener((ActionListener)actionListener);       
       
        frame.getContentPane().add(button);
        frame.pack();
View Full Code Here

    DefaultWindowWrapper wrapper = new DefaultWindowWrapper(AFrame.FRAME_NAME);
   
        try {
            AFrame frame = new AFrame();           

            Mock action = mock(Action.class, "Action");
            action.stubs("isEnabled").will(returnValue(true));
            action.expects("actionPerformed").with(anything());
           
            frame.contentPanel.getActionMap().put(AFrame.ACTION_KEY, (Action) action);
           
            wrapper.pressKeychar(' ');
           
View Full Code Here

                public boolean matches(Object arg) {
                    return ((KeyEvent)arg).getKeyCode() == KeyEvent.VK_SPACE ||
                        ((KeyEvent)arg).getKeyChar() == ' ';
                }
            };
            Mock keyListener = mock(KeyListener.class);
            keyListener.stubs("keyTyped").once().with(spaceKeyEvent);
            keyListener.stubs("keyPressed").once().with(spaceKeyEvent);
            keyListener.expects("keyReleased").once().with(spaceKeyEvent);
            frame.contentPanel.addKeyListener((KeyListener) keyListener);   
           
            wrapper.pressKeychar(' ');
           
            verifyMocks();
View Full Code Here

public class WindowGrabberBehaviour extends UsingMiniMock {
   

    public void shouldGetAnyWindowFromMiniMap() throws TimeoutException {
        checkForHeadless();
        Mock miniMapMock = mock(QueuedMiniMap.class);
       
        WindowGrabber grabber = new WindowGrabber((QueuedMiniMap)miniMapMock);
       
        miniMapMock.expects("get").with(eq("frame.name"), eq(WindowGrabber.DEFAULT_WINDOW_TIMEOUT));
        grabber.getWindow("frame.name");
       
        verifyMocks();
        grabber.dispose();
    }
View Full Code Here

        grabber.dispose();
    }
   
    public void shouldAddNewWindowsToAndRemoveNewWindowsFromMiniMap() {
        checkForHeadless();
        Mock miniMapMock = mock(QueuedMiniMap.class);
        WindowGrabber grabber = new WindowGrabber((QueuedMiniMap)miniMapMock);
       
        JFrame frame = new JFrame();
        frame.setName("frame.name");
        miniMapMock.expects("put").with("frame.name", frame);
        frame.setVisible(true);
               
        miniMapMock.expects("remove").with("frame.name");
        frame.dispose();
        waitForIdle();
        verifyMocks();
        grabber.dispose();
    }
View Full Code Here

TOP

Related Classes of org.jbehave.core.mock.Mock

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.