Ignore:
Timestamp:
Jul 28, 2008, 7:45:40 AM (16 years ago)
Author:
KOBAYASHI, Shinji
Message:

refs #39

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ruby/trunk/lib/models/tests/test_reference_model.rb

    r91 r92  
    144144end
    145145
    146 class ReferenceModelSupportIdentificationTest < Test::Unit::TestCase
     146class RM_Support_Identification_Test < Test::Unit::TestCase
    147147  def setup
    148148    assert_nothing_raised(Exception){@object_id = OpenEHR::RM::Support::Identification::Object_ID.new("0.0.3")}
    149     @terminology_id = OpenEHR::RM::Support::Identification::Terminology_ID.new('terminology','version')
    150     @archetype_id = OpenEHR::RM::Support::Identification::Archetype_ID.new("0.0.5", "biochemistry result_cholesterol", "entry", "ehr_rm", "openehr","cholesterol","0.0.3")
     149    assert_nothing_raised(Exception){@archetype_id = OpenEHR::RM::Support::Identification::Archetype_ID.new("0.0.5", "biochemistry result_cholesterol", "entry", "ehr_rm", "openehr","cholesterol","0.0.3")}
     150    assert_nothing_raised(Exception){@terminology_id = OpenEHR::RM::Support::Identification::Terminology_ID.new("0.0.7", 'terminology','0.0.3')}
     151    assert_nothing_raised(Exception){@generic_id = OpenEHR::RM::Support::Identification::Generic_ID.new("0.0.3", "openehr")}
     152    assert_nothing_raised(Exception){@uid_based_id = OpenEHR::RM::Support::Identification::UID_Based_ID.new('rrip::0.0.3')
    151153  end
    152154 
     
    155157    assert_instance_of OpenEHR::RM::Support::Identification::Archetype_ID, @archetype_id
    156158    assert_instance_of OpenEHR::RM::Support::Identification::Terminology_ID, @terminology_id
     159    assert_instance_of OpenEHR::RM::Support::Identification::Object_ID, @object_id
     160    assert_instance_of OpenEHR::RM::Support::Identification::UID
    157161  end
    158162
     
    175179    assert_raise(ArgumentError){@archetype_id.value=""}
    176180    assert_raise(ArgumentError){@archetype_id = OpenEHR::RM::Support::Identification::Archetype_ID.new}
    177     assert_raise(ArgumentError){@object_id = OpenEHR::RM::Support::Identification::Archetype_ID.new(nil)}
    178     assert_raise(ArgumentError){@object_id = OpenEHR::RM::Support::Identification::Archetype_ID.new("")}
     181    assert_raise(ArgumentError){@archetype_id = OpenEHR::RM::Support::Identification::Archetype_ID.new(nil, "biochemistry result_cholesterol", "entry", "ehr_rm", "openehr","cholesterol","0.0.3")}
     182    assert_raise(ArgumentError){@object_id = OpenEHR::RM::Support::Identification::Archetype_ID.new("", "biochemistry result_cholesterol", "entry", "ehr_rm", "openehr","cholesterol","0.0.3")}
     183    assert_raise(ArgumentError){@archetype_id = OpenEHR::RM::Support::Identification::Archetype_ID.new("0.0.5", nil, "entry", "ehr_rm", "openehr","cholesterol","0.0.3")}
     184    assert_raise(ArgumentError){@archetype_id = OpenEHR::RM::Support::Identification::Archetype_ID.new("0.0.5", "", "entry", "ehr_rm", "openehr","cholesterol","0.0.3")}
     185    assert_raise(ArgumentError){@archetype_id = OpenEHR::RM::Support::Identification::Archetype_ID.new("0.0.5", "biochemistry result_cholesterol", nil, "ehr_rm", "openehr","cholesterol","0.0.3")}
     186    assert_raise(ArgumentError){@archetype_id = OpenEHR::RM::Support::Identification::Archetype_ID.new("0.0.5", "biochemistry result_cholesterol", "", "ehr_rm", "openehr","cholesterol","0.0.3")}
     187    assert_raise(ArgumentError){@archetype_id = OpenEHR::RM::Support::Identification::Archetype_ID.new("0.0.5", "biochemistry result_cholesterol", "entry", nil, "openehr","cholesterol","0.0.3")}
     188    assert_raise(ArgumentError){@archetype_id = OpenEHR::RM::Support::Identification::Archetype_ID.new("0.0.5", "biochemistry result_cholesterol", "entry", "", "openehr","cholesterol","0.0.3")}
     189    assert_raise(ArgumentError){@archetype_id = OpenEHR::RM::Support::Identification::Archetype_ID.new("0.0.5", "biochemistry result_cholesterol", "entry", "ehr_rm", nil,"cholesterol","0.0.3")}
     190    assert_raise(ArgumentError){@archetype_id = OpenEHR::RM::Support::Identification::Archetype_ID.new("0.0.5", "biochemistry result_cholesterol", "entry", "ehr_rm", "","cholesterol","0.0.3")}
     191    assert_raise(ArgumentError){@archetype_id = OpenEHR::RM::Support::Identification::Archetype_ID.new("0.0.5", "biochemistry result_cholesterol", "entry", "ehr_rm", "openehr",nil ,"0.0.3")}
     192    assert_raise(ArgumentError){@archetype_id = OpenEHR::RM::Support::Identification::Archetype_ID.new("0.0.5", "biochemistry result_cholesterol", "entry", "ehr_rm", "openehr","","0.0.3")}
     193    assert_raise(ArgumentError){@archetype_id = OpenEHR::RM::Support::Identification::Archetype_ID.new("0.0.5", "biochemistry result_cholesterol", "entry", "ehr_rm", "openehr","cholesterol", nil)}
     194    assert_raise(ArgumentError){@archetype_id = OpenEHR::RM::Support::Identification::Archetype_ID.new("0.0.5", "biochemistry result_cholesterol", "entry", "ehr_rm", "openehr","cholesterol","")}
    179195
    180196    assert_equal "biochemistry result_cholesterol", @archetype_id.domain_concept
     197    assert_nothing_raised(Exception){(@archetype_id.domain_concept = "biochemistry result_triglyceride")}
     198    assert_equal "biochemistry result_triglyceride", @archetype_id.domain_concept
     199    assert_raise(ArgumentError){@archetype_id.domain_concept = nil}
     200    assert_raise(ArgumentError){@archetype_id.domain_concept = ""}
    181201
    182202    assert_equal "entry", @archetype_id.rm_name
     203    assert_nothing_raised(Exception){@archetype_id.rm_name = "section"}
     204    assert_equal "section", @archetype_id.rm_name
     205    assert_raise(ArgumentError){@archetype_id.rm_name = nil}
     206    assert_raise(ArgumentError){@archetype_id.rm_name = ""}
    183207
    184208    assert_equal "ehr_rm", @archetype_id.rm_entity
     209    assert_nothing_raised(Exception){@archetype_id.rm_entity = "13606"}
     210    assert_equal "13606", @archetype_id.rm_entity
     211    assert_raise(ArgumentError){@archetype_id.rm_entity = nil}
     212    assert_raise(ArgumentError){@archetype_id.rm_entity = ""}
    185213
    186214    assert_equal "openehr", @archetype_id.rm_originator
     215    assert_nothing_raised(Exception){@archetype_id.rm_originator = "cen"}
     216    assert_equal "cen", @archetype_id.rm_originator
     217    assert_raise(ArgumentError){@archetype_id.rm_originator = nil}
     218    assert_raise(ArgumentError){@archetype_id.rm_originator = ""}
    187219
    188220    assert_equal "cholesterol", @archetype_id.specialisation
     221    assert_nothing_raised(Exception){@archetype_id.specialisation = "triglyceride"}
     222    assert_equal "triglyceride", @archetype_id.specialisation
     223    assert_raise(ArgumentError){@archetype_id.specialisation = nil}
     224    assert_raise(ArgumentError){@archetype_id.specialisation = ""}
    189225
    190226    assert_equal "0.0.3", @archetype_id.version_id
    191 
     227    assert_nothing_raised(Exception){@archetype_id.version_id = "0.0.7"}
     228    assert_equal "0.0.7", @archetype_id.version_id
     229    assert_raise(ArgumentError){@archetype_id.version_id = nil}
     230    assert_raise(ArgumentError){@archetype_id.version_id = ""}
     231  end
     232
     233  def test_terminology_id
     234    assert_equal "0.0.7", @terminology_id.value
     235    assert_nothing_raised(Exception){@terminology_id.value = "0.0.8"}
     236    assert_equal "0.0.8", @terminology_id.value
     237    assert_raise(ArgumentError){@terminology_id.value = nil}
     238    assert_raise(ArgumentError){@terminology_id.value = ""}
     239
     240    assert_raise(ArgumentError){@terminology_id = OpenEHR::RM::Support::Identification::Terminology_ID.new}
     241    assert_raise(ArgumentError){@terminology_id = OpenEHR::RM::Support::Identification::Terminology_ID.new(nil, 'terminology','0.0.3')}
     242    assert_raise(ArgumentError){@terminology_id = OpenEHR::RM::Support::Identification::Terminology_ID.new("", 'terminology','0.0.3')}
     243    assert_raise(ArgumentError){@terminology_id = OpenEHR::RM::Support::Identification::Terminology_ID.new("", 'terminology','0.0.3')}
     244    assert_raise(ArgumentError){@terminology_id = OpenEHR::RM::Support::Identification::Terminology_ID.new("0.0.7", nil,'0.0.3')}
     245    assert_raise(ArgumentError){@terminology_id = OpenEHR::RM::Support::Identification::Terminology_ID.new("0.0.7", '','0.0.3')}
     246    assert_raise(ArgumentError){@terminology_id = OpenEHR::RM::Support::Identification::Terminology_ID.new("0.0.7", "terminology", nil)}
     247    assert_nothing_raised(Exception){@terminology_id = OpenEHR::RM::Support::Identification::Terminology_ID.new("0.0.7", "terminology",'')}
     248
     249    assert_equal "terminology", @terminology_id.name
     250    assert_nothing_raised(Exception){@terminology_id.name = "snomed"}
     251    assert_equal "snomed", @terminology_id.name
     252    assert_raise(ArgumentError){@terminology_id.name = nil}
     253    assert_raise(ArgumentError){@terminology_id.name = ""}
     254
     255    assert_equal "", @terminology_id.version_id
     256    assert_nothing_raised(Exception){@terminology_id.version_id = "0.0.8"}
     257    assert_equal "0.0.8", @terminology_id.version_id
     258    assert_raise(ArgumentError){@terminology_id.version_id = nil}
     259    assert_nothing_raised(Exception){@terminology_id.version_id = ''}
     260  end
     261
     262  def test_generic_id
     263    assert_equal "0.0.3", @generic_id.value
     264    assert_equal "openehr", @generic_id.scheme
     265
     266    assert_raise(ArgumentError){@generic_id = OpenEHR::RM::Support::Identification::Generic_ID.new(nil, "openehr")}
     267    assert_raise(ArgumentError){@generic_id = OpenEHR::RM::Support::Identification::Generic_ID.new("", "openehr")}
     268    assert_raise(ArgumentError){@generic_id = OpenEHR::RM::Support::Identification::Generic_ID.new("0.0.3", nil)}
     269    assert_raise(ArgumentError){@generic_id = OpenEHR::RM::Support::Identification::Generic_ID.new("0.0.3", "")}
     270
     271    assert_raise(ArgumentError){@generic_id.value = nil}
     272    assert_raise(ArgumentError){@generic_id.value = ""}
     273    assert_nothing_raised(Exception){@generic_id.value = "0.0.5"}
     274    assert_equal "0.0.5", @generic_id.value
     275
     276    assert_raise(ArgumentError){@generic_id.scheme = nil}
     277    assert_raise(ArgumentError){@generic_id.scheme = ""}
     278    assert_nothing_raised(Exception){@generic_id.scheme = "cen"}
     279    assert_equal "cen", @generic_id.scheme
    192280  end
    193281end
Note: See TracChangeset for help on using the changeset viewer.