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()); }
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)); }
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); }