Beispiel #1
0
        public void ShouldIncreaseSpeed(
            int initialSpeed,
            int expectedValue,
            string expectedAction)
        {
            // Setup
            var sut = new AeroMachine(0, 0, initialSpeed, _sinkMock.Object);

            // Act
            sut.SpeedUp();

            // Assert
            Assert.Equal(2, _sinkActions.Count);
            Assert.Equal(expectedValue, sut.Speed);
            Assert.Equal(expectedAction, _sinkActions[1]);
        }
Beispiel #2
0
        private static void KeyboardController(AeroMachine flyer)
        {
            Console.WriteLine("\nPlease press direction key, +/- to change speed (q for exit).");
            while (true)
            {
                var keyInfo = Console.ReadKey(true);
                if (keyInfo.KeyChar == 'q' || keyInfo.KeyChar == 'Q')
                {
                    Console.WriteLine("\nEject...");
                    return;
                }

                switch (keyInfo.Key)
                {
                case ConsoleKey.LeftArrow:
                    flyer.TurnLeft();
                    break;

                case ConsoleKey.RightArrow:
                    flyer.TurnRight();
                    break;

                case ConsoleKey.UpArrow:
                    flyer.GoUp();
                    break;

                case ConsoleKey.DownArrow:
                    flyer.GoDown();
                    break;

                case ConsoleKey.Oem4:
                    flyer.SpeedUp();
                    break;

                case ConsoleKey.OemPlus:
                    flyer.SloDown();
                    break;
                }
            }
        }