Class: Sequent::Test::CommandHandlerHelpers::FakeEventStore
- Inherits:
-
Object
- Object
- Sequent::Test::CommandHandlerHelpers::FakeEventStore
- Defined in:
- lib/sequent/test/command_handler_helpers.rb
Instance Method Summary collapse
- #commit_events(_, events) ⇒ Object
- #given_events(events) ⇒ Object
-
#initialize ⇒ FakeEventStore
constructor
A new instance of FakeEventStore.
- #load_events(aggregate_id) ⇒ Object
- #stored_events ⇒ Object
Constructor Details
#initialize ⇒ FakeEventStore
Returns a new instance of FakeEventStore.
38 39 40 41 |
# File 'lib/sequent/test/command_handler_helpers.rb', line 38 def initialize @all_events = [] @stored_events = [] end |
Instance Method Details
#commit_events(_, events) ⇒ Object
51 52 53 54 55 |
# File 'lib/sequent/test/command_handler_helpers.rb', line 51 def commit_events(_, events) serialized = serialize_events(events) @all_events += serialized @stored_events += serialized end |
#given_events(events) ⇒ Object
57 58 59 60 |
# File 'lib/sequent/test/command_handler_helpers.rb', line 57 def given_events(events) @all_events += serialize_events(events) @stored_events = [] end |
#load_events(aggregate_id) ⇒ Object
43 44 45 |
# File 'lib/sequent/test/command_handler_helpers.rb', line 43 def load_events(aggregate_id) deserialize_events(@all_events).select { |event| aggregate_id == event.aggregate_id } end |
#stored_events ⇒ Object
47 48 49 |
# File 'lib/sequent/test/command_handler_helpers.rb', line 47 def stored_events deserialize_events(@stored_events) end |