Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
mitkRTPlanReaderServiceTest.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 
13 #include "mitkTestingMacros.h"
14 #include "mitkTestFixture.h"
15 
16 #include "mitkImage.h"
18 #include "mitkBaseProperty.h"
19 #include <mitkIOUtil.h>
20 
21 class mitkRTPlanReaderServiceTestSuite : public mitk::TestFixture
22 {
23  CPPUNIT_TEST_SUITE(mitkRTPlanReaderServiceTestSuite);
24  MITK_TEST(TestProperties);
25  CPPUNIT_TEST_SUITE_END();
26 
27 private:
29 
30 public:
31 
32  void setUp() override
33  {
34  m_image = mitk::IOUtil::Load<mitk::Image>(GetTestDataFilePath("RT/Plan/rtplan.dcm"));
35  CPPUNIT_ASSERT_EQUAL(m_image.IsNotNull(), true);
36  }
37 
38  void TestProperties()
39  {
40  CheckStringProperty("DICOM.300A.0010.[0].300A.0013", "1.2.246.352.72.11.320687012.17740.20090508173031");
41  CheckStringProperty("DICOM.300A.0010.[1].300A.0013", "1.2.246.352.72.11.320687012.17741.20090508173031");
42  CheckStringProperty("DICOM.300A.0010.[0].300A.0016", "Breast");
43  CheckStringProperty("DICOM.300A.0010.[1].300A.0016", "CALC POINT");
44  CheckStringProperty("DICOM.300A.0010.[0].300A.0026", "14");
45  CheckStringProperty("DICOM.300A.0010.[1].300A.0026", "11.3113869239676");
46 
47  CheckStringProperty("DICOM.300A.0070.[0].300A.0078", "7");
48  CheckStringProperty("DICOM.300A.0070.[0].300A.0080", "4");
49 
50  CheckStringProperty("DICOM.300A.00B0.[0].300A.00C6", "PHOTON");
51  CheckStringProperty("DICOM.300A.00B0.[1].300A.00C6", "PHOTON");
52  CheckStringProperty("DICOM.300A.00B0.[2].300A.00C6", "PHOTON");
53  CheckStringProperty("DICOM.300A.00B0.[3].300A.00C6", "PHOTON");
54 
55  CheckStringProperty("DICOM.300C.0060.[0].0008.1155", "1.2.246.352.71.4.320687012.3190.20090511122144");
56  }
57 
58  void CheckStringProperty(const std::string& propertyName, const std::string& expectedPropertyValue)
59  {
60  auto actualProperty = m_image->GetProperty(propertyName.c_str());
61  CPPUNIT_ASSERT_EQUAL_MESSAGE("Property not found: " + propertyName, actualProperty.IsNotNull(), true);
62  auto actualTemporoSpatialStringProperty = dynamic_cast<mitk::TemporoSpatialStringProperty*>(actualProperty.GetPointer());
63  CPPUNIT_ASSERT_EQUAL_MESSAGE("Property has not type string: " + propertyName, actualTemporoSpatialStringProperty != nullptr, true);
64  std::string actualStringProperty = actualTemporoSpatialStringProperty->GetValue();
65  CPPUNIT_ASSERT_EQUAL_MESSAGE(propertyName + " is not as expected", actualStringProperty, expectedPropertyValue);
66  }
67 
68 
69 };
70 
71 MITK_TEST_SUITE_REGISTRATION(mitkRTPlanReaderService)
MITK_TEST_SUITE_REGISTRATION(mitkImageToItk)
#define MITK_TEST(TESTMETHOD)
Adds a test to the current test suite.
static std::string GetTestDataFilePath(const std::string &testData)
Get the absolute path for test data.
Test fixture for parameterized tests.
Property for time and space resolved string values.