Mercurial > hg > orthanc
comparison OrthancFramework/UnitTestsSources/JobsTests.cpp @ 4310:2ae905070221
renaming pure interface JobOperationValue as IJobOperationValue
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 09 Nov 2020 14:40:51 +0100 |
parents | 318c16cfccab |
children | d9473bd5ed43 |
comparison
equal
deleted
inserted
replaced
4309:73de065622ec | 4310:2ae905070221 |
---|---|
829 } | 829 } |
830 } | 830 } |
831 | 831 |
832 | 832 |
833 static bool CheckIdempotentSerialization(IJobUnserializer& unserializer, | 833 static bool CheckIdempotentSerialization(IJobUnserializer& unserializer, |
834 const JobOperationValue& value) | 834 const IJobOperationValue& value) |
835 { | 835 { |
836 Json::Value a = 42; | 836 Json::Value a = 42; |
837 value.Serialize(a); | 837 value.Serialize(a); |
838 | 838 |
839 std::unique_ptr<JobOperationValue> unserialized(unserializer.UnserializeValue(a)); | 839 std::unique_ptr<IJobOperationValue> unserialized(unserializer.UnserializeValue(a)); |
840 | 840 |
841 Json::Value b = 43; | 841 Json::Value b = 43; |
842 unserialized->Serialize(b); | 842 unserialized->Serialize(b); |
843 | 843 |
844 return CheckSameJson(a, b); | 844 return CheckSameJson(a, b); |
889 | 889 |
890 { | 890 { |
891 GenericJobUnserializer unserializer; | 891 GenericJobUnserializer unserializer; |
892 std::unique_ptr<JobOperationValues> values(JobOperationValues::Unserialize(unserializer, s)); | 892 std::unique_ptr<JobOperationValues> values(JobOperationValues::Unserialize(unserializer, s)); |
893 ASSERT_EQ(3u, values->GetSize()); | 893 ASSERT_EQ(3u, values->GetSize()); |
894 ASSERT_EQ(JobOperationValue::Type_Null, values->GetValue(0).GetType()); | 894 ASSERT_EQ(IJobOperationValue::Type_Null, values->GetValue(0).GetType()); |
895 ASSERT_EQ(JobOperationValue::Type_String, values->GetValue(1).GetType()); | 895 ASSERT_EQ(IJobOperationValue::Type_String, values->GetValue(1).GetType()); |
896 ASSERT_EQ(JobOperationValue::Type_String, values->GetValue(2).GetType()); | 896 ASSERT_EQ(IJobOperationValue::Type_String, values->GetValue(2).GetType()); |
897 | 897 |
898 ASSERT_EQ("hello", dynamic_cast<const StringOperationValue&>(values->GetValue(1)).GetContent()); | 898 ASSERT_EQ("hello", dynamic_cast<const StringOperationValue&>(values->GetValue(1)).GetContent()); |
899 ASSERT_EQ("world", dynamic_cast<const StringOperationValue&>(values->GetValue(2)).GetContent()); | 899 ASSERT_EQ("world", dynamic_cast<const StringOperationValue&>(values->GetValue(2)).GetContent()); |
900 } | 900 } |
901 } | 901 } |
914 } | 914 } |
915 | 915 |
916 ASSERT_THROW(unserializer.UnserializeJob(s), OrthancException); | 916 ASSERT_THROW(unserializer.UnserializeJob(s), OrthancException); |
917 ASSERT_THROW(unserializer.UnserializeOperation(s), OrthancException); | 917 ASSERT_THROW(unserializer.UnserializeOperation(s), OrthancException); |
918 | 918 |
919 std::unique_ptr<JobOperationValue> value; | 919 std::unique_ptr<IJobOperationValue> value; |
920 value.reset(unserializer.UnserializeValue(s)); | 920 value.reset(unserializer.UnserializeValue(s)); |
921 | 921 |
922 ASSERT_EQ(JobOperationValue::Type_Null, value->GetType()); | 922 ASSERT_EQ(IJobOperationValue::Type_Null, value->GetType()); |
923 | 923 |
924 { | 924 { |
925 StringOperationValue str("Hello"); | 925 StringOperationValue str("Hello"); |
926 | 926 |
927 ASSERT_TRUE(CheckIdempotentSerialization(unserializer, str)); | 927 ASSERT_TRUE(CheckIdempotentSerialization(unserializer, str)); |
930 | 930 |
931 ASSERT_THROW(unserializer.UnserializeJob(s), OrthancException); | 931 ASSERT_THROW(unserializer.UnserializeJob(s), OrthancException); |
932 ASSERT_THROW(unserializer.UnserializeOperation(s), OrthancException); | 932 ASSERT_THROW(unserializer.UnserializeOperation(s), OrthancException); |
933 value.reset(unserializer.UnserializeValue(s)); | 933 value.reset(unserializer.UnserializeValue(s)); |
934 | 934 |
935 ASSERT_EQ(JobOperationValue::Type_String, value->GetType()); | 935 ASSERT_EQ(IJobOperationValue::Type_String, value->GetType()); |
936 ASSERT_EQ("Hello", dynamic_cast<StringOperationValue&>(*value).GetContent()); | 936 ASSERT_EQ("Hello", dynamic_cast<StringOperationValue&>(*value).GetContent()); |
937 } | 937 } |
938 | 938 |
939 | 939 |
940 TEST(JobsSerialization, GenericJobs) | 940 TEST(JobsSerialization, GenericJobs) |