private static List <Command> Process( ITalkWithUser dialog, RenameCommand leftCommand, RenameCommand rightCommand) { if (leftCommand.ClassFullName == rightCommand.ClassFullName && leftCommand.Method == rightCommand.Method) { if (leftCommand.Variable == rightCommand.Variable) { if (leftCommand.NewName == rightCommand.NewName) { return(new List <Command> { leftCommand }); } else { var selectedName = dialog.Ask(new MessagesGenerator().VariableHasBeenRenamedDifferently(leftCommand.NewName, rightCommand.NewName)); var result = new RenameCommand(leftCommand.ClassFullName, leftCommand.Method, leftCommand.Variable, selectedName); return(new List <Command> { result }); } } else { if (leftCommand.NewName == rightCommand.NewName) { var newLeftName = dialog.Ask(new MessagesGenerator().VariablesHaveBeenRenamedWithConflict(leftCommand.Variable, leftCommand.NewName)); var newRightName = dialog.Ask(new MessagesGenerator().VariablesHaveBeenRenamedWithConflict(rightCommand.Variable, rightCommand.NewName)); if (newLeftName == newRightName) { throw new Exception(); } return(new List <Command> { new RenameCommand(leftCommand.ClassFullName, leftCommand.Method, leftCommand.Variable, newLeftName), new RenameCommand(rightCommand.ClassFullName, rightCommand.Method, rightCommand.Variable, newRightName) }); } else { return(new List <Command> { leftCommand, rightCommand }); } } } else { return(new List <Command> { leftCommand, rightCommand }); } }