I have a library containing some Azure helper classes. Inside these helper classes I obtain settings such as the Azure account name and key. When running in Azure these settings are picked up from the cloud configuration file (cscfg). This all works fine.
In order to unit test these classes outside of Azure (specifically the RoleEnvironment) I created settings of the same variable names within the unit test project. These actually get saved within an app.config file and are edited via the settings section which lives under the properties section of my test project. Rather than create my own method of abstracting the cloud configuration settings from web.config/app.config settings I decided to use the CloudConfigurationManager class. However, when I run my unit tests none of my settings are picked up so I simply get nulls. If however, I change my app.config file to use settings in the 'appSettings' format below, then I do get valid values. The downside of this is I can no longer edit my settings using the settings editor page within visual studio.
So my question is am I doing something wrong or is this a limitation of the cloud configuration manager, whereby it can only pick up manually added appSettings but not applicationSettings added using the editor?
<appSettings>
<add key="Foo" value="MySettingValue"/>
</appSettings>
the above works, whereas the below does not:
<applicationSettings>
<ComponentsTest.Properties.Settings>
<setting name="Foo" serializeAs="String">
<value>MySettingValue</value>
</setting>
</ComponentsTest.Properties.Settings>
</applicationSettings>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…