Class: TestInsteon_2412N_Insteon_Codec

Inherits:
Test::Unit::TestCase
  • Object
show all
Defined in:
lib/belphanior/servant/homenetwork/test/tc_insteon_2412n_insteon_codec.rb

Overview

Test of INSTEON code generator for Insteon 2412N central controller

Instance Method Summary collapse

Instance Method Details

#setupObject



10
11
12
13
14
15
16
# File 'lib/belphanior/servant/homenetwork/test/tc_insteon_2412n_insteon_codec.rb', line 10

def setup
  @marshaller = mock(
    'Belphanior::Servant::HomeNetwork::Insteon_2412n_Marshaller')
  @codec = Belphanior::Servant::HomeNetwork::Insteon_2412n_Insteon_Codec.new(
    @marshaller)
  @insteon_prefix = "0262"
end

#test_brightnessObject



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
# File 'lib/belphanior/servant/homenetwork/test/tc_insteon_2412n_insteon_codec.rb', line 27

def test_brightness
  address = "001122"
  on_code = "11"
  @marshaller.expects(:send).with(
    @insteon_prefix + address + "0F" + on_code + "00")
  @codec.device_set_brightness(address, 0)

  @marshaller.expects(:send).with(
    @insteon_prefix + address + "0F" + on_code + "FF")
  @codec.device_set_brightness(address, 1)

  # Exact equality
  @marshaller.expects(:send).with(
    @insteon_prefix + address + "0F" + on_code + "7F")
  @codec.device_set_brightness(address, 0.5)

  # Near-equality
  @marshaller.expects(:send).with(
    @insteon_prefix + address + "0F" + on_code + "7F")
  @codec.device_set_brightness(address, 0.4)

  # Out of bounds
  @marshaller.expects(:send).with(
    @insteon_prefix + address + "0F" + on_code + "00")
  @codec.device_set_brightness(address, -1)

  @marshaller.expects(:send).with(
    @insteon_prefix + address + "0F" + on_code + "FF")
  @codec.device_set_brightness(address, 1.5)
end

#test_on_offObject



18
19
20
21
22
23
24
25
# File 'lib/belphanior/servant/homenetwork/test/tc_insteon_2412n_insteon_codec.rb', line 18

def test_on_off
  address = "001122"
  fast_on_code = "12"
  fast_off_code = "14"
  @marshaller.expects(:send).with(
    @insteon_prefix + address + "0F" + fast_on_code + "FF")
  @codec.device_on(address)
end