Class: ODDB::TestFachinfo

Inherits:
Test::Unit::TestCase
  • Object
show all
Includes:
FlexMock::TestCase
Defined in:
test/test_model/fachinfo.rb

Defined Under Namespace

Classes: StubRegistration

Instance Method Summary (collapse)

Instance Method Details

- (Object) setup



27
28
29
# File 'test/test_model/fachinfo.rb', line 27

def setup
  @fachinfo = ODDB::Fachinfo.new
end

- (Object) test_add_change_log_item



35
36
37
38
39
40
41
42
# File 'test/test_model/fachinfo.rb', line 35

def test_add_change_log_item
  item, = @fachinfo.add_change_log_item 'test@email.ch', :indications, :de
  assert_instance_of ODDB::Fachinfo::ChangeLogItem, item
  assert_equal 'test@email.ch', item.
  assert_equal :indications, item.chapter
  assert_equal :de, item.language
  assert_equal [item], @fachinfo.change_log
end

- (Object) test_add_registration



30
31
32
33
34
# File 'test/test_model/fachinfo.rb', line 30

def test_add_registration
  reg = StubRegistration.new
  @fachinfo.add_registration(reg)
  assert_equal([reg], @fachinfo.registrations)
end

- (Object) test_atc_class



43
44
45
46
47
48
# File 'test/test_model/fachinfo.rb', line 43

def test_atc_class
  reg1 = flexmock :atc_classes => ['first atc', 'second atc']
  reg2 = flexmock :atc_classes => ['third atc']
  @fachinfo.registrations.push reg1, reg2
  assert_equal 'first atc', @fachinfo.atc_class
end

- (Object) test_company



76
77
78
79
80
# File 'test/test_model/fachinfo.rb', line 76

def test_company
  reg = flexmock :company => 'company'
  @fachinfo.registrations.push(reg)
  assert_equal 'company', @fachinfo.company
end

- (Object) test_company_name



81
82
83
84
85
86
87
# File 'test/test_model/fachinfo.rb', line 81

def test_company_name
  reg = StubRegistration.new
  expected = "Ywesee"
  reg.company_name = expected
  @fachinfo.registrations.push(reg)
  assert_equal(expected, @fachinfo.company_name)
end

- (Object) test_each_chapter



55
56
57
58
59
60
61
62
63
64
# File 'test/test_model/fachinfo.rb', line 55

def test_each_chapter
  fachinfo = ODDB::FachinfoDocument.new
  fachinfo.galenic_form = ODDB::Text::Chapter.new
  fachinfo.composition = ODDB::Text::Chapter.new
  chapters = []
  fachinfo.each_chapter { |chap|
    chapters << chap  
  }
  assert_equal(2, chapters.size)
end

- (Object) test_each_chapter2



65
66
67
68
69
70
71
72
73
74
75
# File 'test/test_model/fachinfo.rb', line 65

def test_each_chapter2
  fachinfo = ODDB::FachinfoDocument2001.new
  fachinfo.amzv = ODDB::Text::Chapter.new
  fachinfo.composition = ODDB::Text::Chapter.new
  fachinfo.effects = ODDB::Text::Chapter.new
  chapters = []
  fachinfo.each_chapter { |chap|
    chapters << chap  
  }
  assert_equal(3, chapters.size)
end

- (Object) test_generic_type



88
89
90
91
92
93
94
95
# File 'test/test_model/fachinfo.rb', line 88

def test_generic_type
  assert_equal(:unknown, @fachinfo.generic_type)
  reg = StubRegistration.new
  expected = :generic
  reg.generic_type = expected
  @fachinfo.registrations.push(reg)
  assert_equal(expected, @fachinfo.generic_type)
end

- (Object) test_interaction_text



96
97
98
99
100
# File 'test/test_model/fachinfo.rb', line 96

def test_interaction_text
  doc = flexmock :interactions => 'Some Interaction Text'
  @fachinfo.descriptions.store 'de', doc
  assert_equal 'Some Interaction Text', @fachinfo.interaction_text(:de)
end

- (Object) test_localized_name



101
102
103
104
105
106
107
108
109
110
111
112
# File 'test/test_model/fachinfo.rb', line 101

def test_localized_name
  assert_nil @fachinfo.localized_name
  reg = flexmock :name_base => 'NameBase'
  @fachinfo.registrations.push reg
  assert_equal 'NameBase', @fachinfo.localized_name
  doc = flexmock :name => 'Name'
  @fachinfo.descriptions.store 'de', doc
  assert_equal 'Name', @fachinfo.localized_name
  doc = flexmock :name => 'Nom'
  @fachinfo.descriptions.store 'fr', doc
  assert_equal 'Nom', @fachinfo.localized_name(:fr)
end

- (Object) test_pointer_descr



113
114
115
116
117
118
# File 'test/test_model/fachinfo.rb', line 113

def test_pointer_descr
  assert_nil @fachinfo.pointer_descr
  reg = flexmock :name_base => 'NameBase'
  @fachinfo.registrations.push reg
  assert_equal 'NameBase', @fachinfo.pointer_descr
end

- (Object) test_remove_registration



49
50
51
52
53
54
# File 'test/test_model/fachinfo.rb', line 49

def test_remove_registration
  reg = StubRegistration.new
  @fachinfo.registrations = [reg]
  @fachinfo.remove_registration(reg)
  assert_equal([], @fachinfo.registrations)
end

- (Object) test_search_text



119
120
121
122
123
# File 'test/test_model/fachinfo.rb', line 119

def test_search_text
  doc = flexmock :indications => 'Some Indication Text'
  @fachinfo.descriptions.store 'de', doc
  assert_equal 'Some Indication Text', @fachinfo.search_text(:de)
end

- (Object) test_substance_names



124
125
126
127
128
129
130
# File 'test/test_model/fachinfo.rb', line 124

def test_substance_names
  reg = StubRegistration.new
  expected = ["Magnesuim", "Mannidol"]
  reg.substance_names = expected
  @fachinfo.registrations.push(reg)
  assert_equal(expected, @fachinfo.substance_names)
end

- (Object) test_unwanted_effect_text



131
132
133
134
135
# File 'test/test_model/fachinfo.rb', line 131

def test_unwanted_effect_text
  doc = flexmock :unwanted_effects => 'Some Unwanted Effect Text'
  @fachinfo.descriptions.store 'de', doc
  assert_equal 'Some Unwanted Effect Text', @fachinfo.unwanted_effect_text(:de)
end