Abhijeet
Abhijeet

Reputation: 13856

Unit Test Azure Cloud Services

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?

Upvotes: 0

Views: 826

Answers (1)

Gaurav Mantri
Gaurav Mantri

Reputation: 136136

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.

Upvotes: 1

Related Questions