This commit is contained in:
parent
450ca4d53a
commit
c7d3b139fe
43
apps/amethyst/test/game_coordinator_test.exs
Normal file
43
apps/amethyst/test/game_coordinator_test.exs
Normal file
@ -0,0 +1,43 @@
|
||||
defmodule GameCoordinatorTestGame do
|
||||
use Amethyst.API.Game
|
||||
|
||||
@moduledoc """
|
||||
This module is a sample game for the purpose of
|
||||
testing the GameCoordinator
|
||||
"""
|
||||
|
||||
@impl true
|
||||
def instantiate() do
|
||||
{:ok, :example_state}
|
||||
end
|
||||
|
||||
@impl true
|
||||
def login(_connection_process, _player_cfg, state) do
|
||||
{:ok, state}
|
||||
end
|
||||
end
|
||||
|
||||
defmodule GameCoordinatorTest do
|
||||
use ExUnit.Case, async: true
|
||||
|
||||
@moduledoc """
|
||||
This module includes tests for Amethyst.GameCoordinator
|
||||
"""
|
||||
|
||||
test "Create an instance of a game with create/1 then kill it" do
|
||||
pid = Amethyst.GameCoordinator.create(GameCoordinatorTestGame)
|
||||
assert Process.alive?(pid)
|
||||
assert Amethyst.GameCoordinator.find(GameCoordinatorTestGame) == pid
|
||||
Process.exit(pid, :kill)
|
||||
assert Amethyst.GameCoordinator.find(GameCoordinatorTestGame) == nil
|
||||
end
|
||||
|
||||
test "Create new instance with find_or_create/1 if one doesn't exist, otherwise use it" do
|
||||
pid = Amethyst.GameCoordinator.find_or_create(GameCoordinatorTestGame)
|
||||
assert Process.alive?(pid)
|
||||
assert Amethyst.GameCoordinator.find_or_create(GameCoordinatorTestGame) == pid
|
||||
Process.exit(pid, :kill)
|
||||
assert Amethyst.GameCoordinator.find_or_create(GameCoordinatorTestGame) != pid
|
||||
Amethyst.GameCoordinator.find(GameCoordinatorTestGame) |> Process.exit(:kill)
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user