Преглед на файлове

Extended StateConnection class

- added setters for connectionId and and stateId
- extended tests for StateConnection class
Patrick-Laptop преди 3 години
родител
ревизия
8c79a13e84
променени са 3 файла, в които са добавени 35 реда и са изтрити 5 реда
  1. 12 2
      source/logic/StateConnection.cpp
  2. 4 2
      source/logic/StateConnection.hpp
  3. 19 1
      test/cases/logic/StateConnectionTest.cpp

+ 12 - 2
source/logic/StateConnection.cpp

@@ -3,7 +3,7 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-09-10
- * Changed:         2020-09-10
+ * Changed:         2020-09-14
  *
  * */
 
@@ -23,10 +23,20 @@ ls_std::StateId ls_std::StateConnection::getStateId() {
   return this->stateId;
 }
 
-bool ls_std::StateConnection::isPassable() {
+bool ls_std::StateConnection::isPassable() const {
   return this->condition;
 }
 
+void ls_std::StateConnection::setConnectionId(StateConnectionId _connectionId)
+{
+  this->connectionId = std::move(_connectionId);
+}
+
+void ls_std::StateConnection::setStateId(StateId _stateId)
+{
+  this->stateId = std::move(_stateId);
+}
+
 void ls_std::StateConnection::updatePassCondition(bool _condition) {
   this->condition = _condition;
 }

+ 4 - 2
source/logic/StateConnection.hpp

@@ -3,7 +3,7 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-09-10
- * Changed:         2020-09-10
+ * Changed:         2020-09-14
  *
  * */
 
@@ -23,7 +23,9 @@ namespace ls_std {
 
       StateConnectionId getConnectionId();
       StateId getStateId();
-      bool isPassable();
+      bool isPassable() const;
+      void setConnectionId(StateConnectionId _connectionId);
+      void setStateId(StateId _stateId);
       void updatePassCondition(bool _condition);
 
     private:

+ 19 - 1
test/cases/logic/StateConnectionTest.cpp

@@ -3,7 +3,7 @@
  * Company:         Lynar Studios
  * E-Mail:          webmaster@lynarstudios.com
  * Created:         2020-09-10
- * Changed:         2020-09-10
+ * Changed:         2020-09-14
  *
  * */
 
@@ -39,6 +39,24 @@ namespace {
     ASSERT_FALSE(connection.isPassable());
   }
 
+  TEST_F(StateConnectionTest, setConnectionId)
+  {
+    ls_std::StateConnection connection {"AB", "B"};
+    ASSERT_STREQ("AB", connection.getConnectionId().c_str());
+
+    connection.setConnectionId("BC");
+    ASSERT_STREQ("BC", connection.getConnectionId().c_str());
+  }
+
+  TEST_F(StateConnectionTest, setStateId)
+  {
+    ls_std::StateConnection connection {"AB", "B"};
+    ASSERT_STREQ("B", connection.getStateId().c_str());
+
+    connection.setStateId("C");
+    ASSERT_STREQ("C", connection.getStateId().c_str());
+  }
+
   TEST_F(StateConnectionTest, updatePassCondition)
   {
     ls_std::StateConnection connection {"AB", "B"};