Exemplo n.º 1
0
        public void IsShipValid_WithOveralppingVerticalShips_ReturnsFalse()
        {
            ShipValidator target               = new ShipValidator();
            var           shipType             = new ShipType("Destroyer", "D", 4);
            var           ship                 = new Ship(new Point(2, 3), new Point(5, 3), shipType);
            var           shipToBeComparedWith = new Ship(new Point(2, 3), new Point(5, 3), shipType);
            var           ships                = new List <Ship> {
                shipToBeComparedWith
            };

            target.IsShipValidForList(ship, ships).Should().BeFalse();
        }
Exemplo n.º 2
0
        public void IsShipValid_WithHorizontalParallelShips_ReturnsTrue()
        {
            ShipValidator target               = new ShipValidator();
            var           shipType             = new ShipType("Destroyer", "D", 4);
            var           ship                 = new Ship(new Point(3, 2), new Point(3, 5), shipType);
            var           shipToBeComparedWith = new Ship(new Point(5, 1), new Point(5, 4), shipType);
            var           ships                = new List <Ship> {
                shipToBeComparedWith
            };

            target.IsShipValidForList(ship, ships).Should().BeTrue();
        }
Exemplo n.º 3
0
        public void IsShipValid_WithIntersectedShipsInTheMiddle_ReturnsFalse()
        {
            ShipValidator target               = new ShipValidator();
            var           shipType             = new ShipType("Destroyer", "D", 4);
            var           ship                 = new Ship(new Point(3, 2), new Point(3, 5), shipType);
            var           shipToBeComparedWith = new Ship(new Point(0, 4), new Point(3, 4), shipType);
            var           ships                = new List <Ship> {
                shipToBeComparedWith
            };

            target.IsShipValidForList(ship, ships).Should().BeFalse();
        }
Exemplo n.º 4
0
        public void IsShipValid_WithOveralppingHorizontaHavingDifferentSizeShips_ReturnsFalse()
        {
            ShipValidator target               = new ShipValidator();
            var           shipType             = new ShipType("Destroyer", "D", 4);
            var           shipType2            = new ShipType("Battleship", "B", 5);
            var           ship                 = new Ship(new Point(3, 2), new Point(3, 5), shipType);
            var           shipToBeComparedWith = new Ship(new Point(3, 1), new Point(3, 5), shipType2);
            var           ships                = new List <Ship> {
                shipToBeComparedWith
            };

            target.IsShipValidForList(ship, ships).Should().BeFalse();
        }