Files
Bubberstation/code/modules/unit_tests/operating_table.dm
vincentiusvin b011e723c6 Refactors operating tables to be event driven + QoL + Unit Test (#69015)
* Event driven table

* Operating computer fix + loosening of check

* Unit testing

* IT NEEDS TO BE FORCE MOVE YOU GOTTA CLIMB TABLES AAAAH

* Migrated patient to carbon instead of human
Has no real bearing on the experiments tbh

* DNAs can be null apparently

* Simplify replacement code

* Move comments
2022-08-12 10:09:07 -04:00

33 lines
1.7 KiB
Plaintext

/// Make a mob hop on an optable, rest, get up, rest again, and then move to another tile.
/// While the mob is still an active patient, move another mob in too.
/// This is so the replacement code can kick in when the original mob is no longer valid.
/datum/unit_test/operating_table
/datum/unit_test/operating_table/Run()
var/obj/structure/table/optable/table = allocate(/obj/structure/table/optable)
var/mob/living/carbon/human/human = allocate(/mob/living/carbon/human, get_step(table, NORTH))
var/mob/living/carbon/human/replacement_human = allocate(/mob/living/carbon/human, get_step(table, NORTH))
// Resting is a bit more high level than bodypos, gets us nicer coverage.
human.set_resting(new_resting = FALSE, instant = TRUE)
replacement_human.set_resting(new_resting = FALSE, instant = TRUE)
human.forceMove(get_turf(table))
TEST_ASSERT_NULL(table.patient, "Operating table is occupied by a non-resting patient.")
human.set_resting(new_resting = TRUE, instant = TRUE)
TEST_ASSERT_EQUAL(table.patient, human, "Operating table failed to update for a resting patient.")
human.set_resting(new_resting = FALSE, instant = TRUE)
TEST_ASSERT_NULL(table.patient, "Operating table is occupied by a non-resting patient.")
human.set_resting(new_resting = TRUE, instant = TRUE)
TEST_ASSERT_EQUAL(table.patient, human, "Operating table failed to update for a resting patient.")
replacement_human.forceMove(get_turf(table))
replacement_human.set_resting(new_resting = TRUE, instant = TRUE)
TEST_ASSERT_EQUAL(table.patient, human, "Operating table patient unset by another patient jumping in.")
human.forceMove(get_step(get_turf(table), NORTH))
TEST_ASSERT_EQUAL(table.patient, replacement_human, "Operating table failed to find a replacement patient.")