|
@@ -12,12 +12,15 @@
|
|
#include <ls-std/ls-std-core.hpp>
|
|
#include <ls-std/ls-std-core.hpp>
|
|
#include <ls-std/ls-std-event.hpp>
|
|
#include <ls-std/ls-std-event.hpp>
|
|
|
|
|
|
-using namespace ls::std::core;
|
|
|
|
-using namespace ls::std::core::interface_type;
|
|
|
|
-using namespace ls::std::event;
|
|
|
|
-using namespace ::std;
|
|
|
|
-using namespace test::event;
|
|
|
|
-using namespace ::testing;
|
|
|
|
|
|
+using ls::std::core::Class;
|
|
|
|
+using ls::std::core::IllegalArgumentException;
|
|
|
|
+using ls::std::core::interface_type::IListener;
|
|
|
|
+using ls::std::event::Narrator;
|
|
|
|
+using std::make_shared;
|
|
|
|
+using std::shared_ptr;
|
|
|
|
+using test::event::Colour;
|
|
|
|
+using test::event::TestDataMercedesCar;
|
|
|
|
+using testing::Test;
|
|
|
|
|
|
namespace
|
|
namespace
|
|
{
|
|
{
|
|
@@ -54,9 +57,9 @@ namespace
|
|
this->createCars();
|
|
this->createCars();
|
|
Narrator paintingMachine{};
|
|
Narrator paintingMachine{};
|
|
|
|
|
|
- ASSERT_TRUE(paintingMachine.addListener(dynamic_pointer_cast<IListener>(this->mercedes1)));
|
|
|
|
- ASSERT_TRUE(paintingMachine.addListener(dynamic_pointer_cast<IListener>(this->mercedes2)));
|
|
|
|
- ASSERT_TRUE(paintingMachine.addListener(dynamic_pointer_cast<IListener>(this->mercedes3)));
|
|
|
|
|
|
+ ASSERT_TRUE(paintingMachine.addListener(this->mercedes1));
|
|
|
|
+ ASSERT_TRUE(paintingMachine.addListener(this->mercedes2));
|
|
|
|
+ ASSERT_TRUE(paintingMachine.addListener(this->mercedes3));
|
|
}
|
|
}
|
|
|
|
|
|
TEST_F(NarratorTest, addListener_listener_already_exists)
|
|
TEST_F(NarratorTest, addListener_listener_already_exists)
|
|
@@ -64,8 +67,8 @@ namespace
|
|
this->createCars();
|
|
this->createCars();
|
|
Narrator paintingMachine{};
|
|
Narrator paintingMachine{};
|
|
|
|
|
|
- ASSERT_TRUE(paintingMachine.addListener(dynamic_pointer_cast<IListener>(this->mercedes1)));
|
|
|
|
- ASSERT_FALSE(paintingMachine.addListener(dynamic_pointer_cast<IListener>(this->mercedes1)));
|
|
|
|
|
|
+ ASSERT_TRUE(paintingMachine.addListener(this->mercedes1));
|
|
|
|
+ ASSERT_FALSE(paintingMachine.addListener(this->mercedes1));
|
|
}
|
|
}
|
|
|
|
|
|
TEST_F(NarratorTest, addListener_no_reference)
|
|
TEST_F(NarratorTest, addListener_no_reference)
|
|
@@ -89,9 +92,9 @@ namespace
|
|
{
|
|
{
|
|
this->createCars();
|
|
this->createCars();
|
|
Narrator paintingMachine{};
|
|
Narrator paintingMachine{};
|
|
- paintingMachine.addListener(dynamic_pointer_cast<IListener>(this->mercedes1));
|
|
|
|
- paintingMachine.addListener(dynamic_pointer_cast<IListener>(this->mercedes2));
|
|
|
|
- paintingMachine.addListener(dynamic_pointer_cast<IListener>(this->mercedes3));
|
|
|
|
|
|
+ paintingMachine.addListener(this->mercedes1);
|
|
|
|
+ paintingMachine.addListener(this->mercedes2);
|
|
|
|
+ paintingMachine.addListener(this->mercedes3);
|
|
|
|
|
|
ASSERT_FALSE(paintingMachine.getListeners().empty());
|
|
ASSERT_FALSE(paintingMachine.getListeners().empty());
|
|
paintingMachine.clear();
|
|
paintingMachine.clear();
|
|
@@ -108,9 +111,9 @@ namespace
|
|
{
|
|
{
|
|
this->createCars();
|
|
this->createCars();
|
|
Narrator paintingMachine{};
|
|
Narrator paintingMachine{};
|
|
- paintingMachine.addListener(dynamic_pointer_cast<IListener>(this->mercedes1));
|
|
|
|
- paintingMachine.addListener(dynamic_pointer_cast<IListener>(this->mercedes2));
|
|
|
|
- paintingMachine.addListener(dynamic_pointer_cast<IListener>(this->mercedes3));
|
|
|
|
|
|
+ paintingMachine.addListener(this->mercedes1);
|
|
|
|
+ paintingMachine.addListener(this->mercedes2);
|
|
|
|
+ paintingMachine.addListener(this->mercedes3);
|
|
|
|
|
|
ASSERT_TRUE(paintingMachine.removeListener(this->mercedes2));
|
|
ASSERT_TRUE(paintingMachine.removeListener(this->mercedes2));
|
|
ASSERT_TRUE(paintingMachine.removeListener(this->mercedes1));
|
|
ASSERT_TRUE(paintingMachine.removeListener(this->mercedes1));
|
|
@@ -146,9 +149,9 @@ namespace
|
|
{
|
|
{
|
|
this->createCars();
|
|
this->createCars();
|
|
Narrator paintingMachine{};
|
|
Narrator paintingMachine{};
|
|
- paintingMachine.addListener(dynamic_pointer_cast<IListener>(this->mercedes1));
|
|
|
|
- paintingMachine.addListener(dynamic_pointer_cast<IListener>(this->mercedes2));
|
|
|
|
- paintingMachine.addListener(dynamic_pointer_cast<IListener>(this->mercedes3));
|
|
|
|
|
|
+ paintingMachine.addListener(this->mercedes1);
|
|
|
|
+ paintingMachine.addListener(this->mercedes2);
|
|
|
|
+ paintingMachine.addListener(this->mercedes3);
|
|
|
|
|
|
ASSERT_STREQ("pink", this->mercedes1->getColor().c_str());
|
|
ASSERT_STREQ("pink", this->mercedes1->getColor().c_str());
|
|
ASSERT_STREQ("blue", this->mercedes2->getColor().c_str());
|
|
ASSERT_STREQ("blue", this->mercedes2->getColor().c_str());
|