Пример #1
0
        public void Attack_IsHitReturnsTrue_ResultHit()
        {
            _fleetMock.Setup(x => x.IsHit(_pointOfAttack)).Returns(true);

            ResultOfAttack result = _subjectUnderTest.Attack(_pointOfAttack);

            Assert.AreEqual(ResultOfAttack.Hit, result);
        }
Пример #2
0
        static void Main(string[] args)
        {
            Program p = new Program();

            p.InitializeTheFleet();
            BattleshipGrid.BattleshipGrid battleshipGrid = new BattleshipGrid.BattleshipGrid(p._fleet);

            Coordinate hitPoint = new Coordinate(7, 5);

            Console.WriteLine("Attack(7,5) " + battleshipGrid.Attack(hitPoint));
            hitPoint = new Coordinate(8, 9);
            Console.WriteLine("Attack(8,9) " + battleshipGrid.Attack(hitPoint));
        }
        public ResultOfAttack AttackAtCoordinate(int row, int column)
        {
            ResultOfAttack result = _battleshipGrid.Attack(new Coordinate(row, column));

            IsNotGameOver = result == ResultOfAttack.GameOver ? false : true;
            return(result);
        }
Пример #4
0
        public void TestAttack_IsHit()
        {
            InitializeTheBattleshipGrid();
            Coordinate     pointOfAttack = new Coordinate(5, 4);
            ResultOfAttack result        = _battleshipGrid.Attack(pointOfAttack);

            Assert.IsTrue(result == ResultOfAttack.Hit);
        }