-
Notifications
You must be signed in to change notification settings - Fork 1
/
hsms_state_test.rb
52 lines (48 loc) · 1.52 KB
/
hsms_state_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
require "test/unit"
require "hsms_state"
class TestHSMSState < Test::Unit::TestCase
def test_connect_state
c = ConnectState.new
assert_equal(false, c.is_connect)
assert_equal("NOT CONNECTED", c.to_s)
c.connected
assert_equal(true, c.is_connect)
assert_equal("CONNECTED", c.to_s)
c.disconnected
assert_equal(false, c.is_connect)
assert_equal("NOT CONNECTED", c.to_s)
end
def test_select_state
s = SelectState.new
assert_equal(false, s.is_select)
assert_equal("NOT SELECTED", s.to_s)
s.selected
assert_equal(true, s.is_select)
assert_equal("SELECTED", s.to_s)
s.deselected
assert_equal(false, s.is_select)
assert_equal("NOT SELECTED", s.to_s)
end
def test_hsms_state
h = HSMSState.new
assert_equal(false, h.is_connect)
assert_equal(false, h.is_select)
assert_equal("HSMS Status: NOT CONNECTED, NOT SELECTED", h.to_s)
h.connected
assert_equal(true, h.is_connect)
assert_equal(false, h.is_select)
assert_equal("HSMS Status: CONNECTED, NOT SELECTED", h.to_s)
h.selected
assert_equal(true, h.is_connect)
assert_equal(true, h.is_select)
assert_equal("HSMS Status: CONNECTED, SELECTED", h.to_s)
h.deselected
assert_equal(true, h.is_connect)
assert_equal(false, h.is_select)
assert_equal("HSMS Status: CONNECTED, NOT SELECTED", h.to_s)
h.disconnected
assert_equal(false, h.is_connect)
assert_equal(false, h.is_select)
assert_equal("HSMS Status: NOT CONNECTED, NOT SELECTED", h.to_s)
end
end