Class: ODDB::State::Drugs::TestComparison

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

Instance Method Summary (collapse)

Instance Method Details

- (Object) setup



47
48
49
50
51
52
53
54
55
56
# File 'test/test_model/comparison.rb', line 47

def setup
  @original = StubComparisonPackage.new(ODDB::Dose.new(10, 'Tabletten'), 1000)
  @pack1 = StubComparisonPackage.new(ODDB::Dose.new(20, 'Tabletten'), 1000)
  @pack2 = StubComparisonPackage.new(ODDB::Dose.new(10, 'Tabletten'), 500)
  @pack3 = StubComparisonPackage.new(ODDB::Dose.new(5, 'Tabletten'), 1000)
  @pack4 = StubComparisonPackage.new(ODDB::Dose.new(5, 'Tabletten'), 0, "a")
  @pack5 = StubComparisonPackage.new(ODDB::Dose.new(5, 'Tabletten'), nil, "b")
  @original.comparables = [@pack1, @pack2, @pack3, @pack4, @pack5]
  @comp = Compare::Comparison.new(@original)
end

- (Object) test_comparables



77
78
79
80
81
# File 'test/test_model/comparison.rb', line 77

def test_comparables
  original = StubComparisonPackage.new(ODDB::Dose.new(10, 'Tabletten'), 1000)
  comp = Compare::Comparison.new(original)
  assert_equal(true, comp.empty?)
end

- (Object) test_empty



57
58
59
# File 'test/test_model/comparison.rb', line 57

def test_empty
  assert_equal(false, @comp.empty?)
end

- (Object) test_enumerable



72
73
74
75
76
# File 'test/test_model/comparison.rb', line 72

def test_enumerable
  collection = @comp.collect { |pack| pack }
  assert_equal(6, collection.size) 
  assert_equal(@original, collection.first.package)
end

- (Object) test_price_difference1



60
61
62
# File 'test/test_model/comparison.rb', line 60

def test_price_difference1
  assert_equal(-0.5, @comp.comparables.first.price_difference)
end

- (Object) test_price_difference2



63
64
65
# File 'test/test_model/comparison.rb', line 63

def test_price_difference2
  assert_equal(-0.5, @comp.comparables[1].price_difference)
end

- (Object) test_price_difference3



66
67
68
# File 'test/test_model/comparison.rb', line 66

def test_price_difference3
  assert_equal(1.0, @comp.comparables[2].price_difference)
end

- (Object) test_sort



69
70
71
# File 'test/test_model/comparison.rb', line 69

def test_sort
  assert_equal([@pack2, @pack1, @pack3, @pack4, @pack5], @comp.comparables.collect { |c| c.package})
end