source: ruby/branches/0.5/test/unit/open_ehr/rm/common/resource_test.rb@ 191

Last change on this file since 191 was 191, checked in by KOBAYASHI, Shinji, 15 years ago

test cases rearrangement

File size: 3.9 KB
Line 
1require 'test/unit'
2require 'set'
3
4class RM_Common_Resource_Test < Test::Unit::TestCase
5 def setup
6 terminology_id = TerminologyId.new('openehr')
7 code_phrase = CodePhrase.new('ja', terminology_id)
8 @translation_details = OpenEhr::RM::Common::Resource::TranslationDetails.new(:language => code_phrase, :author => {'KOBAYASHI, Shinji', 'Ehime Univ'},
9 :accreditation => 'jp', :other_details => {'ruby', 'test'})
10 @authored_resource = OpenEhr::RM::Common::Resource::AuthoredResource.new(:original_language => code_phrase, :translations => {'ja', @translation_details}, :description => "test")
11 @resource_description_item = OpenEhr::RM::Common::Resource::ResourceDescriptionItem.new(:language => code_phrase,
12 :purpose => 'test',
13 :keywords => %w[test ruby],
14 :use => 'unit test',
15 :misuse => 'real use',
16 :copyright => 'openEHR.jp',
17 :original_resource_uri => {'issuer', 'http://openehr.jp/'},
18 :other_details => {'samos', 'icicth7'})
19 @resource_description = OpenEhr::RM::Common::Resource::ResourceDescription.new(:original_author => {'KOBAYASHI, Shinji' => 'Ehime University'},
20 :lifecycle_state => 'experimental',
21 :details => {'ja', @resource_description_item},
22 :other_contributors => %w[aki tim hugh],
23 :resource_package_uri => 'http://openehr.jp/svn/ruby',
24 :other_details => {'ja', 'shikoku'},
25 :parent_resource => @authored_resource)
26 @authored_resource = OpenEhr::RM::Common::Resource::AuthoredResource.new(:original_language => code_phrase, :translations => {'ja', @translation_details}, :description => @resource_description)
27 end
28
29 def test_init
30 assert_instance_of OpenEhr::RM::Common::Resource::AuthoredResource, @authored_resource
31 assert_instance_of OpenEhr::RM::Common::Resource::TranslationDetails, @translation_details
32 assert_instance_of OpenEhr::RM::Common::Resource::ResourceDescriptionItem, @resource_description_item
33 assert_instance_of OpenEhr::RM::Common::Resource::ResourceDescription, @resource_description
34 end
35
36 def test_translation_details
37 assert_equal 'ja', @translation_details.language.code_string
38 assert_equal 'Ehime Univ', @translation_details.author['KOBAYASHI, Shinji']
39 assert_equal 'jp', @translation_details.accreditation
40 assert_equal 'test', @translation_details.other_details['ruby']
41 end
42
43 def test_authoured_resource
44 assert_equal 'ja', @authored_resource.original_language.code_string
45 assert_equal @translation_details, @authored_resource.translations['ja']
46 assert_equal 'experimental', @authored_resource.description.lifecycle_state
47 assert !@authored_resource.is_controlled?
48 assert_equal(Set['ja'], @authored_resource.languages_available)
49 end
50
51 def test_resource_description_item
52 assert_equal 'ja', @resource_description_item.language.code_string
53 assert_equal 'test', @resource_description_item.purpose
54 assert_equal %w[test ruby], @resource_description_item.keywords
55 assert_equal 'unit test', @resource_description_item.use
56 assert_equal 'real use', @resource_description_item.misuse
57 assert_equal 'openEHR.jp', @resource_description_item.copyright
58 assert_equal 'http://openehr.jp/', @resource_description_item.original_resource_uri['issuer']
59 assert_equal 'icicth7', @resource_description_item.other_details['samos']
60 end
61
62 def test_resource_description
63 assert_equal 'Ehime University', @resource_description.original_author['KOBAYASHI, Shinji']
64 assert_equal 'experimental', @resource_description.lifecycle_state
65 assert_equal 'test', @resource_description.details['ja'].purpose
66 assert_equal %w[aki tim hugh], @resource_description.other_contributors
67 assert_equal 'http://openehr.jp/svn/ruby', @resource_description.resource_package_uri
68 assert_equal 'shikoku', @resource_description.other_details['ja']
69 assert_equal 'ja', @resource_description.parent_resource.original_language.code_string
70 end
71end
Note: See TracBrowser for help on using the repository browser.