public void A_card_which_was_created_during_the_period()
        {
            // Given
            card.Size = 5;
            var cardEvent = new CardEvent
            {
                Type     = "CardCreationEvent",
                DateTime = LeanKitConversions.DateTimeToCardEventDateTime(currentDate.AddDays(-2))
            };

            history.Add(cardEvent);

            ApiSetupGetCardHistory(card.Id);

            // When
            var target = new LeanKitCardViewHistory(mockApi.Object, boardId, card, 5, currentDate);

            // Then
            Assert.AreEqual(5, target.PointsPerDay.Count);

            Assert.AreEqual(card.Size, target.PointsPerDay[0].Points, "Incorrect points for day 0");
            Assert.AreEqual(card.Size, target.PointsPerDay[1].Points, "Incorrect points for day 1");
            Assert.AreEqual(0, target.PointsPerDay[2].Points, "Incorrect points for day 2");
            Assert.AreEqual(0, target.PointsPerDay[3].Points, "Incorrect points for day 3");
            Assert.AreEqual(0, target.PointsPerDay[4].Points, "Incorrect points for day 4");
        }
        public void A_card_which_moves_lane()
        {
            // Given
            var cardEvent = new CardEvent
            {
                Type       = "CardMoveEvent",
                DateTime   = LeanKitConversions.DateTimeToCardEventDateTime(currentDate.AddDays(-2)),
                FromLaneId = 5,
                ToLaneId   = card.LaneId
            };

            history.Add(cardEvent);

            ApiSetupGetCardHistory(card.Id);

            // When
            target = new LeanKitCardViewHistory(mockApi.Object, boardId, card, 5, currentDate);

            // Then
            Assert.AreEqual(5, target.PointsPerDay.Count);

            Assert.AreEqual(card.LaneId, target.PointsPerDay[0].LaneId, "Incorrect lane id for day 0");
            Assert.AreEqual(card.LaneId, target.PointsPerDay[1].LaneId, "Incorrect lane id for day 1");
            Assert.AreEqual(cardEvent.FromLaneId, target.PointsPerDay[2].LaneId, "Incorrect lane id for day 2");
            Assert.AreEqual(cardEvent.FromLaneId, target.PointsPerDay[3].LaneId, "Incorrect lane id for day 3");
            Assert.AreEqual(cardEvent.FromLaneId, target.PointsPerDay[4].LaneId, "Incorrect lane id for day 4");
        }
        public void A_card_in_the_ToDo_lane_with_history_and_a_card_in_the_archive_with_no_history()
        {
            // Given
            AddDefaultLanesToBoard();
            ApiSetupGetBoard(mockBoard.Id);

            var card = new CardView {
                Id = 350, LaneId = mockDoingLane.Id ?? 0, Size = 5
            };
            var history = AddCardToLane(mockBoard.Id, mockDoingLane, card);

            var cardEvent = new CardEvent
            {
                Type       = "CardMoveEvent",
                DateTime   = LeanKitConversions.DateTimeToCardEventDateTime(DateTime.Now.AddDays(-1)),
                FromLaneId = mockToDoLane.Id ?? 0,
                ToLaneId   = mockDoingLane.Id ?? 0
            };

            history.Add(cardEvent);

            card = new CardView {
                Id = 200, LaneId = mockDoingLane.Id ?? 0, Size = 10
            };
            AddCardToLane(mockBoard.Id, mockDoingLane, card);

            // When
            RunTest(boardId: mockBoard.Id, numberOfDaysHistory: 5);

            // Then
            ActualLane(mockBacklogLane).AssertLaneHistoryIs(AllAre(value: 0, numberOfElements: 5), "Backlog");
            ActualLane(mockToDoLane).AssertLaneHistoryIs(new List <int> {
                0, 5, 5, 5, 5
            }, "To Do");
            ActualLane(mockDoingLane).AssertLaneHistoryIs(new List <int> {
                15, 10, 10, 10, 10
            }, "Doing");
            ActualLane(mockDoneLane).AssertLaneHistoryIs(AllAre(value: 0, numberOfElements: 5), "Done");
            ActualLane(mockArchiveLane).AssertLaneHistoryIs(AllAre(value: 0, numberOfElements: 5), "Archive");
        }
        public void A_card_which_changes_size()
        {
            // Given
            int oldSize = 2;

            card.Size = 5;
            var cardEvent = new CardEvent
            {
                Type     = "CardFieldsChangedEvent",
                DateTime = LeanKitConversions.DateTimeToCardEventDateTime(currentDate.AddDays(-3)),
                Changes  = new List <CardEvent.FieldChange>
                {
                    new CardEvent.FieldChange {
                        FieldName = "Description", OldValue = "XYZ"
                    },
                    new CardEvent.FieldChange {
                        FieldName = "Size", OldValue = oldSize.ToString()
                    }
                }
            };

            history.Add(cardEvent);

            ApiSetupGetCardHistory(card.Id);

            // When
            var target = new LeanKitCardViewHistory(mockApi.Object, boardId, card, 5, currentDate);

            // Then
            Assert.AreEqual(5, target.PointsPerDay.Count);

            Assert.AreEqual(card.Size, target.PointsPerDay[0].Points, "Incorrect points for day 0");
            Assert.AreEqual(card.Size, target.PointsPerDay[1].Points, "Incorrect points for day 1");
            Assert.AreEqual(card.Size, target.PointsPerDay[2].Points, "Incorrect points for day 2");
            Assert.AreEqual(oldSize, target.PointsPerDay[3].Points, "Incorrect points for day 3");
            Assert.AreEqual(oldSize, target.PointsPerDay[4].Points, "Incorrect points for day 4");
        }