go-pattern-examples/creation/05_abstract_factory/abstractfactory_test.go

25 lines
485 B
Go
Raw Normal View History

2020-04-21 17:50:21 +03:00
package abstractfactory
func getMainAndDetail(factory DAOFactory) {
factory.CreateOrderMainDAO().SaveOrderMain()
factory.CreateOrderDetailDAO().SaveOrderDetail()
}
func ExampleRdbFactory() {
var factory DAOFactory
factory = &RDBDAOFactory{}
getMainAndDetail(factory)
// Output:
// rdb main save
// rdb detail save
}
func ExampleXmlFactory() {
var factory DAOFactory
factory = &XMLDAOFactory{}
getMainAndDetail(factory)
// Output:
// xml main save
// xml detail save
}