I wrote a couple of visual studio unit tests to test business logic included in worker role.
My worker role publishes message to Azure topics. For this I have specified connection strings in CloudConfig.cfg & I pick up the settings using RoleEnvironment.GetConfigurationSettingValue()
. Since tests run in their own app domain & not inside azure emulator. Call to those functions would obviously fail.
What are the best practices out there to handle this scenario?
Instead of using RoleEnvironment.GetConfigurationSettingValue
, use CloudConfigurationManager.GetSetting
. This will pick up configuration settings from appropriate config file - service configuration file if your code is running in context of a cloud service or app.config/web.config otherwise.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments