I have a solution with several projects. In my API project I have a service that sends emails via Mailgun. Because I do not want to store the username and password in Git, what I've done is stored them in an external appSettings.config file and ignored that particular file. I'm then referencing the values using:
Code:
var username = ConfigurationManager.AppSettings["MailgunUsername"];
var password = ConfigurationManager.AppSettings["MailgunPassword"];
My issue is that the AppSettings never has my MailgunUsername or MailgunPassword keys. My gut reaction was that because I'm trying to test the service via a unit test project, perhaps I need to add the same external appSettings.config to the unit test project, but that didn't work either.
Then I thought that perhaps I've setup the config wrong, but I've gone through several examples online and it looks right.
This is what my Web.config (API project) and app.config (unit test project) file's have for the appSettings:
HTML Code:
<appSettings file="AppSettings.config">
<add key="webpages:Version" value="3.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
<add key="RuntimeEnvironment" value="Development" />
</appSettings>
And this is what my AppSettings.config file (in both projects) looks like:
HTML Code:
<appSettings>
<add key="MailgunUsername" value="-my username here-" />
<add key="MailgunPassword" value="-my password here-" />
</appSettings>
What am I doing wrong here?