hybridgroup.gobot/gobot_test.go

37 lines
772 B
Go
Raw Normal View History

2013-12-31 08:51:21 +08:00
package gobot
import (
2014-06-13 05:38:03 +08:00
"log"
2014-04-27 00:24:43 +08:00
"os"
2014-06-13 05:38:03 +08:00
"testing"
2013-12-31 08:51:21 +08:00
)
2014-06-13 05:38:03 +08:00
var g *Gobot
2013-12-31 08:51:21 +08:00
2014-06-13 05:38:03 +08:00
func init() {
2014-06-14 05:46:07 +08:00
log.SetOutput(new(Null))
2014-06-13 05:38:03 +08:00
g = NewGobot()
g.trap = func(c chan os.Signal) {
c <- os.Interrupt
}
g.Robots = []*Robot{
2014-06-14 05:46:07 +08:00
NewTestRobot("Robot 1"),
NewTestRobot("Robot 2"),
NewTestRobot("Robot 3"),
2014-06-13 05:38:03 +08:00
}
}
2013-12-31 08:51:21 +08:00
2014-06-13 05:38:03 +08:00
func TestStart(t *testing.T) {
g.Start()
}
2014-05-03 18:22:22 +08:00
2014-06-13 05:38:03 +08:00
func TestRobot(t *testing.T) {
Expect(t, g.Robot("Robot 1").Name, "Robot 1")
Expect(t, g.Robot("Robot 4"), (*Robot)(nil))
Expect(t, g.Robot("Robot 1").Device("Device 4"), (*device)(nil))
Expect(t, g.Robot("Robot 1").Device("Device 1").Name, "Device 1")
Expect(t, len(g.Robot("Robot 1").Devices()), 3)
Expect(t, g.Robot("Robot 1").Connection("Connection 4"), (*connection)(nil))
Expect(t, len(g.Robot("Robot 1").Connections()), 3)
}