Esempio n. 1
0
        public void Move_rover_on_Mars()
        {
            // arrange
            var mars    = new Mars(_plateau);
            var results = new List <Location>();

            // action
            var robotIds = mars.DeployRovers(_locations).ToList();

            robotIds.ForEach(x => results.Add(mars.MoveRobot(x, "M")));

            //assert
            Assert.NotNull(results);

            Assert.Equal(_locations.Count, robotIds.Count);

            Assert.Equal(_locations.Count, results.Count);

            for (var i = 0; i < _locations.Count; i++)
            {
                Assert.Equal(_locations[i].Orientation, results[i].Orientation);

                switch (_locations[i].Orientation)
                {
                case Orientation.N:
                {
                    Assert.Equal(_locations[i].X, results[i].X);

                    Assert.Equal(_locations[i].Y + 1, results[i].Y);
                }
                break;

                case Orientation.E:
                {
                    Assert.Equal(_locations[i].X + 1, results[i].X);

                    Assert.Equal(_locations[i].Y, results[i].Y);
                }
                break;

                case Orientation.S:
                {
                    Assert.Equal(_locations[i].X, results[i].X);

                    Assert.Equal(_locations[i].Y - 1, results[i].Y);
                }
                break;

                case Orientation.W:
                {
                    Assert.Equal(_locations[i].X - 1, results[i].X);

                    Assert.Equal(_locations[i].Y, results[i].Y);
                }
                break;
                }
                ;
            }
        }
Esempio n. 2
0
        public void Move_invalid_location_rover_on_Mars()
        {
            // arrange
            var mars = new Mars(_plateau);

            //assert
            Assert.Throws <InvalidOperationException>(() => mars.DeployRovers(new List <Location> {
                new Location(1, 1000, Orientation.N)
            }));
        }
Esempio n. 3
0
        public void Move_invalid_rover_on_Mars()
        {
            // arrange
            var mars = new Mars(_plateau);

            // action
            var robotIds = mars.DeployRovers(_locations).ToList();

            var result = mars.MoveRobot(Guid.NewGuid(), "LLMMMM");

            //assert
            Assert.Null(result);
        }
Esempio n. 4
0
        public void DeployRovers_on_Mars()
        {
            // arrange
            var mars = new Mars(_plateau);

            // action
            var result = mars.DeployRovers(_locations);

            //assert
            Assert.NotNull(result);

            var robots = result.ToList();

            Assert.Equal(_locations.Count, robots.Count);
        }
Esempio n. 5
0
        public void Move_rover_on_Mars_acceptance_tests(int maxX, int maxY, int x, int y, Orientation ori, string direction, string finalLocation)
        {
            // arrange
            var mars = new Mars(new Plateau(maxX, maxY));

            // action
            var robotIds = mars.DeployRovers(new List <Location> {
                new Location(x, y, ori)
            }).ToList();

            var result = mars.MoveRobot(robotIds.First(), direction);

            //assert
            Assert.Equal(finalLocation, result.ToString());
        }