예제 #1
0
  @Test
  public void holdsSnipersInAdditionOrder() {
    AuctionSniper sniper2 = new AuctionSniper(new Item("item 1", 345), null);
    context.checking(
        new Expectations() {
          {
            ignoring(listener);
          }
        });

    model.sniperAdded(sniper);
    model.sniperAdded(sniper2);

    assertEquals(ITEM_ID, cellValue(0, Column.ITEM_IDENTIFIER));
    assertEquals("item 1", cellValue(1, Column.ITEM_IDENTIFIER));
  }
예제 #2
0
  @Test
  public void updatesCorrectRowForSniper() {
    AuctionSniper sniper2 = new AuctionSniper(new Item("item 1", 345), null);
    context.checking(
        new Expectations() {
          {
            allowing(listener).tableChanged(with(anyInsertionEvent()));

            one(listener).tableChanged(with(aChangeInRow(1)));
          }
        });

    model.sniperAdded(sniper);
    model.sniperAdded(sniper2);

    SniperSnapshot winning1 = sniper2.getSnapshot().winning(123);
    model.sniperStateChanged(winning1);

    assertRowMatchesSnapshot(1, winning1);
  }
예제 #3
0
  @Test
  public void acceptsNewSniper() {
    context.checking(
        new Expectations() {
          {
            one(listener).tableChanged(with(anInsertionAtRow(0)));
          }
        });

    model.sniperAdded(sniper);

    assertRowMatchesSnapshot(0, SniperSnapshot.joining(ITEM_ID));
  }
예제 #4
0
  @Test
  public void notifiesListenersWhenAddingASniper() {
    context.checking(
        new Expectations() {
          {
            one(listener).tableChanged(with(anInsertionAtRow(0)));
          }
        });

    assertEquals(0, model.getRowCount());

    model.sniperAdded(sniper);

    assertEquals(1, model.getRowCount());
    assertRowMatchesSnapshot(0, SniperSnapshot.joining(ITEM_ID));
  }
예제 #5
0
  @Test
  public void setsSniperValuesInColumns() {
    SniperSnapshot bidding = sniper.getSnapshot().bidding(555, 666);
    context.checking(
        new Expectations() {
          {
            allowing(listener).tableChanged(with(anyInsertionEvent()));

            one(listener).tableChanged(with(aChangeInRow(0)));
          }
        });

    model.sniperAdded(sniper);
    model.sniperStateChanged(bidding);

    assertRowMatchesSnapshot(0, bidding);
  }