コード例 #1
0
        public async Task Handle(OpenTask command)
        {
            var card = new CardAggregate(command.Id);

            card.OpenTask(command.Title);

            await _store.Save(card);
        }
コード例 #2
0
        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());
        }
コード例 #3
0
        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);
        }