Exemple #1
0
        public void Rename_MethodWithSimilarName_RenamedOnlyCorrectMethod()
        {
            string str      = "add_hp(30); add_hp_bar();";
            string method   = "add_hp";
            string new_name = "heal";
            string expected = "heal(30); add_hp_bar();";

            RefactorMethod obj    = new RefactorMethod();
            string         actual = obj.Rename(str, method, new_name);

            Assert.AreEqual(expected, actual);
        }
Exemple #2
0
        public void Rename_MethodInConstString_RenamedOnlyMethod()
        {
            string str      = "add_hp(30){cout<<\"add_hp()\"}; add_hp_bar();";
            string method   = "add_hp";
            string new_name = "heal";
            string expected = "heal(30){cout<<\"add_hp()\"}; add_hp_bar();";

            RefactorMethod obj    = new RefactorMethod();
            string         actual = obj.Rename(str, method, new_name);

            Assert.AreEqual(expected, actual);
        }
Exemple #3
0
        public void Rename_VariableWithMethodName_RenamedOnlyMethod()
        {
            string str      = "void add_hp(){int add_hp;}";
            string method   = "add_hp";
            string new_name = "remove_hp";
            string expected = "void remove_hp(){int add_hp;}";

            RefactorMethod obj    = new RefactorMethod();
            string         actual = obj.Rename(str, method, new_name);

            Assert.AreEqual(expected, actual);
        }
Exemple #4
0
        public void Rename_NotFullMethodName_UnchangedString()
        {
            string str      = "add_hp(30); remove_hp(15);";
            string method   = "hp";
            string new_name = "add_cash";
            string expected = "add_hp(30); remove_hp(15);";

            RefactorMethod obj    = new RefactorMethod();
            string         actual = obj.Rename(str, method, new_name);

            Assert.AreEqual(expected, actual);
        }
Exemple #5
0
        public void Rename_MethodsMultiple_RenamedOnlyDesiredMethod()
        {
            string str      = "add_hp(30); remove_hp(15);";
            string method   = "add_hp";
            string new_name = "add_cash";
            string expected = "add_cash(30); remove_hp(15);";

            RefactorMethod obj    = new RefactorMethod();
            string         actual = obj.Rename(str, method, new_name);

            Assert.AreEqual(expected, actual);
        }
Exemple #6
0
        public void Rename_MethodOne_RenamedMethod()
        {
            string str      = "f(int a,int b);";
            string method   = "f";
            string new_name = "function";
            string expected = "function(int a,int b);";

            RefactorMethod obj    = new RefactorMethod();
            string         actual = obj.Rename(str, method, new_name);

            Assert.AreEqual(expected, actual);
        }
Exemple #7
0
        private void button1_Click(object sender, EventArgs e)
        {
            RefactorMethod refact = new RefactorMethod();

            switch (comboBox1.SelectedIndex)
            {
            case 0:
                richTextBox1.Text = refact.DelParam(richTextBox1.Text, textBox1.Text, textBox2.Text);
                break;

            case 1:
                richTextBox1.Text = refact.Rename(richTextBox1.Text, textBox1.Text, textBox2.Text);
                break;

            case 2:
                richTextBox1.Text = Refactor.AddParameter(richTextBox1.Text, textBox1.Text, textBox2.Text);
                break;

            case 3:
                richTextBox1.Text = Refactor.RenameVariable(richTextBox1.Text, textBox1.Text, textBox2.Text);
                break;
            }
        }