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)
 {
     _turtleGraphicsControlStructuresMock = MockRepository.GenerateMock<ITurtleGraphicsControlStructures>();
     TurtleGraphicsLexicalAnalyser = MockRepository.GenerateMock<ITurtleGraphicsLexicalAnalyser>();
     TurtleGraphicsSyntaxAnalyser = MockRepository.GenerateMock<ITurtleGraphicsSyntaxAnalyser>();
 }
        private static List<TurtleGraphicsCommand> CanExecuteCommand(List<string> args, ITurtleGraphicsControlStructures
            turtleGraphicsControlStructuresMock, TurtleGraphicsAttribute turtleGraphicsAttribute,
            List<TurtleGraphicsArgumentAttribute> argumentAttributes, TurtleGraphicsCommand turtleGraphicsCommand,
            string implementingFunctionName, ExecutionEngineStatusChangedEventHandler stateChangedHandler = null,
            bool hasCompletedWithoutErrors = true)
        {
            // Arrange
            var tokens = new List<string> { turtleGraphicsAttribute.CommandText};

            if (args != null)
            {
                tokens.AddRange(args);
            }

            var textParserMock = GetTextParserMock(tokens);

            turtleGraphicsCommand.Attribute = turtleGraphicsAttribute;
            turtleGraphicsCommand.ArgumentAttributes = argumentAttributes;
            turtleGraphicsCommand.CommandText = turtleGraphicsAttribute.CommandText;
            turtleGraphicsCommand.ArgumentValues = args;
            turtleGraphicsCommand.Status = TurtleGraphicsCommandStatus.Valid;
            turtleGraphicsCommand.ExecutionContext = turtleGraphicsControlStructuresMock;
            turtleGraphicsCommand.ImplementingFunctionName = implementingFunctionName;

            var turtleGraphicsSyntaxAnalyser = GetSyntaxAnalyserMock(turtleGraphicsCommand);
            var executionEngine = GetExecutionEngineInstance(textParserMock, turtleGraphicsSyntaxAnalyser);

            if (stateChangedHandler != null)
            {
                executionEngine.StatusChanged += stateChangedHandler;
            }

            var commandLine = turtleGraphicsAttribute.CommandText + " ";

            if (args != null)
            {
                foreach (var arg in args)
                {
                    commandLine += arg;
                    commandLine += " ";
                }
            }

            // Act
            var turtleGraphicsCommandReturned = executionEngine.ExecuteCommandLine(commandLine, false, true);

            // Assert
            textParserMock.VerifyAllExpectations();
            turtleGraphicsControlStructuresMock.VerifyAllExpectations();
            Assert.AreEqual(hasCompletedWithoutErrors, executionEngine.HasExecutedWithoutErrors());

            return turtleGraphicsCommandReturned;
        }