Add test for checking validating different notifications keys

This commit is contained in:
Dawid Drozd 2017-08-25 11:38:13 +02:00
parent c4b9fcd3de
commit 257cc90c86

View File

@ -146,3 +146,38 @@ TEST_CASE("eventbus/EventBus type conversion", "Check for type conversion")
REQUIRE(ex.calledEvent1 == 1);
REQUIRE(ex.calledEvent2 == 1);//Lookout for std::bind!
}
TEST_CASE("eventbus/Different notification", "Valid check notification")
{
Dexode::EventBus bus;
Dexode::Event<int> notification{"simple1"};
Dexode::Event<int> notification2{"simple2"};
bool called1 = false;
bool called2 = false;
bus.listen(notification, [&called1](int value)
{
called1 = true;
REQUIRE(value == 1);
});
bus.listen(notification2, [&called2](int value)
{
called2 = true;
REQUIRE(value == 2);
});
REQUIRE(called1 == false);
bus.notify(notification, 1);
REQUIRE(called1 == true);
REQUIRE(called2 == false);
called1 = false;
bus.notify(notification2, 2);
REQUIRE(called1 == false);
REQUIRE(called2 == true);
}