22 lines
709 B
Elixir
22 lines
709 B
Elixir
defmodule Scopes.CoreActorTest do
|
|
use ExUnit.Case, async: true
|
|
alias Scopes.Core.Actor
|
|
|
|
describe "actors:" do
|
|
test "basic-life-cycle" do
|
|
Registry.start_link(keys: :unique, name: Actors)
|
|
this = self()
|
|
ac = Actor.create(fn msg -> send(this, msg) end)
|
|
# Actor.register(Actors, :demo, [])
|
|
# [{pid, _value}] = Registry.lookup(Actors, :demo)
|
|
# assert pid == ac
|
|
Actor.send(ac, "Hello Actor!")
|
|
assert_receive "Hello Actor!"
|
|
Actor.become(ac, fn _msg -> send(this, "Goodbye") end)
|
|
Actor.send(ac, "Hello Actor!")
|
|
Actor.stop(ac)
|
|
assert_receive "Goodbye"
|
|
refute_received msg, "unhandled message(s): #{inspect(msg)}"
|
|
end
|
|
end
|
|
end
|