public NewInt CreateNewInt(int placeIndex) { var name = GetRandomName(); var command = new NewInt(name); return(command); }
private AddCommandMutation GetMutationForNewInt(ICommandsList commands, NewInt command, int indexToAdd) { var random = new AddRandom(); random.TuneNewInt(command.Name, indexToAdd); return(new AddCommandMutation(random, commands)); }
public void Accept(NewInt command) { if (_variables.ContainsKey(command.Name)) { _isExecutable = false; return; } _variables[command.Name] = null; }
public void Accept(NewInt command) { if (!_conditions.Peek()) { return; } _variables[command.Name] = null; }
public void IntParse() { const string name = "commandName"; var command = new NewInt(name); var commandParser = new CommandToStringParser(); var parsedCommand = commandParser.ParseCommand(command).Trim('\n', ' ', '\r'); var desiredResult = $"int {name}"; Assert.AreEqual(parsedCommand, desiredResult); }
private NewInt[] GetRandomDeclarationsBefore(int index, int numbers) { var result = new NewInt[numbers]; var declarations = FindAllDeclarationsBefore(index); if (declarations.Length == 0) { declarations = new[] { new NewInt(GetRandomName()) } } ; for (int i = 0; i < numbers; i++) { result[i] = ChooseRandom(declarations); } return(result); }
/// <summary> /// Produce a description that may be useful in debugging event handling and the undo manager. /// </summary> /// <returns></returns> public override string ToString() { string str = PresentationName + ": " + SubHint.ToString(NumberFormatInfo.InvariantInfo); if (Object != null) { str = str + " " + Object.ToString(); IGoLabeledPart goLabeledPart = Object as IGoLabeledPart; if (goLabeledPart != null) { str = str + " \"" + goLabeledPart.Text + "\""; } } if (IsBeforeChanging) { str += " (before)"; } str += ";"; if (OldInt != 0) { str = str + " " + OldInt.ToString(NumberFormatInfo.InvariantInfo); } if (OldValue != null) { str = str + " (" + OldValue.ToString() + ")"; } if (OldRect != default(RectangleF)) { str = str + " [" + OldRect.X.ToString(NumberFormatInfo.InvariantInfo) + "," + OldRect.Y.ToString(NumberFormatInfo.InvariantInfo) + " " + OldRect.Width.ToString(NumberFormatInfo.InvariantInfo) + "x" + OldRect.Height.ToString(NumberFormatInfo.InvariantInfo) + "]"; } str += " -->"; if (NewInt != 0) { str = str + " " + NewInt.ToString(NumberFormatInfo.InvariantInfo); } if (NewValue != null) { str = str + " (" + NewValue.ToString() + ")"; } if (NewRect != default(RectangleF)) { str = str + " [" + NewRect.X.ToString(NumberFormatInfo.InvariantInfo) + "," + NewRect.Y.ToString(NumberFormatInfo.InvariantInfo) + " " + NewRect.Width.ToString(NumberFormatInfo.InvariantInfo) + "x" + NewRect.Height.ToString(NumberFormatInfo.InvariantInfo) + "]"; } return(str); }
public void AddNewInt() { const string code = @"int ione int itwo"; const int indexToAdd = 2; var commandToAdd = new NewInt("ithree"); var commandsList = GenerateCommands(code); var mutation = GetMutationForNewInt(commandsList, commandToAdd, indexToAdd); mutation.Transform(); const string resultCode = @"int ione int itwo int ithree"; var resultCommandsList = GenerateCommands(resultCode); Assert.IsTrue(AreCollectionsEquals(commandsList, resultCommandsList)); }
public void ReplaceNewInt() { const string code = @"int ione ione = 5 int itwo itwo = 2"; const int indexToReplace = 2; var commandToReplace = new NewInt("noname"); var commands = GenerateCommands(code); var mutation = GetMutationForNewInt(commands, indexToReplace, commandToReplace); mutation.Transform(); const string resultCode = @"int ione ione = 5 int noname itwo = 2"; var resultCommands = GenerateCommands(resultCode); Assert.IsTrue(AreCollectionsEquals(commands, resultCommands)); }
private bool EqualsNewInt(NewInt x, NewInt y) { return(x.Name == y.Name); }
public void Accept(NewInt command) { _isEqual = command.Name == (_second as NewInt).Name; }
public void Accept(NewInt command) { _builder.AppendLine($"int {command.Name}"); }
private ReplaceCommandMutation GetMutationForNewInt(ICommandsList commands, int replaceIndex, NewInt command) { var random = new ReplaceRandom(); random.TuneNewInt(replaceIndex, command.Name); return(new ReplaceCommandMutation(random, commands)); }