I have one problem with integration testing in new .net core framework.
I've put some custom data in appsettings.json config and wanted to use it in some class.
"Data": {
"FolderName": "Data",
"Files": {
"Json": "work.json",
"Csv": "work.csv"
}
}
But when I do getting of the data inside class using IConfiguration interface - folderName
variable is empty.
private void InitializeDataFileFullPath(IConfiguration configuration)
{
var root = Directory.GetCurrentDirectory();
var folderName = configuration["Data:FolderName"];
if (folderName == null)
{
throw new NullReferenceException("Folder name with data files isn't specified in appsettings.json");
}
Also root
variable shows not right path - ".IntegrationTests\bin\Debug\netcoreapp2.0"
, but I expected to see something like \.WebApi\
I followed this manual. I also wanted to do something like there, but there's no project.json file anymore.
P.S.
- If I run project just under Visual Studio - everything is fine.
- My fixture class is absolutely the same as in manual from Microsoft. I thought all that manipulations provide me to have project which is being tested in right directory at least.
Thanks for any advice.
(added) The main thing of my post is that getting from appsettings shows different values for integration testing and for common running of the program. I want it to be the same.