Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
mitkGenericIDRelationRuleTest.cpp
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
14 
15 #include "mitkDataNode.h"
16 #include "mitkStringProperty.h"
17 
18 #include "mitkTestFixture.h"
19 #include "mitkTestingMacros.h"
20 
21 class mitkGenericIDRelationRuleTestSuite : public mitk::TestFixture
22 {
23  CPPUNIT_TEST_SUITE(mitkGenericIDRelationRuleTestSuite);
24 
25  MITK_TEST(GetRuleID);
26  MITK_TEST(GetDisplayName);
27  MITK_TEST(GetSourceRoleName);
28  MITK_TEST(GetDestinationRoleName);
30 
31  CPPUNIT_TEST_SUITE_END();
32 
33 private:
37 
38 public:
39  void setUp() override
40  {
41  rule_new1 = mitk::GenericIDRelationRule::New("TestID");
42  rule_new2 = mitk::GenericIDRelationRule::New("TestID2", "display name");
43  rule_new4 = mitk::GenericIDRelationRule::New("TestID4", "display name 4", "srole", "drole");
44  }
45 
46  void tearDown() override {}
47 
48  void GetRuleID()
49  {
50  CPPUNIT_ASSERT(rule_new1->GetRuleID() == "IDRelation_TestID");
51  CPPUNIT_ASSERT(rule_new2->GetRuleID() == "IDRelation_TestID2");
52  CPPUNIT_ASSERT(rule_new4->GetRuleID() == "IDRelation_TestID4");
53  }
54 
55  void GetDisplayName()
56  {
57  CPPUNIT_ASSERT(rule_new1->GetDisplayName() == "TestID relation");
58  CPPUNIT_ASSERT(rule_new2->GetDisplayName() == "display name");
59  CPPUNIT_ASSERT(rule_new4->GetDisplayName() == "display name 4");
60  }
61 
62  void GetSourceRoleName()
63  {
64  CPPUNIT_ASSERT(rule_new1->GetSourceRoleName() == "source of TestID relation");
65  CPPUNIT_ASSERT(rule_new2->GetSourceRoleName() == "source of TestID2 relation");
66  CPPUNIT_ASSERT(rule_new4->GetSourceRoleName() == "srole");
67  }
68 
69  void GetDestinationRoleName()
70  {
71  CPPUNIT_ASSERT(rule_new1->GetDestinationRoleName() == "destination of TestID relation");
72  CPPUNIT_ASSERT(rule_new2->GetDestinationRoleName() == "destination of TestID2 relation");
73  CPPUNIT_ASSERT(rule_new4->GetDestinationRoleName() == "drole");
74  }
75 
76  void Clone()
77  {
78  auto clone = rule_new4->Clone();
79 
80  CPPUNIT_ASSERT(clone->GetRuleID() == "IDRelation_TestID4");
81  CPPUNIT_ASSERT(clone->GetDisplayName() == "display name 4");
82  CPPUNIT_ASSERT(clone->GetSourceRoleName() == "srole");
83  CPPUNIT_ASSERT(clone->GetDestinationRoleName() == "drole");
84  }
85 
86 };
87 
88 MITK_TEST_SUITE_REGISTRATION(mitkGenericIDRelationRule)
MITK_TEST_SUITE_REGISTRATION(mitkImageToItk)
static Pointer New(const RuleIDType &_arg)
#define MITK_TEST(TESTMETHOD)
Adds a test to the current test suite.
static void clone(T *&dst, S *src, int n)
Definition: svm.cpp:59
Test fixture for parameterized tests.
static mitk::PlanarFigure::Pointer Clone(mitk::PlanarFigure::Pointer original)