Class: ODDB::TestGalenicGroup

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

Defined Under Namespace

Classes: StubApp, StubForm

Instance Method Summary (collapse)

Instance Method Details

- (Object) setup



38
39
40
41
42
# File 'test/test_model/galenicgroup.rb', line 38

def setup
  ODBA.storage.reset_id
  @group = ODDB::GalenicGroup.new
  @group.pointer = ODDB::Persistence::Pointer.new([:galenic_group, 1])
end

- (Object) test_add



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

def test_add
  form = StubForm.new
  @group.add(form)
  assert_equal({form.oid=>form}, @group.galenic_forms)
end

- (Object) test_create



71
72
73
74
75
76
77
78
# File 'test/test_model/galenicgroup.rb', line 71

def test_create
  pointer = ODDB::Persistence::Pointer.new([:galenic_group])
  app = StubApp.new
  galenic_group = pointer.issue_create(app)
  expected = ODDB::Persistence::Pointer.new([:galenic_group, galenic_group.oid])
  assert_equal(ODDB::GalenicGroup, galenic_group.class)
  assert_equal(expected, galenic_group.pointer)
end

- (Object) test_create_galenic_form



86
87
88
89
90
91
# File 'test/test_model/galenicgroup.rb', line 86

def test_create_galenic_form
  @group.galenic_forms = {}
  @group.create_galenic_form
  assert_equal(ODDB::GalenicForm, @group.galenic_forms.values.first.class)
  assert_equal(@group.oid, @group.galenic_forms.values.first.galenic_group.oid)
end

- (Object) test_delete_galenic_form



92
93
94
95
# File 'test/test_model/galenicgroup.rb', line 92

def test_delete_galenic_form
  form = StubForm.new
  @group.galenic_forms = {1=>form}
end

- (Object) test_each_galenic_form



96
97
98
99
100
101
102
103
104
105
# File 'test/test_model/galenicgroup.rb', line 96

def test_each_galenic_form
  form1 = StubForm.new
  form2 = StubForm.new
  @group.galenic_forms = { 2 => form1, 3 => form2}
  res = []
  @group.each_galenic_form do |form|
    res.push form.oid
  end
  assert_equal [2, 3], res.sort
end

- (Object) test_empty



48
49
50
51
52
53
# File 'test/test_model/galenicgroup.rb', line 48

def test_empty
  assert_equal(true, @group.empty?)
  form = StubForm.new
  @group.galenic_forms = {form.oid=>form}
  assert_equal(false, @group.empty?)
end

- (Object) test_equal



118
119
120
121
122
123
124
125
# File 'test/test_model/galenicgroup.rb', line 118

def test_equal
  @group.instance_variable_set '@oid', 1
  assert_equal(false, @group == @group)
  group = ODDB::GalenicGroup.new
  assert_equal(true, group == group)
  assert_equal(false, group == @group)
  assert_equal(false, @group == group)
end

- (Object) test_galenic_form



106
107
108
109
110
111
112
# File 'test/test_model/galenicgroup.rb', line 106

def test_galenic_form
  form = StubForm.new
  @group.galenic_forms = {1=>form}
  assert_equal(form, @group.galenic_form(1))
  @group.delete_galenic_form 1
  assert_equal({}, @group.galenic_forms)
end

- (Object) test_get_galenic_form



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

def test_get_galenic_form
  form = StubForm.new
  @group.galenic_forms = {1=>form}
  assert_equal(form, @group.get_galenic_form('Tabletten'))
end

- (Object) test_language_interface



68
69
70
# File 'test/test_model/galenicgroup.rb', line 68

def test_language_interface
  assert_respond_to(@group, :description)
end

- (Object) test_remove1



54
55
56
57
58
59
# File 'test/test_model/galenicgroup.rb', line 54

def test_remove1
  form = StubForm.new
  @group.galenic_forms = {form.oid=>form}
  @group.remove(form)
  assert_equal({}, @group.galenic_forms)
end

- (Object) test_remove2



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

def test_remove2
  form1 = StubForm.new
  form2 = StubForm.new
  @group.galenic_forms = {form1.oid=>form1, form2.oid=>form2}
  assert_equal(2, @group.galenic_forms.size)
  @group.remove(form1)
  assert_equal({form2.oid=>form2}, @group.galenic_forms)
end

- (Object) test_update



79
80
81
82
83
84
85
# File 'test/test_model/galenicgroup.rb', line 79

def test_update
  values = {
    'de'  => 'eine Beschreibung nach dem update',
  }
  @group.update_values(values)
  assert_equal('eine Beschreibung nach dem update', @group.description('de'))
end