I have created a Console application project(proj name: ConsoleApp) with .Net core 3.1. I have added a specflow feature file where in I have defined my test scenario and also a class file which has my test case
[Given(@"I have started the application")]
public void GivenIHaveStartedTheApplication()
{
TestClass testClass1 = new TestClass();
testClass1.ReadConfigValues();
}
Also, I have added an App.config in the same ConsoleApp Project which looks like this
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="User" value="Admin" />
<add key="Password" value="nopassword" />
</appSettings>
</configuration>
TestClass is a C# class file which is residing in a different Class Library project(proj name: TestProject) with .Net Framework 4.7. This project has been referenced by ConsoleApp
Code for TestClass is as below
public class TestClass
{
public void ReadConfigValues()
{
string user = ConfigurationManager.AppSettings["User"];
string password = ConfigurationManager.AppSettings["Password"];
}
}
The issue I'm facing here is that the values for both user and password are returned as null. Basically ConfigurationManager.AppSettings has a count equal to zero.
Could anyone point out if I'm missing anything?