Click here to Skip to main content
15,895,656 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Issue:
When I run the unit test application I receive the following error
"
Test method KT_TestProject.UnitTest1.Load_ProductsTest_Pass threw exception: System.MissingMethodException: Method 'ASP.default_aspx.Button2_Click' not found..
"

Code:
Application:
C#
protected void Page_Load(object sender, EventArgs e)
       {
           Button2.Click += Button2_Click;
       }

void Button2_Click(object sender, EventArgs e)
       {
           TextBox2.Text = TextBox1.Text;
       }


Unit Test:
C#
[TestMethod]
        [HostType("ASP.NET")]
        [UrlToTest("http://localhost/Sample/Default.aspx")]        
        public void Load_Pass()
        {  
Page page = testContextInstance.RequestedPage;
            PrivateObject po = new PrivateObject(page);
po.Invoke("Button2_Click", page, EventArgs.Empty);
Assert.Inconclusive("Doesnot return anything");

}
Posted
Updated 26-Jul-11 6:25am
v2
Comments
[no name] 26-Jul-11 11:12am    
Format your code for better readability.

Did you try declaring Button2_Click method as 'internal' (or 'public' in case your test class is not in the same assembly).
schampacc 27-Jul-11 5:13am    
Thanks! that worked

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900