Beispiel #1
0
        public void ChangeDirectionThrowsArgumentOutOfRangeExceptionWhenInvalidEnumValueTest()
        {
            // arrange
            var snakeElement = new SnakeElement(1, 1, DirectionOfMove.Up);

            // act
            // assert
            Assert.Throws <ArgumentOutOfRangeException>(() => snakeElement.ChangeDirection((DirectionOfMove)100));
        }
Beispiel #2
0
        public void ChangeDirectionToUpValidConditionsTest()
        {
            // arrange
            const DirectionOfMove expected = DirectionOfMove.Up;
            var snakeElement = new SnakeElement(1, 1, DirectionOfMove.Right);

            // act
            snakeElement.ChangeDirection(expected);
            snakeElement.Move();

            // assert
            Assert.AreEqual(expected, snakeElement.DirectionOfMove);
        }
Beispiel #3
0
        public void ChangeDirectionToLeftWhenCurrentIsRightTest()
        {
            // arrange
            const DirectionOfMove expected = DirectionOfMove.Right;
            var snakeElement = new SnakeElement(1, 1, DirectionOfMove.Right);

            // act
            snakeElement.ChangeDirection(DirectionOfMove.Left);
            snakeElement.Move();

            // assert
            Assert.AreEqual(expected, snakeElement.DirectionOfMove);
        }
Beispiel #4
0
        public void ChangeDirectionToDownWhenCurrentIsUpTest()
        {
            // arrange
            const DirectionOfMove expected = DirectionOfMove.Up;
            var snakeElement = new SnakeElement(1, 1, DirectionOfMove.Up);

            // act
            snakeElement.ChangeDirection(DirectionOfMove.Down);
            snakeElement.Move();

            // assert
            Assert.AreEqual(expected, snakeElement.DirectionOfMove);
        }
Beispiel #5
0
        public void ChangeDirectionToDownValidConditionsTest()
        {
            // arrange
            const DirectionOfMove expected = DirectionOfMove.Down;
            var snakeElement = new SnakeElement(0, 0, DirectionOfMove.Left);

            // act
            snakeElement.ChangeDirection(expected);
            snakeElement.Move();

            // assert
            Assert.AreEqual(expected, snakeElement.DirectionOfMove);
        }