コード例 #1
0
        public void HandlesCardAssigned()
        {
            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.Assignee.Should().Be("Jason Mitchell");
        }
コード例 #2
0
        public void DoesNotAllowDevelopmentToStartWithoutAssignee()
        {
            var cardId = RandomId();
            var card   = new CardAggregate(cardId);

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

            Action action = () => card.StartDevelopment();

            action.Should().ThrowExactly <AssigneeIsRequiredException>();
        }
コード例 #3
0
        public void HandlesDevelopmentStarted()
        {
            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.Status.Should().Be(CardStatus.InProgress);
        }
コード例 #4
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"));
        }
コード例 #5
0
        public void HandlesTaskOpened()
        {
            var cardId     = RandomId();
            var dateOpened = DateTime.UtcNow;
            var card       = new CardAggregate(cardId);

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

            card.Type.Should().Be(CardType.Task);
            card.DateOpened.Should().Be(dateOpened);
            card.Status.Should().Be(CardStatus.ToDo);
            card.Title.Should().Be("Test");
        }
コード例 #6
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();
        }
コード例 #7
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();
        }
コード例 #8
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());
        }