Package org.jbehave.core.mock

Examples of org.jbehave.core.mock.Mock


  UsingClassMock classMock = new UsingClassMock();
 
  public void shouldBeAbleToMockClasses() {
    Object expected = new Object();

    Mock mock = classMock.mock(HashMap.class);
    mock.expects("get").with(anything()).will(returnValue(expected));
   
    Object actual = ((HashMap)mock).get("some key");
    ensureThat(expected, eq(actual));
  }
View Full Code Here


  }
 
  public void shouldBeAbleToStubClasses() {
        Object expected = new Object();

        Mock mock = classMock.mock(HashMap.class);
        mock.stubs("get").will(returnValue(expected));
       
        Object actual = ((HashMap)mock).get("some key");
        ensureThat(expected, eq(actual));
  }
View Full Code Here

      public static final Object INSTANCE = new AClassWithNoConstructorsAtAll();
      private AClassWithNoConstructorsAtAll() {}
    }
   
    public void shouldCreateClassObjectThatCanBeCastToTheCorrectType() {
        Mock mock = ClassMockObject.mockClass(AClass.class, "bar");
        Ensure.that(mock instanceof AClass);
    }
View Full Code Here

        ClassMockObject.mockClass(AClassWithConstructorArgs.class, "bar");
    }   
   
    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

import com.sirenian.hellbound.engine.CollisionDetector;

public class JunkBehaviour extends UsingMiniMock {

  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

   
    verifyMocks();
  }
 
  public void shouldAbsorbSegmentsFromOtherGlyphsAndKillThem() {
    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);
       
    ensureThat(glyph.getSegments(), eq(Segments.EMPTY));
View Full Code Here

    Segments segments1 = new Segments(new Segment[] {new Segment(0, 0)});
    Segments segments2 = new Segments(new Segment[] {new Segment(0, 1)});
   
    Glyph glyph = new Glyph(GlyphType.O, GlyphType.O.getSegments(0));
   
    Mock listener1 = mock(GlyphListener.class);
    Mock listener2 = mock(GlyphListener.class);

    expectGlyphMovement(listener1, GlyphType.O.getSegments(0), GlyphType.O.getSegments(0));
    expectGlyphMovement(listener2, GlyphType.O.getSegments(0), GlyphType.O.getSegments(0));
    expectGlyphMovement(listener1, GlyphType.O.getSegments(0), segments1);   
    expectGlyphMovement(listener2, GlyphType.O.getSegments(0), segments1);   
View Full Code Here

 
  public void shouldAllowListenersToBeAddedAsSet() throws Exception {
   
    Glyph glyph = new Glyph(GlyphType.O, GlyphType.O.getSegments(0));
   
    Mock listener1 = mock(GlyphListener.class);
    Mock listener2 = mock(GlyphListener.class);

    expectGlyphMovement(listener1, GlyphType.O.getSegments(0), GlyphType.O.getSegments(0));
    expectGlyphMovement(listener2, GlyphType.O.getSegments(0), GlyphType.O.getSegments(0));
   
    ListenerSet listenerSet = new ListenerSet();
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

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.