summaryrefslogtreecommitdiff
path: root/lib/tests/turns-turn-order.cpp
blob: e0ee431af5dac2193afd3588e580628c1b25fa1c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include "turns-turn-order.h"

#include "turns-participant.h"

#include <catch2/catch_test_macros.hpp>

#include <gio/gio.h>
#include <glib-object.h>

SCENARIO("Creating a turn order", "[lib][object][lifetime]")
{
  GIVEN("A turn order constructed using turns_turn_order_new()")
  {
    g_autoptr(TurnsTurnOrder) instance = turns_turn_order_new();

    THEN("it's participant count is 0")
    {
      REQUIRE(turns_turn_order_get_participant_count(instance) == 0uz);

      auto property_value = decltype(turns_turn_order_get_participant_count(instance)){};
      g_object_get(instance, "participant-count", &property_value, nullptr);

      REQUIRE(property_value == 0);
    }

    THEN("it's running state is false")
    {
      REQUIRE_FALSE(turns_turn_order_get_running(instance));

      auto property_value = decltype(turns_turn_order_get_participant_count(instance)){};
      g_object_get(instance, "running", &property_value, nullptr);

      REQUIRE_FALSE(property_value);
    }

    THEN("it's item count is 0")
    {
      REQUIRE(g_list_model_get_n_items(G_LIST_MODEL(instance)) == 0);
    }

    THEN("it's item type is Turns.Participant")
    {
      REQUIRE(g_list_model_get_item_type(G_LIST_MODEL(instance)) == turns_participant_get_type());
    }

    THEN("it's first item is NULL")
    {
      REQUIRE(g_list_model_get_item(G_LIST_MODEL(instance), 0) == nullptr);
      REQUIRE(g_list_model_get_object(G_LIST_MODEL(instance), 0) == nullptr);
    }
  }
}