| 296 | } |
| 297 | |
| 298 | func TestPID_Tell(t *testing.T) { |
| 299 | system := NewSystem("test") |
| 300 | defer system.Shutdown() |
| 301 | |
| 302 | counter := &CounterActor{} |
| 303 | pid := system.Spawn(counter, "counter") |
| 304 | |
| 305 | // 使用 PID.Tell 发送消息 |
| 306 | pid.Tell(&CountMsg{Value: 100}) |
| 307 | time.Sleep(50 * time.Millisecond) |
| 308 | |
| 309 | replyCh := make(chan int, 1) |
| 310 | pid.Tell(&GetCountMsg{ReplyTo: replyCh}) |
| 311 | |
| 312 | select { |
| 313 | case count := <-replyCh: |
| 314 | assert.Equal(t, 100, count) |
| 315 | case <-time.After(time.Second): |
| 316 | t.Fatal("timeout") |
| 317 | } |
| 318 | } |
| 319 | |
| 320 | func TestPID_Request(t *testing.T) { |
| 321 | system := NewSystem("test") |