public void TopRightDiagonalBingo() { BingoCard card = new BingoCard(); for (int n = 0; n < BingoCard.MaxColumns - 1; n++) { Assert.IsFalse(card.Mark(card.GetCard()[n, BingoCard.MaxColumns - n - 1].Number)); } Assert.IsTrue(card.Mark(card.GetCard()[BingoCard.MaxRows - 1, 0].Number)); }
public void HorizontalBingo() { BingoCard card = new BingoCard(); for (int row = 0; row < BingoCard.MaxColumns - 1; row++) { Assert.IsFalse(card.Mark(card.GetCard()[row, 0].Number)); } Assert.IsTrue(card.Mark(card.GetCard()[BingoCard.MaxRows - 1, 0].Number)); }
public void VerticalBingo() { BingoCard card = new BingoCard(); for (int column = 0; column < BingoCard.MaxColumns - 1; column++) { Assert.IsFalse(card.Mark(card.GetCard()[0, column].Number)); } Assert.IsTrue(card.Mark(card.GetCard()[0, BingoCard.MaxColumns - 1].Number)); }
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 GetCard_Twice_Should_Be_Different_Set() { var card1 = BingoCard.GetCard().ToExpectedObject(); var card2 = BingoCard.GetCard(); card1.ShouldNotEqual(card2); }
public void When_GetCard_Should_Return_Start_With_BINGO_And_Number() { var bingoCard = BingoCard.GetCard(); foreach (var number in bingoCard.ToList()) { Assert.IsTrue(Regex.IsMatch(number, "^[BINGO][0-9]*$")); } }
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 When_GetCard_Should_contain_Char_Below_B_I_N_G_O() { var expecteds = new List <string>() { "B", "I", "N", "G", "O" }; var bingoCard = BingoCard.GetCard(); foreach (var expected in expecteds) { Assert.IsTrue(new List <string>(bingoCard).Any(x => x.Contains(expected))); } }
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 RandomnessTest() { var card = BingoCard.GetCard(); var cardNumberCount = (new int[24]).ToList(); for (var i = 0; i < 100; i++) { var c = BingoCard.GetCard(); for (var j = 0; j < 24; j++) { if (card[j] == c[j]) { cardNumberCount[j]++; } } } Assert.IsFalse(cardNumberCount.Any(x => x > 30), "The same number appeared on more than 30 of the 100 cards on the same spot, are the cards random?"); }
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); }
public void GetCard_Check_Array_Count(string column, int expected) { Assert.AreEqual(expected, BingoCard.GetCard().Count(x => x.Contains(column))); }