简体   繁体   中英

How to step into function to debug code in C# unit test?

I am trying to add a C# unit test (.net 4.5) to an existing solution that creates an instance of a class and calls a public method, and it will execute the code but not let me step into it. The code is in another project in the solution and I've written unit tests before that let me step into code. The assembly from the main project (that houses the code I want to step into) is in my GAC, but I added it to the unit test project as a project reference, not assembly reference.

Code in the test method:

[TestMethod]
public void CalculateChartlines_HasValidCL()
{
    //populating lvi, startDate, endDate
    ChartLines pchart = new ChartLines();
      
    CenterlineDateRange cdr = new CenterlineDateRange(0, true, startDate, endDate, 12);           

    var valuesOut = pchart.CalculateChartLines(ChartType.P_Chart, lvi, cdr); //steps over
    ...
}

ChartLines class in another project in the same solution (I added this project as a reference):

public class ChartLines : ILNCharts
{
    public ChartLines()
    { 
    
    }
    public List<ValuesOut> CalculateChartLines(ChartType chartType, List<ValuesIn> lvi, CenterlineDateRange cldr)
    {
        return GetCalculateChartLines(chartType, lvi, cldr);
    }
    ...
}

public interface ILNCharts
{
    List<ValuesOut> CalculateChartLines(ChartType chartType, List<ValuesIn> lvi, CenterlineDateRange cldr);
    <other methods>
}

maybe you need to add the dll from the project after building it in debug mode and then add the reference to your test project, i do that in my projects.

Maybe this would help too: debug a project with references in visual studio

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM