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 LotteryNumberSet_Generates_SixValidNumbers() { // Setup LotteryNumberSet set; // Act set = LotteryNumberSet.Create(); // Assert Assert.True(set.Balls.All(num => num >= 0), "NonZero numbers should be generated"); // See also: unsigned Assert.True(set.Balls.All(num => num <= LotteryNumberSet.MaxNumber), "All numbers should be less than MaxNumber"); Assert.Equal(set.Balls.Count(), LotteryNumberSet.BallCount); }
public void LotteryNumberSet_Generates_OrderedNumbers() { // Setup LotteryNumberSet set; // Act set = LotteryNumberSet.Create(); // Assert foreach (var index in Enumerable.Range(1, set.Balls.Count())) { Assert.True(set.Balls[index - 1] < set.Balls[index], "Balls should be ordered"); } }
public void LotteryNumberSet_Generates_UniqueNumbers() { // Setup LotteryNumberSet set; // Act set = LotteryNumberSet.Create(); // Assert foreach (var index in Enumerable.Range(1, LotteryNumberSet.BallCount)) { // Balls are a monotonically increasing set // That means pairwise uniqueness inductively guarantees total uniqueness Assert.True(set.Balls[index - 1] != set.Balls[index], "Balls should be unique"); } }