static void Main(string[] args) { LotteryNumberSet set; PrintHeader(); // Some TUI spam for (;;) { switch (Console.ReadKey().KeyChar) // Wait for command { case 'g': // Something along the lines of "(g) generate" set = LotteryNumberSet.Create(); IEnumerable <LotteryNumberSetPrinter.PrintInstruction> sheet; sheet = new LotteryNumberSetPrinter().Format(set); foreach (var instruction in sheet) { instruction.Execute(); } break; case 'q': // Something along the lines of "(q) quit" Environment.Exit(0); break; default: break; } } ; }
public void SetPrinter_Prints_OnesSet() { // Setup LotteryNumberSetPrinter printer = new LotteryNumberSetPrinter(); LotteryNumberSet set = new LotteryNumberSet { Balls = Enumerable.Range(0, LotteryNumberSet.BallCount) .Select(_ => 1u) .ToArray() }; // Act var formatted = printer.Format(set); // Assert Assert.True( // Try to read each number from the corresponding print instruction, // then check the values correspond, and the count is correct (from instruction in formatted where instruction is LotteryNumberSetPrinter.WriteTextPrintInstruction writeText && Int32.TryParse($"{writeText.Text[writeText.Text.Count() - 1]}", out var ballNumber) && ballNumber == 1 select(bool?) null).Count() == set.Balls.Count() ); }