コード例 #1
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());
        }
コード例 #2
0
        public void CardIsAssigned()
        {
            var cardId = RandomId();
            var card   = new CardAggregate(cardId);

            card.Load(new[]
            {
                new TaskOpened(cardId, DateTime.UtcNow, "Test")
            });

            card.AssignTo("Jason Mitchell");

            var changes = card.GetChanges();

            changes.Should().BeEquivalentTo(new CardAssigned(card.Id, null, "Jason Mitchell"));
        }
コード例 #3
0
        public void NoChangesAreRaisedWhenAssigneeHasNotChanged()
        {
            var cardId = RandomId();
            var card   = new CardAggregate(cardId);

            card.Load(new Event[]
            {
                new TaskOpened(cardId, DateTime.UtcNow, "Test"),
                new CardAssigned(card.Id, null, "Jason Mitchell")
            });

            card.AssignTo("Jason Mitchell");

            var changes = card.GetChanges();

            changes.Should().BeEmpty();
        }
コード例 #4
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);
        }
コード例 #5
0
        public void NoChangesAreRaisedWhenDevelopmentHasAlreadyStarted()
        {
            var cardId = RandomId();
            var card   = new CardAggregate(cardId);

            card.Load(new Event[]
            {
                new TaskOpened(cardId, DateTime.UtcNow, "Test"),
                new CardAssigned(card.Id, null, "Jason Mitchell"),
                new DevelopmentStarted(cardId, DateTime.UtcNow)
            });

            card.StartDevelopment();

            var changes = card.GetChanges();

            changes.Should().BeEmpty();
        }
コード例 #6
0
        public void DevelopmentIsStarted()
        {
            var cardId = RandomId();
            var card   = new CardAggregate(cardId);

            card.Load(new Event[]
            {
                new TaskOpened(cardId, DateTime.UtcNow, "Test"),
                new CardAssigned(card.Id, null, "Jason Mitchell")
            });

            card.StartDevelopment();

            var changes = card.GetChanges();

            changes.Should().BeEquivalentTo(new[]
            {
                new DevelopmentStarted(card.Id, DateTime.UtcNow),
            }, opt => opt.Excluding(x => x.DateStarted).WithStrictOrdering());
        }