Beispiel #1
0
        public void When_spider_is_moved_as_per_instructions_with_valid_data_final_spider_information_is_returned(
            int wallTop,
            int wallRight,
            Position spiderPosition,
            Orientation spiderOrientation,
            string spiderInstructions,
            int finalSpiderXCoordinate,
            int finalSpiderYCoordinate,
            Orientation finalSpiderOrientation)
        {
            _spider = new Spider(wallTop, wallRight, spiderPosition, spiderOrientation);
            foreach (var key in spiderInstructions)
            {
                switch (key)
                {
                case 'L':
                    _spider.TurnLeft();
                    break;

                case 'R':
                    _spider.TurnRight();
                    break;

                case 'F':
                    _spider.MoveFront();
                    break;
                }
            }

            var finalPosition = _spider.GetPosition();

            Assert.That(finalPosition.X, Is.EqualTo(finalSpiderXCoordinate));
            Assert.That(finalPosition.Y, Is.EqualTo(finalSpiderYCoordinate));
            Assert.That(_spider.GetOrientation(), Is.EqualTo(finalSpiderOrientation));
        }
Beispiel #2
0
 private static void OnSpiderDeployed(ISpider spider)
 {
     Console.WriteLine("Spider position and orientation after deployment are");
     Console.WriteLine(spider.GetPosition().X);
     Console.WriteLine(spider.GetPosition().Y);
     Console.WriteLine(spider.GetOrientation().ToString());
 }