@Test
  public void willAnnounceItHasFinishedIfPriceGoesAboveMaximum() {
    context.checking(
        new Expectations() {
          {
            exactly(1).of(listener).sniperFinished(sniper);
          }
        });

    sniper.bidAccepted(unbeatableBid);
  }
  @Test
  public void willLimitBidToMaximum() throws Exception {
    context.checking(
        new Expectations() {
          {
            exactly(1).of(auction).bid(maximumBid);
          }
        });

    sniper.bidAccepted(maximumBid.subtract(new Money(1)));
  }
  @Test
  public void willNotBidPriceGreaterThanMaximum() throws Exception {
    context.checking(
        new Expectations() {
          {
            ignoring(listener);
            never(auction).bid(with(any(Money.class)));
          }
        });

    sniper.bidAccepted(unbeatableBid);
  }
  @Test
  public void triesToBeatTheLatestHighestBid() throws Exception {
    final Money expectedBid = beatableBid.add(increment);

    context.checking(
        new Expectations() {
          {
            oneOf(auction).bid(expectedBid);
          }
        });

    sniper.bidAccepted(beatableBid);
  }
  @Test
  public void catchesExceptionsAndReportsThemToErrorListener() throws Exception {
    final AuctionException exception = new AuctionException("test");

    context.checking(
        new Expectations() {
          {
            allowing(auction).bid(with(any(Money.class)));
            will(throwException(exception));
            exactly(1).of(listener).sniperBidFailed(sniper, exception);
          }
        });

    sniper.bidAccepted(beatableBid);
  }