go-pattern-examples/creation/05_abstract_factory/abstractfactory_test.go
2020-04-27 11:55:19 +08:00

31 lines
670 B
Go

package abstractfactory
import "testing"
func TestRobotBatteryFactory(t *testing.T) {
factory := &HomeRobotFactory{}
robot := factory.CreateRobot()
robot.DoWork()
battery := factory.CreateBattery()
battery.Charge(robot)
}
func TestSQLFactory(t *testing.T) {
factory := &SQLFactory{}
orderWorker := factory.CreateOrderWorker()
orderWorker.SaveOrder()
detailWorker := factory.CreateOrderDetailWorker()
detailWorker.SaveOrderDetail()
}
func TestNoSqlFactory(t *testing.T) {
factory := &NoSQLFactory{}
orderWorker := factory.CreateOrderWorker()
orderWorker.SaveOrder()
detailWorker := factory.CreateOrderDetailWorker()
detailWorker.SaveOrderDetail()
}