Mock IConfigurate in xUnit

If you want mock IConfiguration use following code: or copy secrets.json configuration file to output directory: projectName\bin\Debug\netcoreapp3.1 and then use following code in ContextFixture: Config json file e.g. secrets.json:

Secret storage in .NET

Enable secret storage:Type “dotnet user-secrets init” into Package Manager Console <UserSecretsId> can be found in .csproj file. Set a secret (Package Manager Console):dotnet user-secrets set “ApiKey” “test123” or to remove it:dotnet user-secrets remove “ApiKey” To check if exists:dotnet user-secrets listorManage secret through GUI -> right click on project -> Manage User Secrets -> it opensContinue reading “Secret storage in .NET”