From 18795a59e98f2496ab7bb8705f96fa1a4d08ccba Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Mon, 15 Jul 2024 22:36:48 +0200 Subject: domain: extend participant tests --- domain/tests/participant.cpp | 80 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 69 insertions(+), 11 deletions(-) (limited to 'domain/tests') diff --git a/domain/tests/participant.cpp b/domain/tests/participant.cpp index 268b395..6db98f7 100644 --- a/domain/tests/participant.cpp +++ b/domain/tests/participant.cpp @@ -9,7 +9,7 @@ namespace turns::domain::tests { - TEST_CASE("A participant") + TEST_CASE("A freshly constructed participant") { auto constexpr constructed_name = "Vana Thistletop"; auto constexpr constructed_priority = 17; @@ -20,26 +20,84 @@ namespace turns::domain::tests REQUIRE(participant::create(constructed_name, constructed_priority)); } - SECTION("the name can be read") + SECTION("allows access to its name via the associated accessors") { - REQUIRE(instance.get_name() == constructed_name); + SECTION("allowing to get it") + { + REQUIRE(instance.get_name() == constructed_name); + } + + SECTION("allowing to get it via a constant object") + { + auto const & cref = instance; + REQUIRE(cref.get_name() == constructed_name); + } + + SECTION("allowing to set it") + { + instance.set_name("replaced"); + REQUIRE(instance.get_name() == "replaced"); + } } - SECTION("the name can be changed") + SECTION("allows access to its name via the associated property") { - instance.set_name("replaced"); - REQUIRE(instance.get_name() == "replaced"); + SECTION("allowing to get it") + { + REQUIRE(instance.property_name() == constructed_name); + } + + SECTION("allowing to get it via a constant object") + { + auto const & cref = instance; + REQUIRE(cref.property_name() == constructed_name); + } + + SECTION("allowing to set it") + { + instance.property_name() = "replaced"; + REQUIRE(instance.get_name() == "replaced"); + } } - SECTION("the priority can be read") + SECTION("allows access to its priority via the associated accessors") { - REQUIRE(instance.get_priority() == constructed_priority); + SECTION("allowing to get it") + { + REQUIRE(instance.get_priority() == constructed_priority); + } + + SECTION("allowing to get it via a constant object") + { + auto const & cref = instance; + REQUIRE(cref.get_priority() == constructed_priority); + } + + SECTION("allowing to set it") + { + instance.set_priority(3); + REQUIRE(instance.get_priority() == 3); + } } - SECTION("the priority can be changed") + SECTION("allows access to its priority via the associated property") { - instance.set_priority(8); - REQUIRE(instance.get_priority() == 8); + SECTION("allowing to get it") + { + REQUIRE(instance.property_priority() == constructed_priority); + } + + SECTION("allowing to get it via a constant object") + { + auto const & cref = instance; + REQUIRE(cref.property_priority() == constructed_priority); + } + + SECTION("allowing to set it") + { + instance.property_priority() = 4; + REQUIRE(instance.get_priority() == 4); + } } SECTION("can be compared with another participant") -- cgit v1.2.3