go-pattern-examples/structure/02_adapter/adapter_test.go
2020-04-30 16:30:18 +08:00

23 lines
405 B
Go

package adapter
import (
"testing"
)
func TestPowerSocketAdapter(t *testing.T) {
plug := &TwoPinPlugin{}
threePinSocket := ThreePinPowerSocket{}
//三孔插头是不能为两针插头充电的,可以试试看
threePinSocket.ThreePinCharging(plug)
//只好加一个电源适配器
powersocket := NewPowerAdapter(&threePinSocket)
//再试试能不能充电
powersocket.PlugCharging(plug)
}