Question: What is the best way to test production only config files before they are deployed to produciton?

The config files for non production environment could get easily tested in their respective environments. But how can be production environment tested before production deployment happens?

For example, the DB name in STAGE is different than the DB name in prod. 

What if STAGE config file has correct DB name and is tested okay. Now, the prod config file has "typo" in the config file. This typo will not be discovered until its deployed in production. 

Is there a way to test this config file with typo error before it goes to production?

thanks

Answer: 
Under `appSettings` in the web.config file, I use this key:

```
<add key="CurrentEnvironment" value="0"/>
<!--        
    Public Enum Environments
       Development = 0          
       Alpha = 1                
       ReleaseCandidate = 2    
       Production = 3           
    End Enum
-->

```

And as you can see in my comments, this corresponds to an Enum in my Helpers.vb class that is used like so:

```
Public Shared CurrentEnvironment As Environments = DirectCast(WebConfigurationManager.AppSettings("CurrentEnvironment"), Environments)

```

This allows you to write Environment specific code such as URLs, Database Connections, etc.

I've found it super helpful.

*-- sorry for the VB.NET code, but I'm sure you can covert easily --*

**EDIT based on the OP edit:**

Why don't you create a ***[Unit Test project](http://msdn.microsoft.com/en-us/library/aa833171.aspx)***?
Probably the best way to achieve this is create a separate web site in your production environment as a "stage". Then you can roll your new config to this site first to test it and if everything looks OK migrate it over to your real production site. Otherwise, you can't be guaranteed it will behave the same as being on your production server.