public async Task Handle(OpenTask command) { var card = new CardAggregate(command.Id); card.OpenTask(command.Title); await _store.Save(card); }
public void TaskIsOpened() { var card = new CardAggregate(RandomId()); card.OpenTask("Test"); var changes = card.GetChanges(); changes.Should().BeEquivalentTo(new[] { new TaskOpened(card.Id, DateTime.UtcNow, "Test"), }, opt => opt.Excluding(x => x.DateOpened).WithStrictOrdering()); }
public async Task SavesCardAggregateChangesToStream() { var cardId = RandomId(); var card = new CardAggregate(cardId); card.OpenTask("Test"); card.AssignTo("Jason Mitchell"); card.StartDevelopment(); var expectedChanges = card.GetChanges().ToArray(); await _aggregateStore.Save(card); var streamName = $"Card-{cardId}"; await _esdb.AssertStreamExists(streamName); await _esdb.AssertEvents(streamName, expectedChanges); }