go-pattern-examples/structure/02_adapter/adapter_test.go

23 lines
405 B
Go
Raw Normal View History

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