2017-03-19 00:09:43 +08:00
|
|
|
package microbit
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"gobot.io/x/gobot"
|
|
|
|
"gobot.io/x/gobot/gobottest"
|
|
|
|
)
|
|
|
|
|
|
|
|
var _ gobot.Driver = (*MagnetometerDriver)(nil)
|
|
|
|
|
|
|
|
func initTestMagnetometerDriver() *MagnetometerDriver {
|
2017-04-05 18:40:17 +08:00
|
|
|
d := NewMagnetometerDriver(NewBleTestAdaptor())
|
2017-03-19 00:09:43 +08:00
|
|
|
return d
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestMagnetometerDriver(t *testing.T) {
|
|
|
|
d := initTestMagnetometerDriver()
|
|
|
|
gobottest.Assert(t, strings.HasPrefix(d.Name(), "Microbit Magnetometer"), true)
|
2017-04-05 18:40:17 +08:00
|
|
|
d.SetName("NewName")
|
|
|
|
gobottest.Assert(t, d.Name(), "NewName")
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestMagnetometerDriverStartAndHalt(t *testing.T) {
|
|
|
|
d := initTestMagnetometerDriver()
|
|
|
|
gobottest.Assert(t, d.Start(), nil)
|
|
|
|
gobottest.Assert(t, d.Halt(), nil)
|
2017-03-19 00:09:43 +08:00
|
|
|
}
|