Files
Bubberstation/code/modules/unit_tests/operating_table.dm
SkyratBot ea67bfb4d4 [MIRROR] Refactors operating tables to be event driven + QoL + Unit Test [MDB IGNORE] (#15572)
* 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

* Refactors operating tables to be event driven + QoL + Unit Test

* Refactors operating tables to be event driven + QoL + Unit Test

Co-authored-by: vincentiusvin <54709710+vincentiusvin@users.noreply.github.com>
Co-authored-by: Tom <8881105+tf-4@users.noreply.github.com>
2022-08-17 17:41:01 +01: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.")