mirror of
https://gitlab.com/open-fpsz/open-fpsz.git
synced 2026-01-19 19:44:46 +00:00
59 lines
2.1 KiB
GDScript
59 lines
2.1 KiB
GDScript
# This file is part of open-fpsz.
|
|
#
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
extends GutTest
|
|
|
|
var PLAYER : PackedScene = preload("res://entities/player/player.tscn")
|
|
var SCOREBOARD : PackedScene = preload("res://interfaces/scoreboard/scoreboard.tscn")
|
|
|
|
var _subject : Scoreboard
|
|
|
|
func before_each() -> void:
|
|
_subject = SCOREBOARD.instantiate()
|
|
add_child(_subject)
|
|
|
|
func after_each() -> void:
|
|
_subject.free()
|
|
|
|
func test_that_new_scoreboard_is_empty() -> void:
|
|
assert_eq(_subject._entries, {})
|
|
|
|
func test_that_added_entry_is_added_correctly() -> void:
|
|
var player : Player = PLAYER.instantiate()
|
|
player.nickname = "test_nickname"
|
|
_subject.add_player(player)
|
|
var entries : Array = _subject._entries.values()
|
|
assert_eq(1, entries.size())
|
|
var tested_entry : Scoreboard.ScoreboardEntry = entries[0]
|
|
assert_eq("test_nickname", tested_entry.nickname)
|
|
assert_eq(0, tested_entry.kills)
|
|
assert_eq(0, tested_entry.score)
|
|
player.free()
|
|
|
|
func test_that_scores_are_added_correctly() -> void:
|
|
var player : Player = PLAYER.instantiate()
|
|
_subject.add_player(player)
|
|
_subject.add_score_to_player(player, 10)
|
|
var tested_entry : Scoreboard.ScoreboardEntry = _subject._entries.values()[0]
|
|
assert_eq(10, tested_entry.score)
|
|
player.free()
|
|
|
|
func test_that_kill_counts_are_incremented_correctly() -> void:
|
|
var player : Player = PLAYER.instantiate()
|
|
_subject.add_player(player)
|
|
_subject.increment_kill_count(player)
|
|
var tested_entry : Scoreboard.ScoreboardEntry = _subject._entries.values()[0]
|
|
assert_eq(1, tested_entry.kills)
|
|
player.free()
|