コード例 #1
0
  @Test
  public void willLimitBidToMaximum() throws Exception {
    sniper.bidAccepted(maximumBid.subtract(new Money(1)));

    new Verifications() {
      {
        auction.bid(maximumBid);
      }
    };
  }
コード例 #2
0
  @Test
  public void willAnnounceItHasFinishedIfPriceGoesAboveMaximum() {
    sniper.bidAccepted(unbeatableBid);

    new Verifications() {
      {
        listener.sniperFinished(sniper);
      }
    };
  }
コード例 #3
0
  @Test
  public void willAnnounceItHasFinishedIfPriceGoesAboveMaximum() {
    context.checking(
        new Expectations() {
          {
            exactly(1).of(listener).sniperFinished(sniper);
          }
        });

    sniper.bidAccepted(unbeatableBid);
  }
コード例 #4
0
  @Test
  public void willNotBidPriceGreaterThanMaximum() throws Exception {
    sniper.bidAccepted(unbeatableBid);

    new Verifications() {
      {
        auction.bid((Money) any);
        times = 0;
      }
    };
  }
コード例 #5
0
  @Test
  public void willLimitBidToMaximum() throws Exception {
    context.checking(
        new Expectations() {
          {
            exactly(1).of(auction).bid(maximumBid);
          }
        });

    sniper.bidAccepted(maximumBid.subtract(new Money(1)));
  }
コード例 #6
0
  @Test
  public void triesToBeatTheLatestHighestBid() throws Exception {
    final Money expectedBid = beatableBid.add(increment);

    sniper.bidAccepted(beatableBid);

    new Verifications() {
      {
        auction.bid(expectedBid);
      }
    };
  }
コード例 #7
0
  @Test
  public void willNotBidPriceGreaterThanMaximum() throws Exception {
    context.checking(
        new Expectations() {
          {
            ignoring(listener);
            never(auction).bid(with(any(Money.class)));
          }
        });

    sniper.bidAccepted(unbeatableBid);
  }
コード例 #8
0
  @Test
  public void triesToBeatTheLatestHighestBid() throws Exception {
    final Money expectedBid = beatableBid.add(increment);

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

    sniper.bidAccepted(beatableBid);
  }
コード例 #9
0
  @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);
  }
コード例 #10
0
  @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);
      }
    };
  }
コード例 #11
0
ファイル: SnipersTableModel.java プロジェクト: Bisior/goos
 @Override
 public void sniperAdded(AuctionSniper sniper) {
   addSniperSnapshot(sniper.getSnapshot());
   sniper.addSniperListener(new SwingThreadSniperListener(this));
 }