コード例 #1
0
  @Test
  public void winning_bets_contain_all_bets_with_field_winning_strategy_covering_ball_position()
      throws Exception {
    // arrange
    Player p2 = new Player();
    Player p3 = new Player();

    WinningStrategy loses = mock(WinningStrategy.class);
    when(loses.winsOn(anyInt())).thenReturn(false);

    WinningStrategy wins = mock(WinningStrategy.class);
    when(wins.winsOn(anyInt())).thenReturn(true);

    rt.placeBet(p, new Field("A", loses, 36), 1);
    rt.placeBet(p2, new Field("B", wins, 36), 2);
    rt.placeBet(p3, new Field("C", loses, 36), 3);
    // act
    when(rng.generate(30, 40)).thenReturn(33);
    rt.roll();
    timer.moveTime(34000);
    // assert
    Set<Bet> winningBets = new HashSet<Bet>();
    winningBets.add(new Bet(p2, 2));
    assertEquals(winningBets, rt.getWinningBets());
  }
コード例 #2
0
 @Test
 public void system_will_not_pay_out_anything_for_losing_bets() throws Exception {
   WinningStrategy loses = mock(WinningStrategy.class);
   when(loses.winsOn(anyInt())).thenReturn(false);
   rt.placeBet(p, new Field("B", loses, 3), 2);
   when(rng.generate(30, 40)).thenReturn(33);
   rt.roll();
   timer.moveTime(34000);
   verify(walletService, times(1)).adjustBalance(eq(p), anyInt());
 }
コード例 #3
0
 @Test
 public void system_will_automatically_pay_out_winning_bets_with_multiplier_on_field()
     throws Exception {
   WinningStrategy wins = mock(WinningStrategy.class);
   when(wins.winsOn(anyInt())).thenReturn(true);
   rt.placeBet(p, new Field("B", wins, 3), 2);
   when(rng.generate(30, 40)).thenReturn(33);
   rt.roll();
   timer.moveTime(34000);
   verify(walletService).adjustBalance(p, -2);
   verify(walletService).adjustBalance(p, 6);
 }
コード例 #4
0
 @Test
 public void multibets_paid_out_divided_by_number_of_fields() throws Exception {
   WinningStrategy loses = mock(WinningStrategy.class);
   when(loses.winsOn(anyInt())).thenReturn(false);
   WinningStrategy wins = mock(WinningStrategy.class);
   when(wins.winsOn(anyInt())).thenReturn(true);
   rt.placeBet(p, new Field[] {new Field("1", wins, 36), new Field("2", loses, 36)}, 1);
   when(rng.generate(30, 40)).thenReturn(33);
   rt.roll();
   timer.moveTime(34000);
   verify(walletService).adjustBalance(p, -1);
   verify(walletService).adjustBalance(p, 18);
 }