Exemplo n.º 1
0
        public void GivenNullShip_DoesNotAddPointToPlayerScore()
        {
            var   playerScore = new Mock <IPlayerScore>();
            IShip ship        = null;

            var hitHandler = new HitHandler(playerScore.Object, ship);

            hitHandler.Execute();

            playerScore.Verify(x => x.AddPoint(), Times.Never());
        }
Exemplo n.º 2
0
        public void GivenNotNullShip_AddsPointsToPlayerScore()
        {
            var       playerScore = new Mock <IPlayerScore>();
            var       ship        = new Mock <IShip>();
            const int nrOfRepeats = 5;

            for (int i = 0; i < nrOfRepeats; i++)
            {
                var hitHandler = new HitHandler(playerScore.Object, ship.Object);
                hitHandler.Execute();
            }

            playerScore.Verify(x => x.AddPoint(), Times.Exactly(nrOfRepeats));
        }
Exemplo n.º 3
0
        public IShot Shoot(string coordinates)
        {
            int[] coordsInt = Helpers.TranslateCoordinates(coordinates);
            var   shot      = new Shot(Battlefield, coordsInt);

            if (!shot.IsShotValid())
            {
                return(null);
            }

            shot.Fire();
            var hitHandler = new HitHandler(playerScore, shot.HitShip);

            hitHandler.Execute();
            return(shot);
        }