Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkNodePredicateDataPropertyTest.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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #include "mitkGeometry3D.h"
20 #include "mitkDataNode.h"
21 #include "mitkTestFixture.h"
22 #include "mitkTestingMacros.h"
23 #include "mitkStringProperty.h"
24 
25 
26 class mitkNodePredicateDataPropertyTestSuite : public mitk::TestFixture
27 {
28  CPPUNIT_TEST_SUITE(mitkNodePredicateDataPropertyTestSuite);
29  MITK_TEST(Check_InvalidConstructor);
30  MITK_TEST(Check_InvalidCheckNode);
31  MITK_TEST(Check_CheckName);
32  MITK_TEST(Check_CheckNameAndValue);
33  CPPUNIT_TEST_SUITE_END();
34 
35 private:
39  mitk::DataNode::Pointer m_NullNode;
40  mitk::DataNode::Pointer m_NullDataNode;
41  mitk::DataNode::Pointer m_OtherNode;
42  mitk::DataNode::Pointer m_NoPropNode;
43 
44  mitk::StringProperty::Pointer m_RefProperty;
45 
46 public:
51  void setUp() override
52  {
53  m_RefProperty = mitk::StringProperty::New("value1");
54 
56  m_Data->SetProperty("prop1", mitk::StringProperty::New("value1"));
57  m_Data->SetProperty("prop2", mitk::StringProperty::New("value2"));
58 
60  m_OtherData->SetProperty("prop1", mitk::StringProperty::New("othervalue"));
61 
62  m_NullNode = nullptr;
63 
64  m_NullDataNode = mitk::DataNode::New();
65 
66  m_Node = mitk::DataNode::New();
67  m_Node->SetData(m_Data);
68 
69  m_OtherNode = mitk::DataNode::New();
70  m_OtherNode->SetData(m_OtherData);
71 
72  m_NoPropNode = mitk::DataNode::New();
73  m_NoPropNode->SetData(mitk::BaseDataTestImplementation::New());
74  }
75 
76  void tearDown() override
77  {
78  m_Node = nullptr;
79  m_NullNode = nullptr;
80  m_NullDataNode = nullptr;
81  m_OtherNode = nullptr;
82  m_Data = nullptr;
83  m_OtherData = nullptr;
84  }
85 
86  void Check_InvalidConstructor()
87  {
88  CPPUNIT_ASSERT_THROW(mitk::NodePredicateDataProperty::New(""), mitk::Exception);
89  }
90 
91  void Check_InvalidCheckNode()
92  {
94 
95  CPPUNIT_ASSERT_THROW(predicate->CheckNode(nullptr), mitk::Exception);
96  }
97 
98  void Check_CheckName()
99  {
101 
102  CPPUNIT_ASSERT(!predicate->CheckNode(m_NullDataNode));
103  CPPUNIT_ASSERT(predicate->CheckNode(m_Node));
104  CPPUNIT_ASSERT(predicate->CheckNode(m_OtherNode));
105  CPPUNIT_ASSERT(!predicate->CheckNode(m_NoPropNode));
106  }
107 
108  void Check_CheckNameAndValue()
109  {
111 
112  CPPUNIT_ASSERT(!predicate->CheckNode(m_NullDataNode));
113  CPPUNIT_ASSERT(predicate->CheckNode(m_Node));
114  CPPUNIT_ASSERT(!predicate->CheckNode(m_OtherNode));
115  CPPUNIT_ASSERT(!predicate->CheckNode(m_NoPropNode));
116  }
117 };
118 
119 MITK_TEST_SUITE_REGISTRATION(mitkNodePredicateDataProperty)
MITK_TEST_SUITE_REGISTRATION(mitkImageToItk)
#define MITK_TEST(TESTMETHOD)
Adds a test to the current test suite.
mitk::DataNode::Pointer m_Node
static Pointer New()
An object of this class represents an exception of MITK. Please don't instantiate exceptions manually...
Definition: mitkException.h:49
Test fixture for parameterized tests.
static Pointer New(const char *_arg)
static Pointer New()