public void Accept(CloneValue command) { if (!_variables.ContainsKey(command.SourceName) || !_variables.ContainsKey(command.TargetName) || _variables[command.SourceName] == null) { _isExecutable = false; return; } var value = _variables[command.SourceName]; _variables[command.TargetName] = value; }
public void AddCloneValue() { const string code = @"int ione ione = 5 int itwo"; const int indexToAdd = 3; var commandToAdd = new CloneValue("itwo", "ione"); var commands = GenerateCommands(code); var mutation = GetMutationForCloneValue(commands, commandToAdd, indexToAdd); mutation.Transform(); const string resultCode = @"int ione ione = 5 int itwo itwo = ione"; var resultCommands = GenerateCommands(resultCode); Assert.IsTrue(AreCollectionsEquals(commands, resultCommands)); }
private bool EqualsCloneValue(CloneValue x, CloneValue y) { return(x.SourceName == y.SourceName && x.TargetName == y.TargetName); }
public void Accept(CloneValue command) { _builder.AppendLine($"{command.TargetName} = {command.SourceName}"); }
private ReplaceCommandMutation GetMutationForCloneValue(ICommandsList commands, int replaceIndex, CloneValue command) { var random = new ReplaceRandom(); var targetDeclarationIndex = GetDeclarationIndexOfVariable(command.TargetName, commands); var sourceDeclarationIndex = GetDeclarationIndexOfVariable(command.SourceName, commands); random.TuneCloneValue(replaceIndex, targetDeclarationIndex, sourceDeclarationIndex); return(new ReplaceCommandMutation(random, commands)); }