question

BradleyRogers-3891 avatar image
0 Votes"
BradleyRogers-3891 asked YijingSun-MSFT commented

How to test a method in an existing application?

There is a large application with 6 projects and 20 references. It cannot be run as a standalone application.

The question here is about invoking one specific method in one part of code that happens with a mouse click of the app in use. The code was written around 2005 and added to.

When the app is running and the user runs a page it brings sql data in, the user clicks on an item, the goal is to tell VS to run this method with the data just like the web page does. Is that possible? VS has the whole thing loaded up, it may not even build, the hope is to say start in this method, pass in the value "id=x43532343" and single step like it was debugging, but i dont care about anything else, if it hits some external reference that doesnt work? then stop and say cant continue.

But is testing from a method possible this way? I open some .cs file, go to some method, right click and say debug from here, it asks for input parameters, enter that, then click GO?

If it could run there would be a breakpoint at that method, and it would already have the params, then i could single step and see what happens and where it croaks. But how to invoke a method directly from a large project and step in?

dotnet-aspnet-general
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @BradleyRogers-3891 , welcome to Microsoft Q&A forum. What kind of projects do you use? Besides, I see you mentioned .cs, so you are using C# language right?

0 Votes 0 ·

Hi, I was using the other forum a while, but it somehow logged in new here but its ok.

its asp.net 4.7 web forms so each page may have the html and .cs file with it? Am using VS 2019 (or 2017) but its C# and the older web technology and this one is big.

It has to be merged in with other files for the site to run, so since debugging is not possible, was hoping to test methods in place? if that makes sense?

May have to just copy the method into a new project, then find its dependencies and load that, but its a very long process to try to build up a new project picking the code that way.

Ive never tried to test this way so my question i guess is about how to test a method or did the question make sense? thanks

0 Votes 0 ·

1 Answer

BradleyRogers-3891 avatar image
0 Votes"
BradleyRogers-3891 answered YijingSun-MSFT commented

Hi could you please tell me where to find folks who understand asp.net 4.7 web forms applications who could answer technical questions?

Im sorry your former forums were closed, it was the most helpful support there was.

· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @BradleyRogers-3891 ,
If you have a static method,do you care of creating one class in App_code folder and use this in your web form.
Best regards,
Yijing Sun

0 Votes 0 ·

hi, I dont understand what you mean, do I care of creating one class? are you suggesting to create a static method in the app_code folder, then try to run those other methods to be tested this way?

0 Votes 0 ·

Hi @BradleyRogers-3891 ,

are you suggesting to create a static method in the app_code folder, then try to run those other methods to be tested this way?

Yes.You are right.
Best regards,
Yijing Sun


0 Votes 0 ·