Package org.jbehave.core.mock

Examples of org.jbehave.core.mock.Mock


/**
* set balance = -50
*/
public class AccountIsOverdrawn extends GivenUsingMiniMock {
    public void setUp(World world) {
        Mock accountMock = (Mock)world.get("account", mock(Account.class));
        accountMock.stubs("getBalance").will(returnValue(-50));
    }
View Full Code Here


/** set overdraft limit = 0 */
public class AccountDoesNotHaveOverdraftFacility 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

/** set balance = 50 */
public class AccountIsInCredit extends GivenUsingMiniMock {
   
    public void setUp(World world) {
        Mock account = (Mock) world.get("account", mock(Account.class));
        account.stubs("getBalance").withNoArguments().will(returnValue(50));
    }
View Full Code Here

/** set balance = 50 */
public class AccountHasPositiveBalance extends GivenUsingMiniMock {
   
    public void setUp(World world) {
        Mock account = (Mock) world.get("account", mock(Account.class));
        account.stubs("getBalance").withNoArguments().will(returnValue(50));
    }
View Full Code Here

public class ThreadedEngineQueueBehaviour extends ThreadedQueueBehaviour {
   
    public void shouldPassAlongGameRequests() throws Exception {
       
        Mock listener = mock(GameRequestListener.class);
        listener.expects("requestGlyphMovement").with(GlyphMovement.DROP);
       
        final ThreadedEngineQueue queue = new ThreadedEngineQueue();
        queue.setGameRequestDelegate((GameRequestListener) listener);
        queue.requestStartGame();
        queue.requestGlyphMovement(GlyphMovement.DROP);
View Full Code Here

*/
public class AcceleratingHeartbeatBehaviour extends UsingMiniMock {

 
  public void shouldBeatAfterElapsedTime() throws Exception {
    Mock heartbeatListener = mock(HeartbeatListener.class);
    heartbeatListener.expects("beat").atLeastOnce();
   
    AcceleratingHeartbeat heartbeat = new AcceleratingHeartbeat();
    heartbeat.addListener((HeartbeatListener)heartbeatListener);
    heartbeat.start(3);
 
View Full Code Here

    public void shouldMoveImmediatelyToNextWaitingPhaseWhenSkippingABeat() {
        // Nor this.
    }
 
  public void shouldNotBeatAfterBeingStopped() throws Exception {
    Mock heartbeatListener = mock(HeartbeatListener.class);
    heartbeatListener.expects("beat").never();
   
    AcceleratingHeartbeat heartbeat = new AcceleratingHeartbeat();
    heartbeat.start(3);
 
    heartbeat.stop();
View Full Code Here

public class GameBehaviour extends UsingClassMock {

    public void shouldMoveGlyphLowerOnHeartbeat() {
        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);
       
        Segments initialSegments = GlyphType.T.getSegments(0).movedRight(3);
       
        glyphListener.stubs("reportGlyphMovement").with(eq(GlyphType.JUNK), anything(), anything());
        glyphListener.expects("reportGlyphMovement").with(eq(GlyphType.T), anything(), eq(initialSegments));
        glyphListener.expects("reportGlyphMovement").with(eq(GlyphType.T), eq(initialSegments), eq(initialSegments.movedDown()));
        game.requestStartGame();
        heartbeat.beat();
       
        verifyMocks();
    }
View Full Code Here

   
  public void shouldRunOnRequestStartAndStartHeartbeatAndInformListeners() throws Exception {
   
      StubHeartbeat heartbeat = new StubHeartbeat();

        Mock gameListener = mock(GameListener.class);
    gameListener.expects("reportGameStateChanged").once().with(GameState.READY);
    gameListener.expects("reportGameStateChanged").once().with(GameState.RUNNING);
   
        Game game = new Game(new PseudoRandomGlyphFactory(7, 13), heartbeat, 7, 13);
   
    game.addGameListener((GameListener)gameListener);
    game.requestStartGame();
View Full Code Here

  }
 
  public void shouldCreateANewGlyphWithListenersToItWhenGameIsStarted() throws Exception {
    Heartbeat heartbeat = new StubHeartbeat();
   
    Mock glyphFactoryMock = mock(GlyphFactory.class);
    Mock glyphListener = mock(GlyphListener.class);
   
    glyphFactoryMock.expects("nextGlyph")
            .with(new Matcher[] {isA(CollisionDetector.class), isA(ListenerSet.class)})
                .will(returnValue(new LivingGlyph(GlyphType.T, CollisionDetector.NULL, 4)));
   
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.