Example #1
0
 public void setUp(String s) {
   UserInput userInput = Mockito.mock(UserInput.class);
   Mockito.when(userInput.readUserInput()).thenReturn("10000").thenReturn("2134").thenReturn(s);
   RichPreparation richPreparation = new RichPreparation(userInput);
   ;
   richPreparation.prepareRichGame();
   richGame = richPreparation.getRichGame();
   player = richGame.getPlayers().get(2);
   rollAction = new RollAction(player, richGame, userInput);
   richGame.getGameMap().getGroundList().get(13).setOwners("S");
   richGame.getGameMap().getGroundList().get(13).setGroundType(2);
 }
Example #2
0
  @Test
  public void shouldMeetNoPropWhenGotoAreaisToolHouseWhenChoosepMascot() {
    UserInput userInput = Mockito.mock(UserInput.class);
    Mockito.when(userInput.readUserInput()).thenReturn("10000").thenReturn("2134").thenReturn("3");
    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().getMascotLeftDays(), is(5));
  }
Example #3
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));
  }
Example #4
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));
 }
Example #5
0
  @Test
  public void shouldMeetNoPropWhenGotoAreaisToolHouseWhenBuy2Props() {
    UserInput userInput = Mockito.mock(UserInput.class);
    Mockito.when(userInput.readUserInput())
        .thenReturn("10000")
        .thenReturn("2134")
        .thenReturn("1")
        .thenReturn("2")
        .thenReturn("2");
    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);

    assertThat(rollAction.getPlayer().getLocaion(), is(28));
    assertThat(rollAction.getPlayer().getPoints(), is(20));
    assertThat(rollAction.getPlayer().getProps()[0], is(1));
    assertThat(rollAction.getPlayer().getProps()[1], is(1));
  }