public TurtleGraphicsReflectionMatcher(ITurtleGraphicsCommands turtleGraphicsSystem, ITurtleGraphicsControlStructures turtleGraphicsControlStructures) { _turtleGraphicsSystem = turtleGraphicsSystem; _turtleGraphicsControlStructures = turtleGraphicsControlStructures; _turtleGraphicsCommandAttributes = new List<TurtleGraphicsAttribute>(); }
public void MyTestInitialize() { _turtleGraphicsSystemStub = MockRepository.GenerateStub<ITurtleGraphicsCommands>(); _turtleGraphicsControlStructuresSystemStub = MockRepository.GenerateStub<ITurtleGraphicsControlStructures>(); var turtleGraphicsCommand = typeof(TurtleGraphicsCommand); _commands = new List<Tuple<string, string, Type>> { new Tuple<string, string, Type>(GlobalConstants.SelectPenCommandText, "SelectPen", turtleGraphicsCommand), new Tuple<string, string, Type>(GlobalConstants.PenDownCommandText, "PenDown", turtleGraphicsCommand), new Tuple<string, string, Type>(GlobalConstants.PenUpCommandText, "PenUp", turtleGraphicsCommand), new Tuple<string, string, Type>(GlobalConstants.BackColCommandText, "SelectBackGround", turtleGraphicsCommand), new Tuple<string, string, Type>(GlobalConstants.BackwardCommandText, "Backward", turtleGraphicsCommand), new Tuple<string, string, Type>(GlobalConstants.CenterTurtleCommandText, "CenterTurtle", turtleGraphicsCommand), new Tuple<string, string, Type>(GlobalConstants.ClearScreenCommandText, "ClearScreen", turtleGraphicsCommand), new Tuple<string, string, Type>(GlobalConstants.DrawCircleCommandText, "DrawCircle", turtleGraphicsCommand), new Tuple<string, string, Type>(GlobalConstants.DrawTriangleCommandText, "DrawTriangle", turtleGraphicsCommand), new Tuple<string, string, Type>(GlobalConstants.DrawSquareCommandText, "DrawSquare", turtleGraphicsCommand), new Tuple<string, string, Type>(GlobalConstants.ForwardCommandText, "Forward", turtleGraphicsCommand), new Tuple<string, string, Type>(GlobalConstants.MoveCommandText, "Move", turtleGraphicsCommand), new Tuple<string, string, Type>(GlobalConstants.LeftCommandText, "Left", turtleGraphicsCommand), new Tuple<string, string, Type>(GlobalConstants.RightCommandText, "Right", turtleGraphicsCommand), new Tuple<string, string, Type>(GlobalConstants.RotateCommandText, "Rotate", turtleGraphicsCommand), new Tuple<string, string, Type>(GlobalConstants.LabelCommandText, "Label", turtleGraphicsCommand), new Tuple<string, string, Type>(GlobalConstants.PenWidthCommandText, "PenWidth", turtleGraphicsCommand), new Tuple<string, string, Type>(GlobalConstants.PrintCommandText, "Print", turtleGraphicsCommand), new Tuple<string, string, Type>(GlobalConstants.PrintLineCommandText, "PrintLine", turtleGraphicsCommand), new Tuple<string, string, Type>(GlobalConstants.SetPosCommandText, "SetPos", turtleGraphicsCommand), new Tuple<string, string, Type>(GlobalConstants.SetXCommandText, "SetX", turtleGraphicsCommand), new Tuple<string, string, Type>(GlobalConstants.SetYCommandText, "SetY", turtleGraphicsCommand), new Tuple<string, string, Type>(GlobalConstants.WaitCommandText, "Wait", turtleGraphicsCommand), new Tuple<string, string, Type>(GlobalConstants.HideTurtleCommandText, "HideTurtle", turtleGraphicsCommand), new Tuple<string, string, Type>(GlobalConstants.ShowTurtleCommandText, "ShowTurtle", turtleGraphicsCommand), new Tuple<string, string, Type>(GlobalConstants.HideAllTurtlesCommandText, "HideAllTurtles", turtleGraphicsCommand), new Tuple<string, string, Type>(GlobalConstants.ShowAllTurtlesCommandText, "ShowAllTurtles", turtleGraphicsCommand), new Tuple<string, string, Type>(GlobalConstants.DiagnoseCommandText, "Diagnose", turtleGraphicsCommand), new Tuple<string, string, Type>(GlobalConstants.ChangeTurtleImageCommandText, "ChangeTurtleImage", turtleGraphicsCommand), new Tuple<string, string, Type>(GlobalConstants.TurtleCommandText, "Turtle", turtleGraphicsCommand), new Tuple<string, string, Type>(GlobalConstants.DeleteTurtleCommandText, "DeleteTurtle", turtleGraphicsCommand), new Tuple<string, string, Type>(GlobalConstants.ActiveTurtleCommandText, "SetActiveTurtle", turtleGraphicsCommand), new Tuple<string, string, Type>(GlobalConstants.SetCommandText, "Set", turtleGraphicsCommand), new Tuple<string, string, Type>(GlobalConstants.AddCommandText, "Add", turtleGraphicsCommand), new Tuple<string, string, Type>(GlobalConstants.SubtractCommandText, "Subtract", turtleGraphicsCommand), new Tuple<string, string, Type>(GlobalConstants.MultiplyCommandText, "Multiply", turtleGraphicsCommand), new Tuple<string, string, Type>(GlobalConstants.DivideCommandText, "Divide", turtleGraphicsCommand), new Tuple<string, string, Type>(GlobalConstants.RandomCommandText, "Random", turtleGraphicsCommand), new Tuple<string, string, Type>(GlobalConstants.SquareRootCommandText, "SquareRoot", turtleGraphicsCommand), new Tuple<string, string, Type>(GlobalConstants.StopCommandText, "Stop", typeof (TurtleGraphicsTerminationCommand)), new Tuple<string, string, Type>(GlobalConstants.IfCommandText, "If", typeof (TurtleGraphicsIfCommand)), new Tuple<string, string, Type>(GlobalConstants.RepeatCommandText, "Repeat", typeof (TurtleGraphicsRepeatCommand)), new Tuple<string, string, Type>(GlobalConstants.WhileCommandText, "While", typeof (TurtleGraphicsWhileCommand)), new Tuple<string, string, Type>(GlobalConstants.DoCommandText, "Do", typeof (TurtleGraphicsDoFunctionCommand)), new Tuple<string, string, Type>(GlobalConstants.ToCommandText, "To", typeof (TurtleGraphicsFunctionCommand)), new Tuple<string, string, Type>(GlobalConstants.ClearFunctionsCommandText, "ClearFunctions", turtleGraphicsCommand), new Tuple<string, string, Type>(GlobalConstants.ClearVariablesCommandText, "ClearVariables", turtleGraphicsCommand), new Tuple<string, string, Type>(GlobalConstants.RemarkCommandText, "Remark", turtleGraphicsCommand), new Tuple<string, string, Type>(GlobalConstants.SinCommandText, "Sin", turtleGraphicsCommand), new Tuple<string, string, Type>(GlobalConstants.CosCommandText, "Cos", turtleGraphicsCommand), new Tuple<string, string, Type>(GlobalConstants.TanCommandText, "Tan", turtleGraphicsCommand), new Tuple<string, string, Type>(GlobalConstants.PowerCommandText, "Power", turtleGraphicsCommand) }; }
public static void InitializeClass(TestContext ctx) { TurtleGraphicsLexicalAnalyser = MockRepository.GenerateMock<ITurtleGraphicsLexicalAnalyser>(); _turtleGraphicsCommands = MockRepository.GenerateMock<ITurtleGraphicsCommands>(); TurtleGraphicsSyntaxAnalyser = MockRepository.GenerateMock<ITurtleGraphicsSyntaxAnalyser>(); }
private static void CanExecuteCommand(List<string> args, ITurtleGraphicsCommands turtleGraphicsSystemMock, TurtleGraphicsAttribute turtleGraphicsAttribute, List<TurtleGraphicsArgumentAttribute> argumentAttributes, string implementingFunctionName) { // Arrange var tokens = new List<string> { turtleGraphicsAttribute.CommandText}; if (args != null) { tokens.AddRange(args); } var textParserMock = GetTextParserMock(tokens); var turtleGraphicsCommand = new TurtleGraphicsCommand { Attribute = turtleGraphicsAttribute, ArgumentAttributes = argumentAttributes, CommandText = turtleGraphicsAttribute.CommandText, ArgumentValues = args, Status = TurtleGraphicsCommandStatus.Valid, ExecutionContext = turtleGraphicsSystemMock, ImplementingFunctionName = implementingFunctionName, }; var turtleGraphicsSyntaxAnalyser = GetSyntaxAnalyserMock(turtleGraphicsCommand); var commandProcessor = GetExecutionEngineInstance(textParserMock, turtleGraphicsSyntaxAnalyser); var commandLine = turtleGraphicsAttribute.CommandText + " "; if (args != null) { foreach (var arg in args) { commandLine += arg; commandLine += " "; } } // Act var turtleGraphicsCommandReturned = commandProcessor.ExecuteCommandLine(commandLine, false, true); // Assert textParserMock.VerifyAllExpectations(); turtleGraphicsSystemMock.VerifyAllExpectations(); turtleGraphicsSyntaxAnalyser.VerifyAllExpectations(); Assert.AreEqual(TurtleGraphicsCommandStatus.Valid, turtleGraphicsCommandReturned[0].Status); }