mirror of
https://github.com/crazybber/go-pattern-examples.git
synced 2024-11-25 13:16:02 +03:00
31 lines
670 B
Go
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()
|
|
}
|