forked from hybridgroup/gobot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdevice_information_driver_test.go
79 lines (63 loc) · 2.09 KB
/
device_information_driver_test.go
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
package ble
import (
"strings"
"testing"
"gobot.io/x/gobot"
"gobot.io/x/gobot/gobottest"
)
var _ gobot.Driver = (*DeviceInformationDriver)(nil)
func initTestDeviceInformationDriver() *DeviceInformationDriver {
d := NewDeviceInformationDriver(NewBleTestAdaptor())
return d
}
func TestDeviceInformationDriver(t *testing.T) {
d := initTestDeviceInformationDriver()
gobottest.Assert(t, strings.HasPrefix(d.Name(), "DeviceInformation"), true)
d.SetName("NewName")
gobottest.Assert(t, d.Name(), "NewName")
}
func TestDeviceInformationDriverStartAndHalt(t *testing.T) {
d := initTestDeviceInformationDriver()
gobottest.Assert(t, d.Start(), nil)
gobottest.Assert(t, d.Halt(), nil)
}
func TestDeviceInformationDriverGetModelNumber(t *testing.T) {
a := NewBleTestAdaptor()
d := NewDeviceInformationDriver(a)
a.TestReadCharacteristic(func(cUUID string) ([]byte, error) {
return []byte("TestDevice"), nil
})
gobottest.Assert(t, d.GetModelNumber(), "TestDevice")
}
func TestDeviceInformationDriverGetFirmwareRevision(t *testing.T) {
a := NewBleTestAdaptor()
d := NewDeviceInformationDriver(a)
a.TestReadCharacteristic(func(cUUID string) ([]byte, error) {
return []byte("TestDevice"), nil
})
gobottest.Assert(t, d.GetFirmwareRevision(), "TestDevice")
}
func TestDeviceInformationDriverGetHardwareRevision(t *testing.T) {
a := NewBleTestAdaptor()
d := NewDeviceInformationDriver(a)
a.TestReadCharacteristic(func(cUUID string) ([]byte, error) {
return []byte("TestDevice"), nil
})
gobottest.Assert(t, d.GetHardwareRevision(), "TestDevice")
}
func TestDeviceInformationDriverGetManufacturerName(t *testing.T) {
a := NewBleTestAdaptor()
d := NewDeviceInformationDriver(a)
a.TestReadCharacteristic(func(cUUID string) ([]byte, error) {
return []byte("TestDevice"), nil
})
gobottest.Assert(t, d.GetManufacturerName(), "TestDevice")
}
func TestDeviceInformationDriverGetPnPId(t *testing.T) {
a := NewBleTestAdaptor()
d := NewDeviceInformationDriver(a)
a.TestReadCharacteristic(func(cUUID string) ([]byte, error) {
return []byte("TestDevice"), nil
})
gobottest.Assert(t, d.GetPnPId(), "TestDevice")
}