Class: ODDB::TestIndication

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

Defined Under Namespace

Classes: StubRegistration

Instance Method Summary (collapse)

Instance Method Details

- (Object) setup



20
21
22
# File 'test/test_model/indication.rb', line 20

def setup
  @indication = Indication.new
end

- (Object) test_add_remove_registration



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'test/test_model/indication.rb', line 23

def test_add_remove_registration
  assert_equal([], @indication.registrations)
  reg1 = StubRegistration.new
  reg2 = StubRegistration.new
  reg3 = StubRegistration.new
  @indication.add_registration(reg1)
  assert_equal([reg1], @indication.registrations)
  @indication.add_registration(reg2)
  @indication.add_registration(reg3)
  assert_equal([reg1, reg2, reg3], @indication.registrations)
  @indication.remove_registration(reg2)
  assert_equal([reg1, reg3], @indication.registrations)
  @indication.remove_registration(reg1)
  assert_equal([reg3], @indication.registrations)
  @indication.remove_registration(reg3)
  assert_equal([], @indication.registrations)
end

- (Object) test_atc_classes



40
41
42
43
44
45
46
47
48
# File 'test/test_model/indication.rb', line 40

def test_atc_classes
  reg1 = flexmock :atc_classes => ['atc1', 'atc2']
  reg2 = flexmock :atc_classes => [nil, 'atc3']
  seq1 = flexmock :atc_class => 'atc2'
  seq2 = flexmock :atc_class => nil
  @indication.registrations.push reg1, reg2
  @indication.sequences.push seq1, seq2
  assert_equal %w{atc1 atc2 atc3}, @indication.atc_classes
end

- (Object) test_empty__registration



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

def test_empty__registration
  assert_equal(true, @indication.empty?)
  reg1 = StubRegistration.new
  @indication.add_registration(reg1)
  assert_equal(false, @indication.empty?)
end

- (Object) test_empty__sequence



55
56
57
58
59
60
# File 'test/test_model/indication.rb', line 55

def test_empty__sequence
  assert_equal(true, @indication.empty?)
  reg1 = StubRegistration.new
  @indication.add_sequence(reg1)
  assert_equal(false, @indication.empty?)
end

- (Object) test_merge



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'test/test_model/indication.rb', line 73

def test_merge
  reg1 = flexmock 'reg1'
  reg2 = flexmock 'reg2'
  seq1 = flexmock 'seq1'
  seq2 = flexmock 'seq2'
  reg1.should_receive(:indication=).with(@indication).times(1).and_return do
    assert true
  end
  reg2.should_receive(:indication=).with(@indication).times(1).and_return do
    assert true
  end
  seq1.should_receive(:indication=).with(@indication).times(1).and_return do
    assert true
  end
  seq2.should_receive(:indication=).with(@indication).times(1).and_return do
    assert true
  end
  other = Indication.new
  other.update_values 'de' => 'Deutsch', 'fr' => 'Françaix',
                      :synonyms => ['Synonyms']
  other.registrations.push reg1, reg2
  other.sequences.push seq1, seq2
  @indication.merge other
  assert_equal ['Synonyms', 'Deutsch', 'Françaix'], @indication.synonyms
end

- (Object) test_registration_count



61
62
63
64
65
66
# File 'test/test_model/indication.rb', line 61

def test_registration_count
  assert_equal(0, @indication.registration_count)
  reg1 = StubRegistration.new
  @indication.add_registration(reg1)
  assert_equal(1, @indication.registration_count)
end

- (Object) test_search_text



67
68
69
70
71
72
# File 'test/test_model/indication.rb', line 67

def test_search_text
  @indication.update_values 'de' => 'Deutsch', 'fr' => 'Françaix'
  assert_equal 'Deutsch', @indication.search_text(:de)
  assert_equal 'Francaix', @indication.search_text(:fr)
  assert_equal 'Deutsch Francaix', @indication.search_text
end