def test_will_sink(self): tank = TestTank() fish_food = simfish.FishFood() fish_food.turn(tank) self.assertEqual(fish_food, tank.last_item_moved) self.assertEqual(0, tank.total_dx) self.assertEqual(1, tank.total_dy)
def test_will_not_eat_fish_food(self): tank = TestTank() others = [simfish.FishFood()] tank.add_items_with(*others) clockwork_fish = simfish.ClockworkFish() self.assertEqual(others, tank.items_with(clockwork_fish)) clockwork_fish.turn(tank) self.assertEqual(others, tank.items_with(clockwork_fish))
def test_will_eat_fish_food(self): tank = TestTank() others = [simfish.FishFood()] tank.add_items_with(*others) diver_fish = simfish.DiverFish() self.assertEqual(others, tank.items_with(diver_fish)) diver_fish.turn(tank) self.assertEqual(0, len(tank.items_with(diver_fish)))
def test_will_eat_fish_food(self): tank = TestTank() others = [simfish.FishFood()] tank.add_items_with(*others) snail = simfish.Snail() self.assertEqual(others, tank.items_with(snail)) snail.turn(tank) self.assertEqual(0, len(tank.items_with(snail)))
def test_will_only_eat_one_item_per_turn(self): tank = TestTank() others = [simfish.FishFood(), simfish.SunFish(), simfish.DiverFish()] tank.add_items_with(*others) piranha_fish = simfish.PiranhaFish() for count in range(len(others), 0, -1): self.assertEqual(count, len(tank.items_with(piranha_fish))) piranha_fish.turn(tank) self.assertEqual(0, len(tank.items_with(piranha_fish)))
def test_will_only_eat_one_fish_food_per_turn(self): FOOD_COUNT = 10 tank = TestTank() others = [simfish.FishFood()] * FOOD_COUNT tank.add_items_with(*others) diver_fish = simfish.DiverFish() for count in range(FOOD_COUNT, 0, -1): self.assertEqual(count, len(tank.items_with(diver_fish))) diver_fish.turn(tank) self.assertEqual(0, len(tank.items_with(diver_fish)))
def test_can_adjust_energy(self): fish_food = simfish.FishFood(energy=42) self.assertEqual(42, fish_food.energy)
def test_has_correct_default_energy(self): fish_food = simfish.FishFood() self.assertEqual(10, fish_food.energy)
def test_can_create(self): fish_food = simfish.FishFood()