public void Accept(SetValue command) { if (!_variables.ContainsKey(command.TargetName)) { _isExecutable = false; return; } _variables[command.TargetName] = command.Value; }
public void Accept(SetValue command) { _builder.AppendLine($"{command.TargetName} = {command.Value}"); }
public void Accept(SetValue command) { if (!_conditions.Peek()) return; _variables[command.TargetName] = command.Value; }
private AddCommandMutation GetMutationForSetValue(ICommandsList commands, SetValue command, int indexToAdd) { var random = new AddRandom(); var declarationIndex = GetDeclarationIndexOfVariable(command.TargetName, commands); random.TuneSetValue(declarationIndex, command.Value, indexToAdd); return new AddCommandMutation(random, commands); }
public void AddSetValue() { const string code = @"int ione int itwo"; const int value = 5; const int indexToAdd = 1; var commandToAdd = new SetValue("ione", value); var commandsList = GenerateCommands(code); var mutation = GetMutationForSetValue(commandsList, commandToAdd, indexToAdd); mutation.Transform(); const string resultCode = @"int ione ione = 5 int itwo"; var resultCommands = GenerateCommands(resultCode); Assert.IsTrue(AreCollectionsEquals(commandsList, resultCommands)); }
public void Accept(SetValue command) { var comparableCommand = _second as SetValue; _isEqual = command.TargetName == comparableCommand.TargetName && command.Value == comparableCommand.Value; }
private ReplaceCommandMutation GetMutationForSetValue(ICommandsList commands, int replaceIndex, SetValue command) { var random = new ReplaceRandom(); var declarationIndex = GetDeclarationIndexOfVariable(command.TargetName, commands); random.TuneSetValue(replaceIndex, declarationIndex,command.Value); return new ReplaceCommandMutation(random, commands); }
public void ReplaceSetValue() { const string code = @"int ione ione = 5 int itwo itwo = 2 int ithree ithree = 6 "; const int indexToReplace = 5; var commandToReplace = new SetValue("ione", 3); var commands = GenerateCommands(code); var mutation = GetMutationForSetValue(commands, indexToReplace, commandToReplace); mutation.Transform(); const string resultCode = @"int ione ione = 5 int itwo itwo = 2 int ithree ione = 3"; var resultCommands = GenerateCommands(resultCode); Assert.IsTrue(AreCollectionsEquals(commands, resultCommands)); }