示例#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);
 }
示例#2
0
  public void shouldMeetTheBlock() {

    HashMap props = new HashMap();
    props.put(4, "BLOCK");
    richGame.setProps(props);
    rollAction.executeRoll(6);
    assertThat(rollAction.getPlayer().getLocaion(), is(4));
  }
示例#3
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));
  }
示例#4
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));
 }
示例#5
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));
  }
示例#6
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));
  }
示例#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));
 }
示例#8
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));
  }