Ejemplo n.º 1
0
        public void PlayingGame_AsTheFirstString_Returns1()
        {
            // Arrange
            var printerMock = new ResultPrinterMock();
            var game        = new FizzBuzzGame(printerMock);

            // Act
            game.PlayTheGame();

            // Assert
            var firstResult = printerMock.GetMessageWithIndex(1);

            Assert.AreEqual("1", firstResult);
        }
Ejemplo n.º 2
0
        public void PlayingGame_ForMultiplesOfBothThreeAndFive_ReturnsFizzBuzz(int index, string expected)
        {
            // Arrange
            var printerMock = new ResultPrinterMock();
            var game        = new FizzBuzzGame(printerMock);

            // Act
            game.PlayTheGame();

            // Assert
            var actual = printerMock.GetMessageWithIndex(index);

            Assert.AreEqual(expected, actual);
        }
Ejemplo n.º 3
0
        public void PlayingGame_AllNumbers_AreNotMultiplesOfThreeOrFive()
        {
            // Arrange
            var printerMock = new ResultPrinterMock();
            var game        = new FizzBuzzGame(printerMock);

            // Act
            game.PlayTheGame();

            Assert.True(printerMock.AllPrintedMessages().All(s =>
            {
                if (!AssertHelper.IsPositiveInteger(s))
                {
                    return(true);
                }

                var intVal = Int32.Parse(s);
                return(intVal % 3 != 0 && intVal % 5 != 0);
            }));
        }