Unit Test configure file

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello, In a Unit test with visual studio 2005

I have this code in the test assembly:
1.System.Configuration.Configuration config =
ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
2.ConnectionStringsSection csSection = config.ConnectionStrings;
3.ConnectionStringSettings cs =
csSection.ConnectionStrings[GABTSAUDITORIA_CONEXION];
4.ConnectionString = cs.ToString();

5.ConnectionString =
ConfigurationManager.ConnectionStrings[GABTSAUDITORIA_CONEXION].ConnectionString;

I have that write the file of configuration of this way:
[ClassInitialize()]
public static void InicializacionPruebas(TestContext testContext)
{
if (!File.Exists("vstesthost.exe.config"))
{
File.Copy(FICHERO_CONFIGURACION, "vstesthost.exe.config");
}


But if the assembly not contain the lines 1,2,3,4 then Where and How I have
to write the file of configuration?


Thanks
 
Hola, ya tengo la solución:
Con el nuevo código hay que poner un fichero de configuración con el nombre
user.config:
if (!File.Exists("user.config"))
{
File.Copy(FICHERO_CONFIGURACION, "user.config");
}
 
Back
Top