Mercurial > hg > orthanc-databases
comparison Framework/Plugins/IndexUnitTests.h @ 199:8cae98f73d53
refactoring
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 18 Mar 2021 14:52:06 +0100 |
parents | 3236894320d6 |
children | 30b210616f4f |
comparison
equal
deleted
inserted
replaced
198:7335efde0d23 | 199:8cae98f73d53 |
---|---|
96 | 96 |
97 static OrthancPluginErrorCode InvokeService(struct _OrthancPluginContext_t* context, | 97 static OrthancPluginErrorCode InvokeService(struct _OrthancPluginContext_t* context, |
98 _OrthancPluginService service, | 98 _OrthancPluginService service, |
99 const void* params) | 99 const void* params) |
100 { | 100 { |
101 if (service == _OrthancPluginService_DatabaseAnswer) | 101 switch (service) |
102 { | 102 { |
103 const _OrthancPluginDatabaseAnswer& answer = | 103 case _OrthancPluginService_DatabaseAnswer: |
104 *reinterpret_cast<const _OrthancPluginDatabaseAnswer*>(params); | |
105 | |
106 switch (answer.type) | |
107 { | 104 { |
108 case _OrthancPluginDatabaseAnswerType_Attachment: | 105 const _OrthancPluginDatabaseAnswer& answer = |
106 *reinterpret_cast<const _OrthancPluginDatabaseAnswer*>(params); | |
107 | |
108 switch (answer.type) | |
109 { | 109 { |
110 const OrthancPluginAttachment& attachment = | 110 case _OrthancPluginDatabaseAnswerType_Attachment: |
111 *reinterpret_cast<const OrthancPluginAttachment*>(answer.valueGeneric); | 111 { |
112 CheckAttachment(attachment); | 112 const OrthancPluginAttachment& attachment = |
113 break; | 113 *reinterpret_cast<const OrthancPluginAttachment*>(answer.valueGeneric); |
114 CheckAttachment(attachment); | |
115 break; | |
116 } | |
117 | |
118 case _OrthancPluginDatabaseAnswerType_ExportedResource: | |
119 { | |
120 const OrthancPluginExportedResource& attachment = | |
121 *reinterpret_cast<const OrthancPluginExportedResource*>(answer.valueGeneric); | |
122 CheckExportedResource(attachment); | |
123 break; | |
124 } | |
125 | |
126 case _OrthancPluginDatabaseAnswerType_DicomTag: | |
127 { | |
128 const OrthancPluginDicomTag& tag = | |
129 *reinterpret_cast<const OrthancPluginDicomTag*>(answer.valueGeneric); | |
130 CheckDicomTag(tag); | |
131 break; | |
132 } | |
133 | |
134 default: | |
135 printf("Unhandled message: %d\n", answer.type); | |
136 break; | |
114 } | 137 } |
115 | 138 |
116 case _OrthancPluginDatabaseAnswerType_ExportedResource: | 139 return OrthancPluginErrorCode_Success; |
117 { | |
118 const OrthancPluginExportedResource& attachment = | |
119 *reinterpret_cast<const OrthancPluginExportedResource*>(answer.valueGeneric); | |
120 CheckExportedResource(attachment); | |
121 break; | |
122 } | |
123 | |
124 case _OrthancPluginDatabaseAnswerType_DicomTag: | |
125 { | |
126 const OrthancPluginDicomTag& tag = | |
127 *reinterpret_cast<const OrthancPluginDicomTag*>(answer.valueGeneric); | |
128 CheckDicomTag(tag); | |
129 break; | |
130 } | |
131 | |
132 default: | |
133 printf("Unhandled message: %d\n", answer.type); | |
134 break; | |
135 } | 140 } |
141 | |
142 case _OrthancPluginService_GetExpectedDatabaseVersion: | |
143 { | |
144 const _OrthancPluginReturnSingleValue& p = | |
145 *reinterpret_cast<const _OrthancPluginReturnSingleValue*>(params); | |
146 *(p.resultUint32) = ORTHANC_DATABASE_VERSION; | |
147 return OrthancPluginErrorCode_Success; | |
148 } | |
149 | |
150 default: | |
151 assert(0); | |
152 printf("Service not emulated: %d\n", service); | |
153 return OrthancPluginErrorCode_NotImplemented; | |
136 } | 154 } |
137 | |
138 return OrthancPluginErrorCode_Success; | |
139 } | 155 } |
140 | 156 |
141 | 157 |
142 TEST(IndexBackend, Basic) | 158 TEST(IndexBackend, Basic) |
143 { | 159 { |
161 SQLiteIndex db; // Open in memory | 177 SQLiteIndex db; // Open in memory |
162 #else | 178 #else |
163 # error Unsupported database backend | 179 # error Unsupported database backend |
164 #endif | 180 #endif |
165 | 181 |
166 db.RegisterOutput(new OrthancPlugins::DatabaseBackendOutput(&context, NULL)); | 182 db.RegisterOutput(&context, new OrthancPlugins::DatabaseBackendOutput(&context, NULL)); |
167 db.Open(); | 183 db.Open(); |
168 | 184 |
169 | 185 |
170 std::string s; | 186 std::string s; |
171 ASSERT_TRUE(db.LookupGlobalProperty(s, Orthanc::GlobalProperty_DatabaseSchemaVersion)); | 187 ASSERT_TRUE(db.LookupGlobalProperty(s, Orthanc::GlobalProperty_DatabaseSchemaVersion)); |