예제 #1
0
        public void MakeShotTest()
        {
            var    console            = new StubConsole("A1");
            Player user               = new User(new List <Ship>(), 2, console);
            var    expectedShotCoords = new Coordinates(0, 0);

            var opponentShip = new Ship();

            opponentShip.AddDeck(new Coordinates(0, 1));
            var opponentShips = new List <Ship> {
                opponentShip
            };

            var actualShotCoords = user.MakeAShot();

            Assert.True(actualShotCoords.Equals(expectedShotCoords));
        }
예제 #2
0
        public void TurnWhenShotSunk()
        {
            var console    = new StubConsole();
            var shotCoords = new Coordinates(0, 1);
            var player     = new TestPlayer(shotCoords, new List <Ship>(), 2, console);

            var opponentShip = new Ship();

            opponentShip.AddDeck(new Coordinates(0, 1));
            var opponentShips = new List <Ship> {
                opponentShip
            };

            player.Turn(opponentShips);
            List <Shot> shots = player.GetShots();

            Assert.True(shots.Find(s => s.GetCoords().Equals(shotCoords)).GetResult() == Result.sunk);
        }