View Source OnePiece.Commanded.TestSupport.CommandHandlerCase (OnePiece.Commanded v0.11.0)

This module helps with test cases for testing aggregate states, and command handlers.

usage

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

Link to this section Summary

Link to this section 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

assert_state(initial_events, command, expected_state, aggregate_module, command_handler_module)

View Source