-
Notifications
You must be signed in to change notification settings - Fork 15
/
contract_test.rb
29 lines (22 loc) · 1.11 KB
/
contract_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
require "test/unit"
require "date"
require_relative './contract'
class ContractTest < Test::Unit::TestCase
def test_contract_is_setup_correctly
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))
assert_equal 100, contract.purchase_price
assert_equal "PENDING", contract.status
assert_equal Product.new("dishwasher", "OEUOEU23", "Whirlpool", "7DP840CWDB0"), contract.covered_product
end
# entities compare by unique IDs, not properties
def test_contract_equality
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_same_id = contract.clone
contract_same_id.status = "ACTIVE"
assert_equal contract, contract_same_id
contract_different_id = Contract.new(100.0, product, Date.new(2010, 5, 8), Date.new(2010, 5, 8), Date.new(2012, 5, 8))
assert_not_equal contract, contract_different_id
end
end