From 74ef1f2ce14297bef8184d8dafadf05c42c7b7f7 Mon Sep 17 00:00:00 2001
From: Floris Berendsen <floris.berendsen@gmail.com>
Date: Wed, 18 Nov 2015 13:27:17 +0100
Subject: [PATCH] FIX: some tests

---
 Testing/Unit/elxComponentInterfaceTest.cxx | 25 ++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/Testing/Unit/elxComponentInterfaceTest.cxx b/Testing/Unit/elxComponentInterfaceTest.cxx
index fac06b98..43e2b6ee 100644
--- a/Testing/Unit/elxComponentInterfaceTest.cxx
+++ b/Testing/Unit/elxComponentInterfaceTest.cxx
@@ -54,7 +54,7 @@ TEST_F( InterfaceTest, DynamicCast )
   //optimizer3p should have a OptimizerUpdateInterface
   OptimizerUpdateInterface* updateIF = dynamic_cast<OptimizerUpdateInterface*> (optimizer3p);
   ASSERT_NE(updateIF, nullptr);
-  EXPECT_NO_THROW(returnval = updateIF->Update());
+  //EXPECT_NO_THROW(returnval = updateIF->Update()); // Update can only be called if metric and optimizer are connected
 
   //optimizer3p should have a InterfaceAcceptor<MetricValueInterface> 
   InterfaceAcceptor<MetricValueInterface>* valueAcceptorIF = dynamic_cast<InterfaceAcceptor<MetricValueInterface>*> (optimizer3p);
@@ -66,7 +66,7 @@ TEST_F( InterfaceTest, DynamicCast )
   
 }
 
-TEST_F( InterfaceTest, ComponentConnecting )
+TEST_F( InterfaceTest, ConnectByName )
 {
   interfaceStatus IFstatus;
   EXPECT_NO_THROW(IFstatus = optimizer3p->ConnectFrom("MetricValueInterface", metric3p));
@@ -92,4 +92,25 @@ TEST_F( InterfaceTest, ComponentConnecting )
   EXPECT_EQ(IFstatus, interfaceStatus::noaccepter);
 
 }
+
+TEST_F(InterfaceTest, ConnectAll)
+{
+  int connectionCount = 0;
+  EXPECT_NO_THROW(connectionCount = optimizer3p->ConnectFrom(metric3p));
+  EXPECT_EQ(connectionCount, 2); // both MetricValueInterface and MetricDerivativeInterface are connected
+
+  EXPECT_NO_THROW(connectionCount = optimizer3p->ConnectFrom(metric4p));
+  EXPECT_EQ(connectionCount, 1); // only MetricValueInterface is connected
+
+  EXPECT_NO_THROW(connectionCount = optimizer4p->ConnectFrom(metric3p));
+  EXPECT_EQ(connectionCount, 1); // only MetricValueInterface is connected
+
+  EXPECT_NO_THROW(connectionCount = optimizer4p->ConnectFrom(metric4p));
+  EXPECT_EQ(connectionCount, 1); // only MetricValueInterface is connected
+
+
+  EXPECT_NO_THROW(connectionCount = metric4p->ConnectFrom(optimizer4p));
+  EXPECT_EQ(connectionCount, 0); // cannot connect in this direction
+}
+
 } // namespace elx
-- 
GitLab