TinyAdventure/tests/scenes/game_tests.gd

29 lines
1.0 KiB
GDScript
Raw Normal View History

# GdUnit generated TestSuite
class_name GameTest
extends GdUnitTestSuite
@warning_ignore('unused_parameter')
@warning_ignore('return_value_discarded')
# TestSuite generated from
const __source = 'res://scenes/game.gd'
var game_scene:PackedScene = preload("res://scenes/game.tscn")
var _unittest_game_profile_path:String = "user://game_profiles/unittest"
func test_save_game() -> void:
var game:Game = game_scene.instantiate()
add_child(game)
var floor_resource = load("res://data/structures/floor.tres")
game.build_system.build_structure(floor_resource, Transform3D.IDENTITY)
game.build_system.build_structure(floor_resource, Transform3D.IDENTITY.translated(Vector3(1, 0, 0)))
game.save_game(_unittest_game_profile_path)
var save_data:SaveGameResource = load(_unittest_game_profile_path + "/savegame.tres") as SaveGameResource
assert_that(len(save_data.built_structures.keys())).is_equal(1)
assert_that(save_data.built_structures.has(floor_resource)).is_equal(true)
assert_that(len(save_data.built_structures[floor_resource])).is_equal(2)