public void Last_bin_is_selected_as_first_with_any_cards_in_it()
        {
            var sut = new SelectDueCardProcessor();
            var ctx = new SelectDueCardContextModel
            {
                Bins = new[]
                {
                    new string[0],
                    new string[0],
                    new[] { "1", "2", "3" },
                    new[] { "a", "b", "c", "d", "e", "f", "g" }
                },

                DueBinIndex = 1,

                Config = new FlashcardboxConfig {
                    Bins = new [] {
                        new FlashcardboxConfig.Bin {
                            LowerDueThreshold = 2,
                            UpperDueThreshold = 4
                        },
                        new FlashcardboxConfig.Bin {
                            LowerDueThreshold = 3,
                            UpperDueThreshold = 5
                        }
                    }
                }
            };

            var(status, _, _, _) = sut.Process(new SelectDueCardCommand(), ctx, "");

            status.Should().BeOfType <Success>();
        }
        public void No_due_bin_continue_down_from_last_bin()
        {
            var sut = new SelectDueCardProcessor();
            var ctx = new SelectDueCardContextModel
            {
                Bins = new[]
                {
                    new string[0], // bin 0
                    new[] { "11" },
                    new[] { "21", "22", "23", "24", "25" },
                    new[] { "31" },
                    new[] { "41" } // bin 4, archive
                },

                DueBinIndex = -1,

                Config = __CONFIG
            };

            var(status, events, _, _) = sut.Process(new SelectDueCardCommand(), ctx, "");

            status.Should().BeOfType <Success>();
            events.Should().BeEquivalentTo(new[] {
                new DueCardSelected {
                    CardId = "21", BinIndex = 2, Id = events[0].Id
                }
            });
        }
        public void Config_defines_more_bins_than_have_been_filled()
        {
            var sut = new SelectDueCardProcessor();
            var ctx = new SelectDueCardContextModel
            {
                Bins = new[]
                {
                    new string[0], // bin 0
                    new[] { "11", "12", "13", "14" },
                },

                DueBinIndex = -1,

                Config = __CONFIG
            };

            var(status, events, _, _) = sut.Process(new SelectDueCardCommand(), ctx, "");

            status.Should().BeOfType <Success>();
            events.Should().BeEquivalentTo(new[] {
                new DueCardSelected {
                    CardId = "11", BinIndex = 1, Id = events[0].Id
                }
            });
        }
        public void Select_first_bin_to_contain_cards_after_bin_1()
        {
            var sut = new SelectDueCardProcessor();
            var ctx = new SelectDueCardContextModel
            {
                Bins = new[]
                {
                    new string[0],
                    new string[0],
                    new[] { "21" },
                    new[] { "31" },
                    new[] { "41" } // bin 4, archive
                },

                DueBinIndex = -1,

                Config = __CONFIG
            };

            var(status, events, _, _) = sut.Process(new SelectDueCardCommand(), ctx, "");

            status.Should().BeOfType <Success>();
            events.Should().BeEquivalentTo(
                new DueCardSelected {
                CardId = "21", BinIndex = 2, Id = events[0].Id
            });
        }
        public void Start_with_due_bin_and_give_it_up_continue_with_bin_1()
        {
            var sut = new SelectDueCardProcessor();
            var ctx = new SelectDueCardContextModel
            {
                Bins = new[]
                {
                    new string[0], // bin 0
                    new[] { "11", "12", "13", "14" },
                    new[] { "21" },
                    new[] { "31", "32", "33", "34", "35", "36" },
                    new[] { "41" } // bin 4, archive
                },

                DueBinIndex = 2,

                Config = __CONFIG
            };

            var(status, events, _, _) = sut.Process(new SelectDueCardCommand(), ctx, "");

            status.Should().BeOfType <Success>();
            events.Should().BeEquivalentTo(new[] {
                new DueCardSelected {
                    CardId = "11", BinIndex = 1, Id = events[0].Id
                }
            });
        }
Ejemplo n.º 6
0
        public void More_bins_than_config()
        {
            var ctx = new SelectDueCardContextModel
            {
                Bins = new [] {
                    new[] { "01", "02" },
                    new[] { "11", "12", "13" },
                    new[] { "21" },
                    new[] { "31", "32", "33", "34" },
                    new[] { "41", "42", "43", "44", "45" }
                },
                DueBinIndex = -1,
                Config      = __CONFIG
            };
            var sut = new ProgressProcessor();

            var result = sut.Process(new ProgressQuery(), ctx) as ProgressQueryResult;

            result.Should().BeEquivalentTo(new ProgressQueryResult {
                Bins = new [] {
                    new ProgressQueryResult.Bin {
                        Count = 2
                    },
                    new ProgressQueryResult.Bin {
                        Count             = 3,
                        LowerDueThreshold = 2,
                        UpperDueThreshold = 4
                    },
                    new ProgressQueryResult.Bin {
                        Count             = 1,
                        LowerDueThreshold = 3,
                        UpperDueThreshold = 5
                    },
                    new ProgressQueryResult.Bin {
                        Count = 4
                    },
                    new ProgressQueryResult.Bin {
                        Count = 5
                    },
                }
            });
            result.TotalCount.Should().Be(15);
        }
Ejemplo n.º 7
0
        public void Due_bin_with_matching_bins_and_config()
        {
            var ctx = new SelectDueCardContextModel
            {
                Bins = new [] {
                    new[] { "01", "02" },
                    new[] { "11", "12", "13" },
                    new[] { "21" },
                    new[] { "31", "32", "33", "34" }
                },
                DueBinIndex = 2,
                Config      = __CONFIG
            };
            var sut = new ProgressProcessor();

            var result = sut.Process(new ProgressQuery(), ctx) as ProgressQueryResult;

            result.Should().BeEquivalentTo(new ProgressQueryResult {
                Bins = new [] {
                    new ProgressQueryResult.Bin {
                        Count = 2
                    },
                    new ProgressQueryResult.Bin {
                        Count             = 3,
                        LowerDueThreshold = 2,
                        UpperDueThreshold = 4
                    },
                    new ProgressQueryResult.Bin {
                        Count             = 1,
                        LowerDueThreshold = 3,
                        UpperDueThreshold = 5,
                        IsDue             = true
                    },
                    new ProgressQueryResult.Bin {
                        Count = 4
                    },
                }
            });
            result.TotalCount.Should().Be(10);
        }
        public void Fill_up_bin_1_completely_from_bin_0()
        {
            var sut = new SelectDueCardProcessor();
            var ctx = new SelectDueCardContextModel
            {
                Bins = new[]
                {
                    new[] { "11", "12", "13", "14", "15" }, // bin 0
                    new string[0],
                    new[] { "21" },
                    new[] { "31" },
                    new[] { "41" } // bin 4, archive
                },

                DueBinIndex = -1,

                Config = __CONFIG
            };

            var(status, events, _, _) = sut.Process(new SelectDueCardCommand(), ctx, "");

            status.Should().BeOfType <Success>();
            events.Should().BeEquivalentTo(
                new CardMovedTo {
                CardId = "11", BinIndex = 1, Id = events[0].Id
            },
                new CardMovedTo {
                CardId = "12", BinIndex = 1, Id = events[1].Id
            },
                new CardMovedTo {
                CardId = "13", BinIndex = 1, Id = events[2].Id
            },
                new CardMovedTo {
                CardId = "14", BinIndex = 1, Id = events[3].Id
            },
                new DueCardSelected {
                CardId = "11", BinIndex = 1, Id = events[4].Id
            });
        }
        public void Report_failure_if_no_non_archive_bins_dont_contain_cards()
        {
            var sut = new SelectDueCardProcessor();
            var ctx = new SelectDueCardContextModel
            {
                Bins = new[]
                {
                    new string[0],
                    new string[0],
                    new string[0],
                    new string[0],
                    new[] { "41" } // bin 4, archive
                },

                DueBinIndex = -1,

                Config = __CONFIG
            };

            var(status, _, _, _) = sut.Process(new SelectDueCardCommand(), ctx, "");

            status.Should().BeOfType <Failure>();
        }
        public void Config_defines_fewer_bins_than_have_been_filled()
        {
            var sut = new SelectDueCardProcessor();
            var ctx = new SelectDueCardContextModel
            {
                Bins = new[]
                {
                    new string[0], // bin 0
                    new string[0],
                    new string[0],
                    new string[0],
                    new[] { "41" }, // new archive
                    new[] { "51" } // former archive
                },

                DueBinIndex = -1,

                Config = __CONFIG
            };

            var(status, _, _, _) = sut.Process(new SelectDueCardCommand(), ctx, "");

            status.Should().BeOfType <Failure>();
        }
Ejemplo n.º 11
0
        public void Less_bins_than_config()
        {
            var ctx = new SelectDueCardContextModel
            {
                Bins = new [] {
                    new[] { "01", "02" },
                    new[] { "11", "12", "13" },
                },
                DueBinIndex = 2,
                Config      = __CONFIG
            };
            var sut = new ProgressProcessor();

            var result = sut.Process(new ProgressQuery(), ctx) as ProgressQueryResult;

            result.Should().BeEquivalentTo(new ProgressQueryResult {
                Bins = new [] {
                    new ProgressQueryResult.Bin {
                        Count = 2
                    },
                    new ProgressQueryResult.Bin {
                        Count             = 3,
                        LowerDueThreshold = 2,
                        UpperDueThreshold = 4
                    },
                    new ProgressQueryResult.Bin {
                        Count             = 0,
                        LowerDueThreshold = 3,
                        UpperDueThreshold = 5,
                        IsDue             = true
                    },
                    new ProgressQueryResult.Bin()
                }
            });
            result.TotalCount.Should().Be(5);
        }