View Source OnePiece.Commanded.TestSupport.CommandHandlerCase (OnePiece.Commanded v0.19.1)
This module helps with test cases for testing aggregate states, and command handlers.
Usage
After import the test support file, you should be able to have the module in your test files.
defmodule MyAggregateTest do
use OnePiece.Commanded.TestSupport.CommandHandlerCase,
aggregate: MyAggregate,
# You can also pass `handler` if you are using Command Handler modules
# handler: MyCommandHandler,
async: true
describe "my aggregate" do
test "should do something" do
assert_events(
[%InitialEvent{}],
%DoSomething{},
[%SomethingHappened{}]
)
end
test "the state" do
assert_state(
[%InitialEvent{}],
%DoSomething{},
%MyAggregate{}
)
end
test "the error" do
assert_error(
[%InitialEvent{}],
%DoSomething{},
:already_exists
)
end
end
end
Summary
Functions
Link to this function
assert_error(initial_events, command, expected_error, aggregate_module, command_handler_module)
View Source
Link to this function
assert_events(initial_events, command, expected_events, aggregate_module, command_handler_module)
View Source
Link to this function