Esempio n. 1
0
  @Before
  public void setup() {
    Fixtures.deleteAll();

    Fixtures.load("data.yml");

    duckRunnerGame = Game.find("byName", "Duck Runner").first();
    parkingLotGame = Game.find("byName", "Parking Lot").first();
  }
Esempio n. 2
0
  @Test
  public void evenlyRandomlySelectsGame() {
    boolean duckRunnerGameFetched = false;
    boolean parkingLotGameFetched = false;

    // two games should be fetched by random chance

    for (int i = 0; i < 25; i++) {
      String aRandomGameName = Game.random().name;
      assertNotNull(aRandomGameName);

      if (aRandomGameName == duckRunnerGame.name) {
        duckRunnerGameFetched = true;
      } else if (aRandomGameName == parkingLotGame.name) {
        parkingLotGameFetched = true;
      } else {
        fail("should select existing games only...");
      }
    }

    if (!duckRunnerGameFetched) {
      fail("duck runner game should've been selected...");
    }

    if (!parkingLotGameFetched) {
      fail("parking lot game should've been selected...");
    }
  }
Esempio n. 3
0
 @Test
 public void evenlyRandomlySelectGameButTheSelectedGame() {
   String selectedGameName = Game.randomBut(parkingLotGame.name).name;
   assertEquals("duck runner game should've been selected...", "Duck Runner", selectedGameName);
 }