コード例 #1
0
  @Test
  public void shouldMeetTheBomb() {

    HashMap props = new HashMap();
    props.put(4, "BOMB");
    richGame.setProps(props);
    rollAction.executeRoll(4);
    assertThat(rollAction.getPlayer().getLocaion(), is(14));
    assertThat(rollAction.getPlayer().getHospitalOrPrison(), is(1));
    assertThat(rollAction.getPlayer().getLeftDays(), is(3));
  }
コード例 #2
0
  @Test
  public void shouldStopInASpace() {
    setUp("y");
    HashMap props = new HashMap();

    rollAction.executeRoll(4);
    assertThat(rollAction.getPlayer().getLocaion(), is(4));
    assertThat(rollAction.getPlayer().getFunds(), is(9800));
    assertThat(rollAction.getRichGame().getGameMap().getGroundList().get(4).getOwners(), is("S"));
    assertThat(rollAction.getPlayer().getLandedProperty()[0], is(1));
  }
コード例 #3
0
  public void shouldMeetTheBlock() {

    HashMap props = new HashMap();
    props.put(4, "BLOCK");
    richGame.setProps(props);
    rollAction.executeRoll(6);
    assertThat(rollAction.getPlayer().getLocaion(), is(4));
  }
コード例 #4
0
  @Test
  public void shouldMeetNoPropWhenGotoAreaisToolHouseWhenChooseFunds() {
    UserInput userInput = Mockito.mock(UserInput.class);
    Mockito.when(userInput.readUserInput()).thenReturn("10000").thenReturn("2134").thenReturn("1");
    RichPreparation richPreparation = new RichPreparation(userInput);
    richPreparation.prepareRichGame();
    richGame = richPreparation.getRichGame();
    player = richGame.getPlayers().get(2);
    player.setLocaion(34);
    player.setPoints(100);
    rollAction = new RollAction(player, richGame, userInput);
    rollAction.executeRoll(1);

    assertThat(rollAction.getPlayer().getLocaion(), is(35));
    assertThat(rollAction.getPlayer().getPoints(), is(100));
    assertThat(rollAction.getPlayer().getFunds(), is(12000));
  }
コード例 #5
0
 @Test
 public void shouldMeetTheBlockAndNotBuyArea() {
   setUp("n");
   HashMap props = new HashMap();
   props.put(2, "BLOCK");
   richGame.setProps(props);
   rollAction.executeRoll(3);
   assertThat(rollAction.getPlayer().getLocaion(), is(2));
   assertFalse(rollAction.getRichGame().getProps().containsValue(2));
   assertThat(player.getFunds(), is(10000));
 }
コード例 #6
0
  @Test
  public void shouldMeetNoPropWhenGotoAreaisAnotherPlayer() {
    UserInput userInput = Mockito.mock(UserInput.class);
    Mockito.when(userInput.readUserInput()).thenReturn("10000").thenReturn("2134");
    RichPreparation richPreparation = new RichPreparation(userInput);
    ;
    richPreparation.prepareRichGame();
    richGame = richPreparation.getRichGame();
    player = richGame.getPlayers().get(2);
    player.setLocaion(41);
    rollAction = new RollAction(player, richGame, userInput);
    richGame.getGameMap().getGroundList().get(44).setOwners("J");
    richGame.getGameMap().getGroundList().get(44).setGroundType(1);
    ;
    HashMap props = new HashMap();

    rollAction.executeRoll(3);
    assertThat(rollAction.getPlayer().getLocaion(), is(44));
    assertThat(rollAction.getPlayer().getFunds(), is(9700));
  }
コード例 #7
0
 @Test
 public void shouldMeetNoPropWhenGotoAreaisGiftHouse() {
   UserInput userInput = Mockito.mock(UserInput.class);
   Mockito.when(userInput.readUserInput())
       .thenReturn("10000")
       .thenReturn("2134")
       .thenReturn("S")
       .thenReturn("Q")
       .thenReturn("F");
   RichPreparation richPreparation = new RichPreparation(userInput);
   ;
   richPreparation.prepareRichGame();
   richGame = richPreparation.getRichGame();
   player = richGame.getPlayers().get(2);
   player.setLocaion(26);
   player.setPoints(100);
   rollAction = new RollAction(player, richGame, userInput);
   rollAction.executeRoll(2);
   Mockito.verify(userInput, Mockito.times(2)).printMessage("prop type should be 1 or 2 or 3");
   assertThat(rollAction.getPlayer().getLocaion(), is(28));
   assertThat(rollAction.getPlayer().getPoints(), is(100));
 }