Esempio n. 1
0
        public void RenderPlaygroundTestWithPlaygroundWithSize2()
        {
            var field          = GenerateTestField.GenerateFieldWithSizeTwo();
            var expectedString = "   0 1 \r\n   ----\r\n0 |1 X \r\n1 |- - \r\n";

            this.playgroundRender.RenderPlayground(field);
            this.iURender.Verify(w => w.WriteLine(It.Is <string>(fieldString => fieldString == expectedString)), Times.Once);
        }
Esempio n. 2
0
        public void GetNextPositionForPlayFromUserTestForCorrectPositionWithMine()
        {
            var field = GenerateTestField.GenerateFieldWithSizeTwo();

            this.inputReader.Setup(x => x.GetUserInput()).Returns("0 0");
            this.messenger.Setup(x => x.MessageForWrongCoordinates()).Throws(new ArgumentException("Invalid Coordinates"));
            this.messenger.Setup(x => x.MessageForInvalidMove()).Throws(new ArgumentException("Invalid Move"));
            Position returnedPosition = this.gameController.GetNextPositionForPlayFromUser(field);
            bool     isTheSameCell    = 0 == returnedPosition.X && 0 == returnedPosition.Y;

            Assert.IsTrue(isTheSameCell);
        }
Esempio n. 3
0
        public void GetNextPositionForPlayFromUserTestForAskUntilGetCorrectCoordinate()
        {
            var arrayWithCoordinates = new String[] { "111", String.Empty, "1 1", "-5 5", "0 0" };
            var currentIndex         = 0;
            var field = GenerateTestField.GenerateFieldWithSizeTwo();

            this.inputReader.Setup(x => x.GetUserInput())
            .Returns(() => arrayWithCoordinates[currentIndex])
            .Callback(() => currentIndex++);
            Position returnedPosition = this.gameController.GetNextPositionForPlayFromUser(field);
            bool     isTheSameCell    = 0 == returnedPosition.X && 0 == returnedPosition.Y;

            Assert.IsTrue(isTheSameCell);
        }
Esempio n. 4
0
 public void GetNextPositionForPlayFromUserTestForInvalidPosition()
 {
     try
     {
         var field = GenerateTestField.GenerateFieldWithSizeTwo();
         this.inputReader.Setup(x => x.GetUserInput()).Returns("111");
         this.messenger.Setup(x => x.MessageForWrongCoordinates()).Throws(new ArgumentException("Invalid Coordinates"));
         this.messenger.Setup(x => x.MessageForInvalidMove()).Throws(new ArgumentException("Invalid Move"));
         Position returnedPosition = this.gameController.GetNextPositionForPlayFromUser(field);
     }
     catch (ArgumentException ex)
     {
         Assert.AreEqual("Invalid Coordinates", ex.Message);
         throw;
     }
 }
Esempio n. 5
0
        public void RenderPlaygroundTestWithPlaygroundWithSize10AndEmptyCells()
        {
            var field          = GenerateTestField.GenerateFieldWithSizeTenWithEmptyCells();
            var expectedString = "   0 1 2 3 4 5 6 7 8 9 \r\n" +
                                 "   --------------------\r\n" +
                                 "0 |- - - - - - - - - - \r\n" +
                                 "1 |- - - - - - - - - - \r\n" +
                                 "2 |- - - - - - - - - - \r\n" +
                                 "3 |- - - - - - - - - - \r\n" +
                                 "4 |- - - - - - - - - - \r\n" +
                                 "5 |- - - - - - - - - - \r\n" +
                                 "6 |- - - - - - - - - - \r\n" +
                                 "7 |- - - - - - - - - - \r\n" +
                                 "8 |- - - - - - - - - - \r\n" +
                                 "9 |- - - - - - - - - - \r\n";

            this.playgroundRender.RenderPlayground(field);
            this.iURender.Verify(w => w.WriteLine(It.Is <string>(fieldString => fieldString == expectedString)), Times.Once);
        }