MCPcopy
hub / github.com/EngoEngine/engo / TestMessageCounterSimple

Function TestMessageCounterSimple

message_test.go:13–31  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

11}
12
13func TestMessageCounterSimple(t *testing.T) {
14 mailbox := &MessageManager{}
15 msg := testMessageCounter{}
16 mailbox.Listen("testMessageCounter", func(message Message) {
17 m, ok := message.(*testMessageCounter)
18 if !ok {
19 t.Error("Message should be of type testMessageCounter")
20 }
21 m.counter++
22 })
23 mailbox.Dispatch(&msg)
24 if msg.counter != 1 {
25 t.Error("Message should have been received 1 times by now")
26 }
27 mailbox.Dispatch(&msg)
28 if msg.counter != 2 {
29 t.Error("Message should have been received 2 times by now")
30 }
31}
32
33func TestMessageCounterWithRemoval(t *testing.T) {
34 mailbox := &MessageManager{}

Callers

nothing calls this directly

Calls 3

ListenMethod · 0.95
DispatchMethod · 0.95
ErrorMethod · 0.45

Tested by

no test coverage detected