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

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

test case rearrangement

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