I have below feature with steps and class under test. When I change the Name field visibility to public I can retrieve the value after Table.CreateInstance<>()
but when make it private it's failing.
Scenario: Get employee details.
Given below employee create a user.
| Name | age |
| John | 28 |
Code
[Binding]
public class TableSteps
{
[Given(@"below employee create a user\.")]
public void GivenBelowEmployeeCreateAUser_(Table table)
{
Employee employee = table.CreateInstance<Employee>();
Console.Write("Name:" + employee.Name); //Works as it is public.
Console.Write("Name:"+ employee.EmpName); //No value returned here. Just null.
}
}
public class Employee
{
private string Name { get; set; } //not working.
//public string Name { get; set; } //works.
public int age { get; set; }
public Employee(String Name, int age)
{
this.Name = Name;
this.age = age;
}
public string EmpName
{
get { return Name; }
}
}