Class: ODDB::OdbaExporter::TestAcscLine

Inherits:
Test::Unit::TestCase
  • Object
show all
Includes:
FlexMock::TestCase
Defined in:
ext/export/test/test_oddbdat.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) test_structure



333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
# File 'ext/export/test/test_oddbdat.rb', line 333

def test_structure
  # test nil case
  package = ODDB::Package.new('12')
  @acscline = AcscLine.new(package, nil, 'count')
  assert_equal(nil, @acscline.structure)

  # test not nil case
  flexstub(package).should_receive(:oid).and_return(123)
  active_agent = flexmock('active_agent') do |act|
    act.should_receive(:dose).and_return(flexmock('dose') do |dose|
      dose.should_receive(:is_a?).and_return(true)
      dose.should_receive(:qty).and_return('qty')
      dose.should_receive(:unit).and_return('unit')
    end)
    act.should_receive(:substance).and_return(flexmock('oid') do |oid|
      oid.should_receive(:oid).and_return('oid')
    end)
  end
  flexstub(Date).should_receive(:"today.strftime").and_return('20110203000000')
  @acscline =AcscLine.new(package, active_agent, 223)

  expected = {
    1=>"41",
    2=>"20110203000000",
    3=>123,
    4=>223,
    5=>"4",
    6=>"oid",
    7=>"qty",
    8=>"unit",
    9=>"W",
  }
  assert_equal(expected.sort, @acscline.structure.sort)
end