Ejemplo n.º 1
0
        public void deploysBot()
        {
            Mission testMission = new Mission();
            testMission.processInstructionSet("../../TestInputs/goodBasic.txt");
            testMission.execute();

            Assert.IsTrue(testMission.bots[0].Deployed);
        }
Ejemplo n.º 2
0
        public void inputProcessorAcceptsGoodInputWithNoDirections1()
        {
            Mission testMission = new Mission();
            testMission.processInstructionSet("../../TestInputs/goodNoDirections1.txt");

            Assert.AreEqual(2, testMission.botQty);
            Assert.AreEqual(2, testMission.bots.Length);
            Assert.IsTrue(testMission.DataIsValid);
        }
Ejemplo n.º 3
0
        public void handlesBotCollision()
        {
            Mission testMission = new Mission();
            testMission.processInstructionSet("../../TestInputs/movementCollisions.txt");
            testMission.execute();

            Assert.AreEqual(1, testMission.bots[0].X);
            Assert.AreEqual(2, testMission.bots[1].X);
            Assert.AreEqual(-2, testMission.bots[2].X);
        }
Ejemplo n.º 4
0
        public void detectsOutOfBoundsDeployment()
        {
            Mission testMission = new Mission();
            testMission.processInstructionSet("../../TestInputs/outOfBoundsDeployment.txt");
            testMission.execute();

            Assert.IsFalse(testMission.bots[1].Deployed);
            Assert.IsFalse(testMission.bots[2].Deployed);
            Assert.IsFalse(testMission.bots[3].Deployed);
        }
Ejemplo n.º 5
0
        public void canInitialize()
        {
            Mission testMission = new Mission();

            Assert.AreEqual(0, testMission.grid.Right);
            Assert.AreEqual(0, testMission.grid.Top);
            Assert.AreEqual(0, testMission.grid.Left);
            Assert.AreEqual(0, testMission.grid.Bottom);
            Assert.AreEqual(0, testMission.botQty);
            Assert.IsNull(testMission.bots);
            Assert.IsFalse(testMission.DataIsValid);
        }
Ejemplo n.º 6
0
        public void inputProcessorAcceptsGoodInput()
        {
            Mission testMission = new Mission();
            testMission.processInstructionSet("../../TestInputs/goodBasic.txt");

            Assert.AreEqual(2, testMission.grid.Right);
            Assert.AreEqual(2, testMission.grid.Top);
            Assert.AreEqual(-2, testMission.grid.Left);
            Assert.AreEqual(-2, testMission.grid.Bottom);
            Assert.AreEqual(4, testMission.botQty);
            Assert.AreEqual(4, testMission.bots.Length);
            Assert.AreEqual(3, testMission.bots[0].directions.Length);
            Assert.IsTrue(testMission.DataIsValid);
        }
Ejemplo n.º 7
0
        static void Main(string[] args)
        {
            try {
                if (args.Any()) {
                    if (File.Exists(args[0])) {
                        Mission mission = new Mission();

                        mission.processInstructionSet(args[0]);
                        mission.execute();
                        mission.reportPositions();
                    }
                    else {
                        throw new Exception("Input Error: File path not found.\n");
                    }
                }
                else {
                    throw new Exception("Input Error: You must provide the path of your instructions file.\n Usage: UnderWaterBots.exe <file>\n");
                }
            }
            catch (Exception e) {
                Console.WriteLine("{0}", e);
            }
        }
Ejemplo n.º 8
0
        public void performsBasicMovement()
        {
            Mission testMission = new Mission();
            testMission.processInstructionSet("../../TestInputs/goodBasic.txt");
            testMission.execute();

            Assert.AreEqual(0, testMission.bots[0].X);
            Assert.AreEqual(2, testMission.bots[0].Y);
            Assert.AreEqual('N', testMission.bots[0].Heading);
            Assert.AreEqual(2, testMission.bots[1].X);
            Assert.AreEqual(0, testMission.bots[1].Y);
            Assert.AreEqual('N', testMission.bots[1].Heading);
            Assert.AreEqual(0, testMission.bots[2].X);
            Assert.AreEqual(-2, testMission.bots[2].Y);
            Assert.AreEqual('W', testMission.bots[2].Heading);
            Assert.AreEqual(-2, testMission.bots[3].X);
            Assert.AreEqual(0, testMission.bots[3].Y);
            Assert.AreEqual('W', testMission.bots[3].Heading);
        }
Ejemplo n.º 9
0
 public void inputProcessorRejectsBadNoBotQuantity()
 {
     Mission testMission = new Mission();
     testMission.processInstructionSet("../../TestInputs/badNoBotQuantity.txt");
     Assert.IsFalse(testMission.DataIsValid);
 }
Ejemplo n.º 10
0
 public void inputProcessorRejectsBadBotStartPositionInput()
 {
     Mission testMission = new Mission();
     testMission.processInstructionSet("../../TestInputs/badBotStartPosition.txt");
     Assert.IsFalse(testMission.DataIsValid);
 }