Пример #1
0
        public void ValidateShipPositions_Should_Throw_Exception_When_Ships_Position_Cross()
        {
            var tracker = new GameTrackerService();

            tracker.CreateBoard();


            tracker.Ships.Add(
                Ship.Create(new ShipViewModel
            {
                StartingPosition = new BoardPosition {
                    X = 3, Y = 3
                },
                Alignment = Alignment.Horizontal,
                Length    = 3
            }));

            var newShip = Ship.Create(new ShipViewModel
            {
                StartingPosition = new BoardPosition {
                    X = 4, Y = 1
                },
                Alignment = Alignment.Vertical,
                Length    = 4
            });
            Action act = () => tracker.ValidateIfShipNotCrossingOtherShips(newShip);

            Assert.Throws <HttpStatusCodeException>(act);
        }
Пример #2
0
        public void Cannot_Setup_Board_When_Its_in_Playing_Status()
        {
            var gameTracker = new GameTrackerService();

            gameTracker.Status = GameStatus.Playing;
            Action act = () => gameTracker.CreateBoard();

            Assert.Throws <HttpStatusCodeException>(act);
        }