34 lines
1.2 KiB
GDScript
34 lines
1.2 KiB
GDScript
# 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://unittest/game_tests/"
|
|
|
|
func test_save_game() -> void:
|
|
# Output folder must exist
|
|
DirAccess.make_dir_recursive_absolute(_unittest_game_profile_path)
|
|
|
|
# Create game
|
|
var game:Game = game_scene.instantiate()
|
|
add_child(game)
|
|
|
|
# Build stuff
|
|
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)))
|
|
|
|
# Save
|
|
game.save_game(_unittest_game_profile_path)
|
|
|
|
# Load and check whether the built stuff can be found.
|
|
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)
|