コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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;
     }
 }