示例#1
0
        public void TakeShootTest_Automiss()
        {
            Field field   = new Field_Valid_OneShip_Size1();
            Point shipPos = new Point(1);
            Point miss    = new Point(0);
            Ship  ship    = Ship.CreateNewShip(shipPos, Orientation.Vertical, field.Ships[0].Id, field.Ships[0].Size);

            field.SetShip(ship);
            Assert.AreEqual(ShotResult.Miss, field.TakeShoot(miss));
            Assert.AreEqual(CellStatus.Missed, field.Cells[miss.Y, miss.X]);
            Assert.AreEqual(ShotResult.Hit, field.TakeShoot(shipPos));
            Assert.AreEqual(CellStatus.Dead, field.Cells[shipPos.Y, shipPos.X]);
            Point start = new Point(0);
            Point end   = new Point(2);

            for (int i = start.Y; i <= end.Y; i++)
            {
                for (int j = start.X; j <= end.X; j++)
                {
                    if (j == miss.X && i == miss.Y)
                    {
                        Assert.AreEqual(CellStatus.Missed, field.Cells[i, j]);
                    }
                    else if (!(j == shipPos.X && i == shipPos.Y))
                    {
                        Assert.AreEqual(CellStatus.AutoMissed, field.Cells[i, j]);
                    }
                }
            }
        }
示例#2
0
        public void TakeShootTest_KillHit()
        {
            Field field = new Field_Valid_OneShip_Size1();
            Point point = new Point(1);
            Ship  ship  = Ship.CreateNewShip(point, Orientation.Vertical, field.Ships[0].Id, field.Ships[0].Size);

            field.SetShip(ship);
            Assert.AreEqual(ShotResult.Hit, field.TakeShoot(point));
            Assert.AreEqual(CellStatus.Dead, field.Cells[point.Y, point.X]);
        }