public void MoveNextWhenHaveInstructionAddedTest() { InstructionSet instructionSet = new InstructionSet(); instructionSet.Add("5 5"); instructionSet.Add("1 2 N"); instructionSet.Add("L"); Assert.AreEqual(true, instructionSet.MoveNext()); }
public void PlateauSizeMissWidthOrLengthShouldThrowException() { var instructionSet = new InstructionSet(); instructionSet.Add("55"); instructionSet.GetPlateau(); }
public void PlateauWidthOrLengthIsNegativeShouldThrowException() { var instructionSet = new InstructionSet(); instructionSet.Add("5 -1"); instructionSet.GetPlateau(); }
public void InvalidPlateauWestToEastLengthShouldThrowException() { var instructionSet = new InstructionSet(); instructionSet.Add("A 55"); instructionSet.GetPlateau(); }
public void InvalidPlateauSouthToNorthLengthShouldThrowException() { var instructionSet = new InstructionSet(); instructionSet.Add("55 A"); instructionSet.GetPlateau(); }
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()); }
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); }
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); }
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; }
public void Setup() { _instructionSet = new InstructionSet(); _instructionSet.Add("5 5"); _instructionSet.Add("1 2 N"); }
public void RegisterCommand(char symbol, Action <IVirtualMachine> execute) { InstructionSet.Add(symbol, execute); }
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; }
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; }