1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
|
#define BOOST_TEST_MODULE CFindRequest
#include <boost/test/unit_test.hpp>
#include "odil/message/CFindRequest.h"
#include "odil/DataSet.h"
#include "odil/message/Message.h"
#include "odil/registry.h"
#include "../../MessageFixtureBase.h"
struct Fixture: public MessageFixtureBase<odil::message::CFindRequest>
{
std::shared_ptr<odil::DataSet> command_set;
std::shared_ptr<odil::DataSet> query;
Fixture()
: command_set(std::make_shared<odil::DataSet>()),
query(std::make_shared<odil::DataSet>())
{
this->command_set->add(
"CommandField", {odil::message::Message::Command::C_FIND_RQ});
this->command_set->add("MessageID", {1234});
this->command_set->add("AffectedSOPClassUID",
{odil::registry::PatientRootQueryRetrieveInformationModelFind});
this->command_set->add(
"Priority", {odil::message::Message::Priority::MEDIUM});
this->query->add("PatientName", {"Doe^John"});
this->query->add("StudyDescription", {"Brain"});
this->query->add("QueryRetrieveLevel", {"STUDY"});
}
virtual void check(odil::message::CFindRequest const & message)
{
BOOST_CHECK_EQUAL(
message.get_command_field(),
odil::message::Message::Command::C_FIND_RQ);
BOOST_CHECK_EQUAL(message.get_message_id(), 1234);
BOOST_CHECK_EQUAL(
message.get_affected_sop_class_uid(),
odil::registry::PatientRootQueryRetrieveInformationModelFind);
BOOST_CHECK(*message.get_data_set() == *this->query);
}
};
BOOST_FIXTURE_TEST_CASE(Constructor, Fixture)
{
odil::message::CFindRequest const message(
1234, odil::registry::PatientRootQueryRetrieveInformationModelFind,
odil::message::Message::Priority::MEDIUM, this->query);
this->check(message);
}
BOOST_FIXTURE_TEST_CASE(MessageConstructor, Fixture)
{
this->check_message_constructor(this->command_set, this->query);
}
BOOST_FIXTURE_TEST_CASE(MessageConstructorWrongCommandField, Fixture)
{
this->command_set->as_int("CommandField") = {
odil::message::Message::Command::C_ECHO_RQ};
this->check_message_constructor_throw(this->command_set, this->query);
}
BOOST_FIXTURE_TEST_CASE(MessageConstructorMissingAffectSOPClass, Fixture)
{
this->command_set->remove("AffectedSOPClassUID");
this->check_message_constructor_throw(this->command_set, this->query);
}
BOOST_FIXTURE_TEST_CASE(MessageConstructorMissingPriority, Fixture)
{
this->command_set->remove("Priority");
this->check_message_constructor_throw(this->command_set, this->query);
}
BOOST_FIXTURE_TEST_CASE(MessageConstructorMissingQuery, Fixture)
{
this->check_message_constructor_throw(this->command_set);
}
BOOST_FIXTURE_TEST_CASE(MessageConstructorEmptyQuery, Fixture)
{
auto empty = std::make_shared<odil::DataSet>();
this->check_message_constructor_throw(this->command_set, empty);
}
|