def test_get_view_only_state(self): # Arrange & Act teama = FootballTeam('teama') teamb = FootballTeam('teamb') ruleset = FootballRuleset().quarter_count(5) \ .quarter_time(300) state = FootballSimulationGameState() \ .gameid(40) \ .team1(teama) \ .team2(teamb) \ .possession(teama) \ .ruleset(ruleset) \ .quarter(3) \ .time(100) \ .get_view_only_state() # Assert self.assertEqual(state.get_gameid(), 40) self.assertEqual(state.get_team1().get_name(), 'teama') self.assertEqual(state.get_team2().get_name(), 'teamb') self.assertEqual(state.get_possession().get_name(), 'teama') self.assertEqual(state.get_nonpossession().get_name(), 'teamb') self.assertFalse(hasattr(state.get_team1(), 'get_controller')) self.assertFalse(hasattr(state.get_team2(), 'get_controller')) self.assertFalse(hasattr(state.get_possession(), 'get_controller')) self.assertFalse(hasattr(state.get_nonpossession(), 'get_controller')) self.assertEqual(state.get_ruleset().get_quarter_count(), 5) self.assertEqual(state.get_quarter(), 3) self.assertEqual(state.get_ruleset().get_quarter_time(), 300) self.assertEqual(state.get_time(), 100) self.assertIsInstance(state, ViewOnlyFootballSimulationGameState)
def test_should_set_time(self): # Arrange & Act state = FootballSimulationGameState() \ .time(138) # Assert self.assertEqual(state.get_time(), 138)
def test_should_change_time_to_zero(self): # Arrange state = FootballSimulationGameState() \ .team1(FootballTeam('teama')) \ .team2(FootballTeam('teamb')) \ .quarter(1) \ .time(40000) # Act state = quarter_changed(state) # Assert self.assertEqual(0, state.get_time()) self.assertEqual(2, state.get_quarter())