-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathclaims_adjudication_test.rb
79 lines (57 loc) · 2.29 KB
/
claims_adjudication_test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
require "test/unit"
require 'date'
require_relative './claims_adjudication'
class ClaimsAdjudicationTest < Test::Unit::TestCase
def fake_contract
product = Product.new("dishwasher", "OEUOEU23", "Whirlpool", "7DP840CWDB0")
contract = Contract.new(100.0, product, Date.new(2010, 5, 8), Date.new(2010, 5, 8), Date.new(2012, 5, 8))
contract.status = "ACTIVE"
contract
end
def test_claims_adjudication_for_valid_claim
contract = fake_contract
claim = Claim.new(79.0, Date.new(2010, 5, 8))
claims_adjudication = ClaimsAdjudication.new
claims_adjudication.adjudicate(contract, claim)
assert_equal 1, contract.claims.length
assert_equal 79.0, contract.claims.first.amount
assert_equal Date.new(2010, 5, 8), contract.claims.first.failure_date
end
def test_claims_adjudication_for_invalid_claim_amount
contract = fake_contract
claim = Claim.new(81.0, Date.new(2010, 5, 8))
claims_adjudication = ClaimsAdjudication.new
claims_adjudication.adjudicate(contract, claim)
assert_equal 0, contract.claims.length
end
def test_claims_adjudication_for_pending_contract
contract = fake_contract
contract.status = "PENDING"
claim = Claim.new(79.0, Date.new(2010, 5, 8))
claims_adjudication = ClaimsAdjudication.new
claims_adjudication.adjudicate(contract, claim)
assert_equal 0, contract.claims.length
end
def test_claims_adjudication_for_contract_prior_to_effective_date
contract = fake_contract
claim = Claim.new(79.0, Date.new(2010, 5, 5))
claims_adjudication = ClaimsAdjudication.new
claims_adjudication.adjudicate(contract, claim)
assert_equal 0, contract.claims.length
end
def test_claims_adjudication_for_expired_contract
contract = fake_contract
contract.status = "EXPIRED"
claim = Claim.new(79.0, Date.new(2010, 5, 8))
claims_adjudication = ClaimsAdjudication.new
claims_adjudication.adjudicate(contract, claim)
assert_equal 0, contract.claims.length
end
def test_claims_adjudication_for_contract_after_expiration_date
contract = fake_contract
claim = Claim.new(79.0, Date.new(2012, 5, 9))
claims_adjudication = ClaimsAdjudication.new
claims_adjudication.adjudicate(contract, claim)
assert_equal 0, contract.claims.length
end
end