Package org.jbehave.core.mock

Examples of org.jbehave.core.mock.Mock.expects()


  public void shouldInitiallyContainNoSegments() {
    Mock glyphListener = mock(GlyphListener.class);
    Junk junk = new Junk(9, 13);
   
    glyphListener.expects("reportGlyphMovement").with(new Matcher[] {eq(GlyphType.JUNK), eq(Segments.EMPTY), eq(Segments.EMPTY)});
    junk.addListener((GlyphListener)glyphListener);
   
    verifyMocks();
  }
 
View Full Code Here


    Mock glyphListener = mock(GlyphListener.class);
        LivingGlyph glyph = new LivingGlyph(GlyphType.O, CollisionDetector.NULL, 4);
        Segments originalSegments = glyph.getSegments();

    Junk junk = new Junk(9, 13);
        glyphListener.expects("reportGlyphMovement").with(new Matcher[] {eq(GlyphType.JUNK), eq(Segments.EMPTY), eq(Segments.EMPTY)});
    glyphListener.expects("reportGlyphMovement").with(new Matcher[] {eq(GlyphType.JUNK), eq(Segments.EMPTY), eq(originalSegments)});

        junk.addListener((GlyphListener)glyphListener);
    junk.absorb(glyph);
       
View Full Code Here

        LivingGlyph glyph = new LivingGlyph(GlyphType.O, CollisionDetector.NULL, 4);
        Segments originalSegments = glyph.getSegments();

    Junk junk = new Junk(9, 13);
        glyphListener.expects("reportGlyphMovement").with(new Matcher[] {eq(GlyphType.JUNK), eq(Segments.EMPTY), eq(Segments.EMPTY)});
    glyphListener.expects("reportGlyphMovement").with(new Matcher[] {eq(GlyphType.JUNK), eq(Segments.EMPTY), eq(originalSegments)});

        junk.addListener((GlyphListener)glyphListener);
    junk.absorb(glyph);
       
    ensureThat(glyph.getSegments(), eq(Segments.EMPTY));
View Full Code Here

  public void shouldPerformCommandOnAddedListeners() throws Exception {

    ListenerSet list = new ListenerSet();

    Mock listener = mock(WibblableListener.class);
    listener.expects("wibble");

    list.addListener((Listener) listener);

    list.notifyListeners(new WibblyNotifier());
View Full Code Here

 
  public void shouldNotNotifyRemovedListeners() throws Exception {
    ListenerSet list = new ListenerSet();

    Mock listener = mock(WibblableListener.class);
    listener.expects("wibble").never();
   
    list.addListener((Listener) listener);
    list.removeListener((Listener) listener);

    list.notifyListeners(new WibblyNotifier());
View Full Code Here

    public void shouldPassCaughtExceptionsToHandler() throws Exception {
        final QueuedObjectHolder exceptionHolder = new QueuedObjectHolder();
        final RuntimeException exception = new RuntimeException("An exception occurred");
       
        Mock handler = mock(ErrorHandler.class);
        handler.expects("handle").will(new InvocationHandler() {
            public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                exceptionHolder.set(args[0]);
                return null;
            }
        });
View Full Code Here

    }
   
    public void shouldSucceedWhenMethodCalledWithExpectedArgument() {
        Mock mock = MiniMockObject.mock(Foo.class, "foo");
       
        mock.expects("doSomething").with(eq("A"));
       
        ((Foo)mock).doSomething("A");
       
        try {
            mock.verify();
View Full Code Here

    }
   
    public void shouldFailOnVerifyWhenMethodCalledWithExpectedThenUnexpectedArgument() {
        Mock mock = MiniMockObject.mock(Foo.class, "foo");
       
        mock.expects("doSomething").with(eq("A"));
       
        ((Foo)mock).doSomething("A");
       
        boolean skippedThis = true;
       
View Full Code Here

        return System.getProperty("line.separator");
    }

    public void shouldSucceedOnVerifyWhenMethodCalledWithExpectedArgumentThenOtherMethodCalled() {
        Mock mock = MiniMockObject.mock(Foo.class, "foo");
        mock.expects("doSomething");
       
        ((Foo)mock).doSomething();
        ((Foo)mock).doSomethingElse();
       
        mock.verify();
View Full Code Here

  public void shouldContainTheButtonToStartTheGame() throws Exception {

    WindowWrapper wrapper = new DefaultWindowWrapper("TestFrame");
   
    Mock gameStarter = mock(GameRequestListener.class);
    gameStarter.expects("requestStartGame");
   
    FrontPanel panel = new FrontPanel((GameRequestListener)gameStarter);

    JFrame frame = new JFrame();
    frame.setName("TestFrame");
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.