28 TestFileReaderService(
const std::string &description)
34 ~TestFileReaderService()
override 40 std::vector<itk::SmartPointer<BaseData>>
Read()
override 42 std::vector<itk::SmartPointer<BaseData>> result;
52 TestFileReaderService *
Clone()
const override 54 return new TestFileReaderService(*
this);
65 CPPUNIT_TEST_SUITE(mitkPreferenceListReaderOptionsFunctorTestSuite);
71 MITK_TEST(UseOverlappingBlackAndPreferenceList);
72 MITK_TEST(UsePreferenceListWithInexistantReaders);
76 CPPUNIT_TEST_SUITE_END();
79 std::string m_ImagePath;
84 mitk::TestFileReaderService* m_NormalService;
85 mitk::TestFileReaderService* m_PrefService;
86 mitk::TestFileReaderService* m_BlackService;
92 m_ImagePath = GetTestDataFilePath(
"BallBinary30x30x30.nrrd");
94 preference = {
"Prefered Test Service" };
95 black = {
"Unwanted Test Service" };
106 context->RegisterService(m_TestMimeType, props);
108 m_NormalService =
new mitk::TestFileReaderService(
"Normal Test Service");
109 m_PrefService =
new mitk::TestFileReaderService(
"Prefered Test Service");
110 m_BlackService =
new mitk::TestFileReaderService(
"Unwanted Test Service");
113 void tearDown()
override 115 delete m_PrefService;
116 delete m_BlackService;
117 delete m_NormalService;
118 delete m_TestMimeType;
121 void UsePreferenceList()
126 CPPUNIT_ASSERT(
true == functor(
info));
127 auto description =
info.m_ReaderSelector.GetSelected().GetDescription();
128 CPPUNIT_ASSERT_EQUAL(std::string(
"Prefered Test Service"), description);
136 CPPUNIT_ASSERT(
true == functor(
info));
137 auto description =
info.m_ReaderSelector.GetSelected().GetDescription();
138 CPPUNIT_ASSERT_EQUAL(std::string(
"Normal Test Service"), description);
146 CPPUNIT_ASSERT(
true == functor(
info));
147 auto description =
info.m_ReaderSelector.GetSelected().GetDescription();
148 CPPUNIT_ASSERT(description !=
"Unwanted Test Service");
151 void UseBlackAndPreferenceList()
156 CPPUNIT_ASSERT(
true == functor(
info));
157 auto description =
info.m_ReaderSelector.GetSelected().GetDescription();
158 CPPUNIT_ASSERT_EQUAL(std::string(
"Prefered Test Service"), description);
161 void UseOverlappingBlackAndPreferenceList()
165 black.push_back(
"Prefered Test Service");
166 black.push_back(
"Normal Test Service");
169 CPPUNIT_ASSERT(
true == functor(
info));
170 auto description =
info.m_ReaderSelector.GetSelected().GetDescription();
171 CPPUNIT_ASSERT_EQUAL(std::string(
"ITK NrrdImageIO"), description);
174 void UsePreferenceListWithInexistantReaders()
177 preference.push_back(
"InexistantReader");
180 CPPUNIT_ASSERT(
true == functor(
info));
181 auto description =
info.m_ReaderSelector.GetSelected().GetDescription();
182 CPPUNIT_ASSERT_EQUAL(std::string(
"Prefered Test Service"), description);
185 void UseAllBlackedList()
189 for (
auto reader :
info.m_ReaderSelector.Get())
191 black.push_back(reader.GetDescription());
Option callback functor with a preference list/ black list option selection strategy.
MITK_TEST_SUITE_REGISTRATION(mitkImageToItk)
US_Core_EXPORT const std::string & SERVICE_RANKING()
#define MITK_TEST(TESTMETHOD)
Adds a test to the current test suite.
DataCollection - Class to facilitate loading/accessing structured data.
std::vector< itk::SmartPointer< BaseData > > Read() override=0
Reads a path or stream and creates a list of BaseData objects.
void SetComment(const std::string &comment)
static void info(const char *fmt,...)
The CustomMimeType class represents a custom mime-type which may be registered as a service object...
static std::string CATEGORY_IMAGES()
us::ServiceRegistration< IFileReader > RegisterService(us::ModuleContext *context=us::GetModuleContext())
ConfidenceLevel
A confidence level describing the confidence of the reader or writer in handling the given data...
An object of this class represents an exception of MITK. Please don't instantiate exceptions manually...
Test fixture for parameterized tests.
DataStorage::SetOfObjects::Pointer Read(mitk::DataStorage &ds) override
Reads the specified file or input stream, loading its contents into the provided DataStorage.
void AddExtension(const std::string &extension)
US_UNORDERED_MAP_TYPE< std::string, Any > ServiceProperties
std::vector< std::string > ListType
void SetCategory(const std::string &category)
Base class for creating mitk::BaseData objects from files or streams.
static ModuleContext * GetModuleContext()
Returns the module context of the calling module.