go-pattern-examples/structure/03_bridge/bridge_test.go
2020-05-02 17:40:51 +08:00

28 lines
657 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package bridge
import "testing"
func TestSendMessage(t *testing.T) {
//注意看这里,接口的实例关系在初始化时候是固定的
ws := &WSMessage{&EmergencyWSMessage{}, 100}
//注意看这里,接口的实例关系在初始化时候是固定的
email := &EmailMessage{&EmergencyEmailMessage{}, 10}
ws.NoticeUser("Miss White ,Let's Drink")
email.NoticeUser("Miss White,Fire!,Fire!")
ews := &EmergencyWSMessage{}
eem := &EmergencyEmailMessage{}
list := []IMessage{
&WSMessage{ews, 50},
&WSMessage{ews, 100},
&EmailMessage{eem, 10},
&EmailMessage{eem, 20},
}
for _, v := range list {
v.NoticeUser("Lets go for fun")
}
}