コード例 #1
0
        public void TakeShootTest_AleadyShooted()
        {
            Field field = new Field_Valid_OneShip();

            field.SetRandomShips();
            field.TakeShoot(new Point(0));
            field.TakeShoot(new Point(0));
        }
コード例 #2
0
        public void TakeShootTest_CornerAutoMiss()
        {
            Field field = new Field_Valid_OneShip();
            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.Miss, field.TakeShoot(new Point(point.X - 1, point.Y - 1)));
            Assert.AreEqual(CellStatus.Missed, field.Cells[point.Y - 1, point.X - 1]);
            Assert.AreEqual(ShotResult.Hit, field.TakeShoot(point));
            Assert.AreEqual(CellStatus.Hit, field.Cells[point.Y, point.X]);
            Assert.AreEqual(CellStatus.Missed, field.Cells[point.Y - 1, point.X - 1]);
            Assert.AreEqual(CellStatus.AutoMissed, field.Cells[point.Y + 1, point.X - 1]);
            Assert.AreEqual(CellStatus.AutoMissed, field.Cells[point.Y - 1, point.X + 1]);
            Assert.AreEqual(CellStatus.AutoMissed, field.Cells[point.Y + 1, point.X + 1]);
        }
コード例 #3
0
        public void TakeShootTest_PointOutOfField()
        {
            Field field = new Field_Valid_OneShip();

            field.SetRandomShips();
            field.TakeShoot(new Point(-1));
        }
コード例 #4
0
        public void TakeShootTest_NotSetShip()
        {
            Field field = new Field_Valid_OneShip();

            field.TakeShoot(new Point(0));
        }