public void incorrect_items_stay_in_review_queue_until_correct()
        {
            var items = new ReviewItemListBuilder()
                        .WithDueItems(1)
                        .Build();
            var session = new StudySession <ReviewItem>(items);

            var incorrectTimes = 0;

            foreach (var reviewItem in session)
            {
                if (incorrectTimes++ < 3)
                {
                    session.Review(reviewItem, ReviewOutcome.Incorrect);
                }
                else
                {
                    break;
                }
            }

            session.Review(session.First(), ReviewOutcome.Perfect);

            Assert.That(session, Is.Empty);
        }
        public void item_is_not_due_for_review()
        {
            var items = new ReviewItemListBuilder()
                        .WithFutureItems(1)
                        .Build();

            var session = new StudySession <ReviewItem>(items);

            Assert.That(session.IsDue(items.First()), Is.False);
        }
        public void limit_existing_cards_per_session()
        {
            var items   = new ReviewItemListBuilder().WithExistingItems(_maxExistingCardsPerSession + 1).Build();
            var session = new StudySession <ReviewItem>(items)
            {
                MaxExistingCards = _maxExistingCardsPerSession
            };

            Assert.That(session.Count(), Is.EqualTo(_maxExistingCardsPerSession));
        }
        public void only_return_due_items()
        {
            var dueItems = 2;
            var items    = new ReviewItemListBuilder()
                           .WithDueItems(dueItems)
                           .WithFutureItems(3)
                           .Build();
            var session = new StudySession <ReviewItem>(items);

            Assert.That(session.Count(), Is.EqualTo(dueItems));
        }
        public void incorrect_items_stay_in_review_queue()
        {
            var items = new ReviewItemListBuilder()
                        .WithDueItems(1)
                        .Build();
            var session = new StudySession <ReviewItem>(items);

            var item   = session.First();
            var review = session.Review(item, ReviewOutcome.Incorrect);

            Assert.That(session.First(), Is.EqualTo(review));
        }
        public void correct_items_are_removed_from_review_queue(ReviewOutcome outcome)
        {
            var items = new ReviewItemListBuilder()
                        .WithDueItems(1)
                        .Build();
            var session = new StudySession <ReviewItem>(items);

            var item = session.First();

            session.Review(item, outcome);

            Assert.That(session.Count(), Is.EqualTo(0));
        }
        public void limit_existing_cards_when_there_are_also_new_cards()
        {
            var items = new ReviewItemListBuilder()
                        .WithExistingItems(_maxExistingCardsPerSession - 1)
                        .WithNewItems(1)
                        .WithExistingItems(2)
                        .Build();

            var session = new StudySession <ReviewItem>(items)
            {
                MaxExistingCards = _maxExistingCardsPerSession
            };

            Assert.That(session.Count(x => x.ReviewDate != DateTime.MinValue), Is.EqualTo(_maxExistingCardsPerSession));
        }
        public void item_is_not_due_for_review()
        {
            var items = new ReviewItemListBuilder()
                   .WithFutureItems(1)
                   .Build();

            var session = new StudySession<ReviewItem>(items);

            Assert.That(session.IsDue(items.First()), Is.False);

        }
        public void limit_existing_cards_when_there_are_also_new_cards()
        {
            var items = new ReviewItemListBuilder()
                               .WithExistingItems(_maxExistingCardsPerSession - 1)
                               .WithNewItems(1)
                               .WithExistingItems(2)
                               .Build();

            var session = new StudySession<ReviewItem>(items) { MaxExistingCards = _maxExistingCardsPerSession};

            Assert.That(session.Count(x => x.ReviewDate != DateTime.MinValue), Is.EqualTo(_maxExistingCardsPerSession));
        }
        public void limit_existing_cards_per_session()
        {
            var items = new ReviewItemListBuilder().WithExistingItems(_maxExistingCardsPerSession + 1).Build();
            var session = new StudySession<ReviewItem>(items) { MaxExistingCards = _maxExistingCardsPerSession };

            Assert.That(session.Count(), Is.EqualTo(_maxExistingCardsPerSession));
        }
        public void only_return_due_items()
        {
            var dueItems = 2;
            var items = new ReviewItemListBuilder()
                            .WithDueItems(dueItems)
                            .WithFutureItems(3)
                            .Build();
            var session = new StudySession<ReviewItem>(items);

            Assert.That(session.Count(), Is.EqualTo(dueItems));
        }
        public void incorrect_items_stay_in_review_queue_until_correct()
        {
            var items = new ReviewItemListBuilder()
                            .WithDueItems(1)
                            .Build();
            var session = new StudySession<ReviewItem>(items);

            var incorrectTimes = 0;
            foreach (var reviewItem in session)
            {
                if (incorrectTimes++ < 3)
                    session.Review(reviewItem, ReviewOutcome.Incorrect);
                else break;
            }

            session.Review(session.First(), ReviewOutcome.Perfect);

            Assert.That(session, Is.Empty);
        }
        public void incorrect_items_stay_in_review_queue()
        {
            var items = new ReviewItemListBuilder()
                            .WithDueItems(1)
                            .Build();
            var session = new StudySession<ReviewItem>(items);

            var item = session.First();
            var review = session.Review(item, ReviewOutcome.Incorrect);

            Assert.That(session.First(), Is.EqualTo(review));
        }
        public void correct_items_are_removed_from_review_queue(ReviewOutcome outcome)
        {
            var items = new ReviewItemListBuilder()
                            .WithDueItems(1)
                            .Build();
            var session = new StudySession<ReviewItem>(items);

            var item = session.First();
            session.Review(item, outcome);

            Assert.That(session.Count(), Is.EqualTo(0));
        }