SObjectizer  5.5
Namespaces | Classes | Enumerations | Functions
so_5::experimental::testing::v1 Namespace Reference

Namespaces

 details
 
 impl
 

Classes

class  scenario_proxy_t
 A special wrapper around scenario object. More...
 
class  scenario_result_t
 The result of run of testing scenario. More...
 
class  step_definition_proxy_t
 A special object that should be used for definition of a step of a testing scenario. More...
 
class  testing_env_t
 A special testing environment that should be used for testing of agents. More...
 

Enumerations

enum  scenario_status_t { scenario_status_t::not_started, scenario_status_t::in_progress, scenario_status_t::completed, scenario_status_t::timed_out }
 Status of testing scenario. More...
 

Functions

SO_5_NODISCARD scenario_result_t completed ()
 Create a value that means that scenario completed successfuly. More...
 
template<typename Msg_Type >
details::trigger_source_t< details::incident_status_t::handledreacts_to ()
 Define a trigger that activates when an agent receives and handles a message from the direct mbox. More...
 
template<typename Msg_Type >
details::trigger_source_t< details::incident_status_t::handledreacts_to (const so_5::mbox_t &mbox)
 Define a trigger that activates when an agent receives and handles a message from the specific mbox. More...
 
details::store_agent_state_name_t store_state_name (std::string tag)
 Create a special marker for a trigger for storing agent's state name inside scenario. More...
 
template<typename Msg_Type >
details::trigger_source_t< details::incident_status_t::ignoredignores ()
 Define a trigger that activates when an agent rejects a message from the direct mbox. More...
 
template<typename Msg_Type >
details::trigger_source_t< details::incident_status_t::ignoredignores (const so_5::mbox_t &mbox)
 Define a trigger that activates when an agent rejects a message from the direct mbox. More...
 
details::constraint_unique_ptr_t not_before (std::chrono::steady_clock::duration pause)
 Create a constraint not-before. More...
 
details::constraint_unique_ptr_t not_after (std::chrono::steady_clock::duration pause)
 Create a constraint not-after. More...
 

Enumeration Type Documentation

◆ scenario_status_t

Status of testing scenario.

This enumeration is used by testing scenario itself and by scenario_result_t type.

Since
v.5.5.24
Enumerator
not_started 

Testing scenario is not started yet. New step can be added when scenario is in state.

in_progress 

Testing scenario is started but not finished yet. New steps can't be added.

completed 

Testing scenario is successfuly completed.

timed_out 

Testing scenario is not working any more, but it is not completed becase there is no more time to run the scenario.

Function Documentation

◆ completed()

SO_5_NODISCARD scenario_result_t so_5::experimental::testing::v1::completed ( )
inline

Create a value that means that scenario completed successfuly.

Usage example:

TEST_CASE("some_case") {
using namespace so_5::experimental::testing;
testing_env_t env;
...
env.scenario().run_for(std::chrono::milliseconds(500));
REQUIRE(completed() == env.scenario().result());
}
Since
v.5.5.24

◆ ignores() [1/2]

template<typename Msg_Type >
details::trigger_source_t< details::incident_status_t::ignored > so_5::experimental::testing::v1::ignores ( )

Define a trigger that activates when an agent rejects a message from the direct mbox.

Usage example:

...
env.scenario().define_step("my_step")
.when(some_agent & ignores<some_message>());
Attention
It is necessary that agent should be subscribed to that message but ignores it in the current state. If an agent is not subscribed to a message then the message can be simply skipped inside a call to send() function. It means that there won't be delivery of message at all.
Since
v.5.5.24

◆ ignores() [2/2]

template<typename Msg_Type >
details::trigger_source_t< details::incident_status_t::ignored > so_5::experimental::testing::v1::ignores ( const so_5::mbox_t mbox)

Define a trigger that activates when an agent rejects a message from the direct mbox.

Usage example:

...
env.scenario().define_step("my_step")
.when(some_agent & ignores<some_message>(some_mbox));
Attention
It is necessary that agent should be subscribed to that message but ignores it in the current state. If an agent is not subscribed to a message then the message can be simply skipped inside a call to send() function. It means that there won't be delivery of message at all.
Since
v.5.5.24

◆ not_after()

details::constraint_unique_ptr_t so_5::experimental::testing::v1::not_after ( std::chrono::steady_clock::duration  pause)
inline

Create a constraint not-after.

That constraint is fulfilled if an event is happened before a specified pause. Time is calculated from moment of preactivation of a scenario's step.

Usage example:

env.scenario().define_step("my_step")
.constraints(not_after(std::chrono::milliseconds(50)))
.when(some_agent & reacts_to<some_message>());

In that case step won't be activated if agent receives a message after, for example, 55ms.

Note
If not_after() is used with not_before() then the correctness of those constraints is not checked.
Since
v.5.5.24

◆ not_before()

details::constraint_unique_ptr_t so_5::experimental::testing::v1::not_before ( std::chrono::steady_clock::duration  pause)
inline

Create a constraint not-before.

That constraint is fulfilled if an event is happened after a specified pause. Time is calculated from moment of preactivation of a scenario's step.

Usage example:

env.scenario().define_step("my_step")
.constraints(not_before(std::chrono::milliseconds(50)))
.when(some_agent & reacts_to<some_message>());

In that case step won't be activated if agent receives a message after, for example, 15ms.

Note
If not_before() is used with not_after() then the correctness of those constraints is not checked.
Since
v.5.5.24

◆ reacts_to() [1/2]

template<typename Msg_Type >
details::trigger_source_t< details::incident_status_t::handled > so_5::experimental::testing::v1::reacts_to ( )

Define a trigger that activates when an agent receives and handles a message from the direct mbox.

Usage example:

...
env.scenario().define_step("my_step")
.when(some_agent & reacts_to<some_message>());
Since
v.5.5.24

◆ reacts_to() [2/2]

template<typename Msg_Type >
details::trigger_source_t< details::incident_status_t::handled > so_5::experimental::testing::v1::reacts_to ( const so_5::mbox_t mbox)

Define a trigger that activates when an agent receives and handles a message from the specific mbox.

Usage example:

...
env.scenario().define_step("my_step")
.when(some_agent & reacts_to<some_message>(some_mbox));
Since
v.5.5.24

◆ store_state_name()

details::store_agent_state_name_t so_5::experimental::testing::v1::store_state_name ( std::string  tag)
inline

Create a special marker for a trigger for storing agent's state name inside scenario.

Usage example:

...
env.scenario().define_step("my_step")
.when(some_agent & reacts_to<some_message>() & store_agent_name("my_agent"));
...
env.scenario().run_for(std::chrono::seconds(1));
REQUIRE(completed() == env.scenario().result());
REQUIRE("some_state" == env.scenario().stored_state_name("my_step", "my_agent"));
Since
v.5.5.24