public void MoveNextWhenHaveInstructionAddedTest()
        {
            InstructionSet instructionSet = new InstructionSet();
            instructionSet.Add("5 5");
            instructionSet.Add("1 2 N");
            instructionSet.Add("L");

            Assert.AreEqual(true, instructionSet.MoveNext());
        }
예제 #2
0
        public void PlateauSizeMissWidthOrLengthShouldThrowException()
        {
            var instructionSet = new InstructionSet();
            instructionSet.Add("55");

            instructionSet.GetPlateau();
        }
예제 #3
0
        public void PlateauWidthOrLengthIsNegativeShouldThrowException()
        {
            var instructionSet = new InstructionSet();
            instructionSet.Add("5 -1");

            instructionSet.GetPlateau();
        }
예제 #4
0
        public void InvalidPlateauWestToEastLengthShouldThrowException()
        {
            var instructionSet = new InstructionSet();
            instructionSet.Add("A 55");

            instructionSet.GetPlateau();
        }
예제 #5
0
        public void InvalidPlateauSouthToNorthLengthShouldThrowException()
        {
            var instructionSet = new InstructionSet();
            instructionSet.Add("55 A");

            instructionSet.GetPlateau();
        }
예제 #6
0
        public InstructionSet ToInstructionSet(IInstructable instructable)
        {
            InstructionSet instructionSet = new InstructionSet();

            instructionSet.Name = this.Target;

            //INameable nameable = null;


            foreach (KeyframeListSave keyframeList in Instructions)
            {
                KeyframeList keyframes = new KeyframeList();
                keyframes.Name = keyframeList.Name;

                instructionSet.Add(keyframes);
                foreach (KeyframeSave keyframe in keyframeList.SceneKeyframes)
                {
                    InstructionList list = new InstructionList();
                    list.Name = keyframe.Name;
                    keyframes.Add(list);

                    foreach (InstructionSave instructionSave in keyframe.InstructionSaves)
                    {
                        list.Add(instructionSave.ToInstruction(instructable));
                    }
                }
            }

            return(instructionSet);
        }
        public void ResetTest()
        {
            InstructionSet instructionSet = new InstructionSet();
            instructionSet.Add("5 5");
            instructionSet.Add("1 2 N");
            instructionSet.Add("L");
            instructionSet.Add("2 3 W");
            instructionSet.Add("R");

            instructionSet.MoveNext();
            Assert.AreEqual(typeof(HeadingNorth), instructionSet.Current.GetLandingHeading().GetType());

            instructionSet.MoveNext();
            Assert.AreEqual(typeof(HeadingWest), instructionSet.Current.GetLandingHeading().GetType());

            instructionSet.Reset();
            instructionSet.MoveNext();
            Assert.AreEqual(typeof(HeadingNorth), instructionSet.Current.GetLandingHeading().GetType());
        }
예제 #8
0
        public void CorrectPlateauSizeTest()
        {
            var instructionSet = new InstructionSet();
            instructionSet.Add("5 3");

            Plateau plateau = instructionSet.GetPlateau();

            Assert.AreEqual(5, plateau.WestToEastLength);
            Assert.AreEqual(3, plateau.SouthToNorthLength);
        }
예제 #9
0
        public InstructionSet ToInstructionSet(FlatRedBall.Scene scene)
        {
            InstructionSet instructionSet = new InstructionSet();

            instructionSet.Name = this.Target;

            INameable nameable = null;


            foreach (KeyframeListSave keyframeList in Instructions)
            {
                KeyframeList keyframes = new KeyframeList();
                keyframes.Name = keyframeList.Name;

                instructionSet.Add(keyframes);
                foreach (KeyframeSave keyframe in keyframeList.SceneKeyframes)
                {
                    InstructionList list = new InstructionList();
                    list.Name = keyframe.Name;
                    keyframes.Add(list);

                    foreach (InstructionSave instructionSave in keyframe.InstructionSaves)
                    {
                        if (nameable == null || nameable.Name != instructionSave.TargetName)
                        {
                            // We don't have a nameable yet, or the current instruction is
                            // not modifying the one referenced by nameable.
                            nameable = scene.Sprites.FindByName(instructionSave.TargetName);

                            if (nameable == null)
                            {
                                nameable = scene.SpriteFrames.FindByName(instructionSave.TargetName);
                            }
                        }

                        if (nameable == null)
                        {
                            throw new NullReferenceException("Could not find an object of instance " + instructionSave.Type + " with the name " + instructionSave.TargetName);
                        }

                        list.Add(instructionSave.ToInstruction(nameable));
                    }
                }
            }

            return(instructionSet);
        }
예제 #10
0
        private static InstructionSet ReceiveInstructions()
        {
            var instructionSet = new InstructionSet();

            string instruction;

            while ((instruction = Console.ReadLine()) != string.Empty)
            {
                instructionSet.Add(instruction);
            }

            //instructionSet.Add("5 5");
            //instructionSet.Add("1 2 N");
            //instructionSet.Add("LMLMLMLMM");
            //instructionSet.Add("3 3 E");
            //instructionSet.Add("MMRMMRMRRM");
            //instructionSet.Add("3 3 E");
            //instructionSet.Add("MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM");

            return instructionSet;
        }
예제 #11
0
 public void Setup()
 {
     _instructionSet = new InstructionSet();
     _instructionSet.Add("5 5");
     _instructionSet.Add("1 2 N");
 }
예제 #12
0
 public void RegisterCommand(char symbol, Action <IVirtualMachine> execute)
 {
     InstructionSet.Add(symbol, execute);
 }
예제 #13
0
        public InstructionSet ToInstructionSet(FlatRedBall.Scene scene)
        {
            InstructionSet instructionSet = new InstructionSet();
            instructionSet.Name = this.Target;

            INameable nameable = null;
            

            foreach (KeyframeListSave keyframeList in Instructions)
            {
                KeyframeList keyframes = new KeyframeList();
                keyframes.Name = keyframeList.Name;

                instructionSet.Add(keyframes);
                foreach (KeyframeSave keyframe in keyframeList.SceneKeyframes)
                {
                    InstructionList list = new InstructionList();
                    list.Name = keyframe.Name;
                    keyframes.Add(list);

                    foreach (InstructionSave instructionSave in keyframe.InstructionSaves)
                    {
                        if (nameable == null || nameable.Name != instructionSave.TargetName)
                        {
                            // We don't have a nameable yet, or the current instruction is 
                            // not modifying the one referenced by nameable.
                            nameable = scene.Sprites.FindByName(instructionSave.TargetName);

                            if (nameable == null)
                            {
                                nameable = scene.SpriteFrames.FindByName(instructionSave.TargetName);
                            }

                        }

                        if (nameable == null)
                        {
                            throw new NullReferenceException("Could not find an object of instance " + instructionSave.Type + " with the name " + instructionSave.TargetName);
                        }

                        list.Add(instructionSave.ToInstruction(nameable));
                    }
                }

            }

            return instructionSet;
        }
예제 #14
0
        public InstructionSet ToInstructionSet(IInstructable instructable)
        {
            InstructionSet instructionSet = new InstructionSet();
            instructionSet.Name = this.Target;

            //INameable nameable = null;


            foreach (KeyframeListSave keyframeList in Instructions)
            {
                KeyframeList keyframes = new KeyframeList();
                keyframes.Name = keyframeList.Name;

                instructionSet.Add(keyframes);
                foreach (KeyframeSave keyframe in keyframeList.SceneKeyframes)
                {
                    InstructionList list = new InstructionList();
                    list.Name = keyframe.Name;
                    keyframes.Add(list);

                    foreach (InstructionSave instructionSave in keyframe.InstructionSaves)
                    {
                        list.Add(instructionSave.ToInstruction(instructable));
                    }
                }

            }

            return instructionSet;
        }