jeudi 25 juin 2015

In c#, how to access local variables of a method while writing unit tests

If I have a bellow sample code like this.

public class Employee
{
    public void CalculateEmpSal(int empId,int salary)
    {      
        // local varibles
        int Basic; 
        int HRA;       

        // Calculate employee salary
        Basic = salry * (0.40);
        HRA = Basic * (0.50);
    }
}

I need to write a Unit test for above "CalculateEmpSal" method to get Basic/Hra of the employee. For this, I want to access these method leval local variables from My Unit tests.I couldn't access these variables using reflection. Please help me .





Aucun commentaire:

Enregistrer un commentaire