Наследование: ICommandSetter
Пример #1
0
 public void Accept(GetState command)
 {
     _builder.AppendLine($"{command.TargetName} = getState {command.Direction}");
 }
Пример #2
0
        public void AddGetState()
        {
            const string code = @"int ione
                                  ione = 5
                                  int itwo
                                  itwo = 2
                                  int three
                                  int four
                                  int five";
            const int indexToAdd = 6;
            var commandToAdd = new GetState("three", 2);
            var commands = GenerateCommands(code);
            var mutation = GetMutationForGetState(commands, commandToAdd, indexToAdd);

            mutation.Transform();

            const string resultCode = @"int ione
                                        ione = 5
                                        int itwo
                                        itwo = 2
                                        int three
                                        int four
                                        three = getState 2
                                        int five";
            var resultCommands = GenerateCommands(resultCode);
            Assert.IsTrue(AreCollectionsEquals(commands, resultCommands));
        }
Пример #3
0
        public void Accept(GetState command)
        {
            if (!_conditions.Peek()) return;

            _variables[command.TargetName] = _executorToolset.GetState(command.Direction);
        }
Пример #4
0
 private AddCommandMutation GetMutationForGetState(ICommandsList commands, GetState command, int indexToAdd)
 {
     var random = new AddRandom();
     var targetDeclarationIndex = GetDeclarationIndexOfVariable(command.TargetName, commands);
     var direction = command.Direction;
     random.TuneGetState(targetDeclarationIndex, direction, indexToAdd);
     return new AddCommandMutation(random, commands);
 }
 public void Accept(GetState command)
 {
     var comparableCommand = _second as GetState;
     _isEqual = command.TargetName == comparableCommand.TargetName &&
                command.Direction == comparableCommand.Direction;
 }
Пример #6
0
 private ReplaceCommandMutation GetMutationForGetState(ICommandsList commands, int replaceIndex, GetState command)
 {
     var random = new ReplaceRandom();
     var declarationIndex = GetDeclarationIndexOfVariable(command.TargetName, commands);
     var direction = command.Direction;
     random.TuneGetState(replaceIndex, declarationIndex, direction);
     return new ReplaceCommandMutation(random, commands);
 }
Пример #7
0
        public void ReplaceGetState()
        {
            const string code = @"int ione
                                  ione = 5
                                  int itwo
                                  itwo = 2
                                  int ithree
                                  ithree = ione
                                  itwo = getState 3";
            const int indexToReplace = 6;
            var commandToReplace = new GetState("ithree", 0);
            var commands = GenerateCommands(code);
            var mutation = GetMutationForGetState(commands, indexToReplace, commandToReplace);

            mutation.Transform();

            const string resultCode = @"int ione
                                        ione = 5
                                        int itwo
                                        itwo = 2
                                        int ithree
                                        ithree = ione
                                        ithree = getState 0";
            var resultCommands = GenerateCommands(resultCode);
            Assert.IsTrue(AreCollectionsEquals(commands, resultCommands));
        }
Пример #8
0
 public void Accept(GetState command)
 {
     if (!_variables.ContainsKey(command.TargetName))
     {
         _isExecutable = false;
         return;
     }
     //TODO
     _variables[command.TargetName] = _executorToolset.GetState(command.Direction);
 }