Examples of expects()


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

    }   
   
    public void shouldBeAbleToUseMockedClassesJustLikeOtherMocks() {
      Object expected = new Object();
      Mock mock = ClassMockObject.mockClass(HashMap.class, "hashMap");
    mock.expects("get").with("a key").will(returnValue(expected));
   
    Object actual = ((HashMap)mock).get("a key");
    ensureThat(expected, eq(actual));
    }
View Full Code Here

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

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

    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

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

        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

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

  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

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

 
  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

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

    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

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

    }
   
    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

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

    }
   
    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

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

        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
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.