@Test public void willAnnounceItHasFinishedIfPriceGoesAboveMaximum() { sniper.bidAccepted(unbeatableBid); new Verifications() { { listener.sniperFinished(sniper); } }; }
@Test public void willLimitBidToMaximum() throws Exception { sniper.bidAccepted(maximumBid.subtract(new Money(1))); new Verifications() { { auction.bid(maximumBid); } }; }
@Test public void willNotBidPriceGreaterThanMaximum() throws Exception { sniper.bidAccepted(unbeatableBid); new Verifications() { { auction.bid((Money) any); times = 0; } }; }
@Test public void triesToBeatTheLatestHighestBid() throws Exception { final Money expectedBid = beatableBid.add(increment); sniper.bidAccepted(beatableBid); new Verifications() { { auction.bid(expectedBid); } }; }
@Test public void catchesExceptionsAndReportsThemToErrorListener() throws Exception { final AuctionException exception = new AuctionException("test"); new Expectations() { { auction.bid((Money) any); result = exception; } }; sniper.bidAccepted(beatableBid); new Verifications() { { listener.sniperBidFailed(sniper, exception); } }; }