go-pattern-examples/behavior/03_observer/obserser_test.go
2020-05-02 21:23:04 +08:00

30 lines
513 B
Go
Raw Permalink 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 observer
import (
"context"
"testing"
)
func TestObserver(t *testing.T) {
//内容提供商科技BBS
techInfoProvider := TechBBS{}
lily := User{"Lily"}
jacky := User{"Jacky"}
techInfoProvider.Registry(&lily)
techInfoProvider.Registry(&jacky)
updateKey := updates{}
updateValue := updates{topic: "cosmos", order: 1001}
updateContent := context.WithValue(context.Background(), updateKey, updateValue)
techInfoProvider.SetConext(updateContent)
techInfoProvider.noticeAllUpdate()
}