Esempio n. 1
0
        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));
        }
Esempio n. 2
0
        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));
        }
Esempio n. 3
0
        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));
        }
Esempio n. 4
0
        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]*$"));
        }
Esempio n. 5
0
        public void GetCard_Twice_Should_Be_Different_Set()
        {
            var card1 = BingoCard.GetCard().ToExpectedObject();
            var card2 = BingoCard.GetCard();

            card1.ShouldNotEqual(card2);
        }
Esempio n. 6
0
        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]*$"));
            }
        }
Esempio n. 7
0
        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);
            }
        }
Esempio n. 8
0
        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)));
            }
        }
Esempio n. 9
0
        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?");
        }
Esempio n. 10
0
        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?");
        }
Esempio n. 11
0
        public void ColumnContainsCorrectNumberOfItems(string column, int count)
        {
            var numbers = BingoCard.GetCard().Where(x => x.StartsWith(column)).ToList();

            Assert.AreEqual(count, numbers.Count);
        }
Esempio n. 12
0
        public void EachNumberOnCardIsUnique()
        {
            var card = BingoCard.GetCard();

            Assert.AreEqual(card.Length, card.ToList().Distinct().Count());
        }
Esempio n. 13
0
 public void CardHas24Numbers()
 {
     Assert.AreEqual(24, BingoCard.GetCard().Length);
 }
Esempio n. 14
0
 public void GetCard_Check_Array_Count(string column, int expected)
 {
     Assert.AreEqual(expected, BingoCard.GetCard().Count(x => x.Contains(column)));
 }