Class: ODDB::State::TestGlobal

Inherits:
Test::Unit::TestCase
  • Object
show all
Defined in:
test/test_state/global.rb

Defined Under Namespace

Classes: StubApp, StubCompany, StubGalenicForm, StubGalenicGroup, StubPointer, StubSession

Instance Method Summary (collapse)

Instance Method Details

- (Object) setup



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

def setup
  ODBA.storage = Mock.new
  ODBA.storage.__next(:next_id) {
    1
  }
  @session = StubSession.new
  @state = State::Global.new(@session, @session)
end

- (Object) teardown



96
97
98
# File 'test/test_state/global.rb', line 96

def teardown
  ODBA.storage = nil
end

- (Object) test_resolve1



99
100
101
102
103
104
105
106
107
108
109
# File 'test/test_state/global.rb', line 99

def test_resolve1
  @company = StubCompany.new
  @session.app.companies = { 
    4  => @company, 
  }
  @session.user_input = {
    :pointer =>  Persistence::Pointer.new([:company, 4])
  }
  newstate = @state.resolve
  assert_instance_of(State::Companies::Company, newstate)
end

- (Object) test_resolve__print1



110
111
112
113
114
115
116
117
# File 'test/test_state/global.rb', line 110

def test_resolve__print1
  @session.app.fachinfos = { 0  => :foo}
  @session.user_input = {
    :pointer =>  Persistence::Pointer.new([:fachinfo, 0])
  }
  newstate = @state.print
  assert_instance_of(State::Drugs::FachinfoPrint, newstate)
end

- (Object) test_user_input1



118
119
120
121
122
123
124
125
126
127
128
# File 'test/test_state/global.rb', line 118

def test_user_input1
  @session.user_input = {
    :good => 'foo', 
    :bad => SBSM::InvalidDataError.new('e_invalid_bad', :bad, 'bar')
  }
  result = @state.user_input([:good, :bad])
  expected = {:good => 'foo'}
  assert_equal(expected, result)
  assert_equal(true, @state.errors.has_key?(:bad))
  assert_instance_of(SBSM::InvalidDataError, @state.error(:bad))
end

- (Object) test_user_input2



129
130
131
132
133
134
135
136
137
138
139
# File 'test/test_state/global.rb', line 129

def test_user_input2
  @session.user_input = {
    :good => 'foo', 
    :bad => SBSM::InvalidDataError.new('e_invalid_bad', :bad, 'bar')
  }
  @state.model = Persistence::CreateItem.new()
  @state.user_input([:good, :bad])
  assert_instance_of(Persistence::CreateItem, @state.model)
  assert_equal('foo', @state.model.good)
  assert_equal('bar', @state.model.bad)
end