public void NumbersAreOrderedByColumn() { var columns = string.Join("", BingoCard.GetCard().ToList() .Select(x => x.Substring(0, 1)).ToArray()); Assert.IsTrue(Regex.IsMatch(columns, "^[B]*[I]*[N]*[G]*[O]*$")); }
public void NumbersWithinColumnAreAllInTheCorrectRange(string column, int start, int end) { var numbers = BingoCard.GetCard().Where(x => x.StartsWith(column)).ToList(); foreach (var number in numbers) { var n = Convert.ToInt32(number.Substring(1)); Assert.GreaterOrEqual(n, start, "Column {0} should be in the range between {1} and {2}, found: {3}", column, start, end, number); Assert.LessOrEqual(n, end, "Column {0} should be in the range between {1} and {2}, found: {3}", column, start, end, number); } }
public void NumbersWithinColumnAreInRandomOrder() { var card = BingoCard.GetCard().Select(x => Convert.ToInt32(x.Substring(1))).ToArray(); var isRandom = false; for (var i = 1; i < card.Length; i++) { if (card[i - 1] > card[i]) { isRandom = true; break; } } Assert.IsTrue(isRandom, "Unlikely result, is the list ordered?"); }
public void ColumnContainsCorrectNumberOfItems(string column, int count) { var numbers = BingoCard.GetCard().Where(x => x.StartsWith(column)).ToList(); Assert.AreEqual(count, numbers.Count); }
public void EachNumberOnCardIsUnique() { var card = BingoCard.GetCard(); Assert.AreEqual(card.Length, card.ToList().Distinct().Count()); }
public void CardHas24Numbers() { Assert.AreEqual(24, BingoCard.GetCard().Length); }