# GdUnit generated TestSuite #warning-ignore-all:unused_argument #warning-ignore-all:return_value_discarded class_name ModalResultsTest extends GdUnitTestSuite # TestSuite generated from const __source = 'res://scripts/modal_results.gd' var __game_data = 'res://scripts/game_data.gd' func setup_mocks(): # Arrange var class_mock = mock(__source, CALL_REAL_FUNC) var game_data_mock = mock(__game_data) var cons_mock = game_data_mock.dict.contractors var pois_mock = game_data_mock.dict.pois # Create 4 random contractors from the game data var cons_array_mock = [] while cons_array_mock.size() < 4: var random_index = randi() % cons_mock.size() var random_id = String(random_index + 1).pad_zeros(3) if !cons_array_mock.has(random_id): cons_array_mock.push_back(random_id) # Get 1 random POI from the game data var random_index = randi() % pois_mock.size() var random_id = String(random_index + 1).pad_zeros(3) var poi_single = pois_mock[random_id] var mocks = { "class": class_mock, "game_data": game_data_mock, "cons": cons_mock, "cons_array": cons_array_mock, "pois": pois_mock, "poi_single": poi_single } return mocks; func test_calculate_xp() -> void: # Arrange var mocks = setup_mocks() # Act var result = mocks.class.calculate_xp(mocks.cons_array, mocks.cons, mocks.poi_single) # Assert assert_array(result) # result is an array assert_int(result.size()).is_equal(4) # result has 4 elements for item in result: assert_object(item) # Each item in array is an object assert_int(item.size()).is_equal(2) # Each has 2 properties assert_str(item.con_id) # property 'con_id' is a string assert_int(item.xp_awarded) # property 'xp_awarded' is an int assert_int(item.xp_awarded).is_not_negative() # can't be < 0 func test_calculate_levels() -> void: # Arrange var mocks = setup_mocks() # Act var result = mocks.class.calculate_levels(mocks.cons_array, mocks.cons, mocks.game_data.dict.levels_xp) # Assert assert_array(result) # result is an array assert_int(result.size()).is_equal(4) # result has 4 elements for item in result: assert_object(item) # Each item in array is an object assert_int(item.size()).is_equal(4) # Each has 4 properties assert_str(item.con_id) # property 'con_id' is a string assert_int(item.old_level) assert_int(item.new_level) assert_int(item.level_change)