Esempio n. 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));
  }
Esempio n. 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));
  }
Esempio n. 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));
  }
Esempio n. 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));
  }
Esempio n. 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));
 }
Esempio n. 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));
  }
Esempio n. 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));
 }