I'm trying to set a Test environment for my actual project but having troubles connecting to my Test db, we don't have a mock.
I use some code to determine if is a Design Time or Run Time like this:
ConnectionStringSettings connString = null;
string myConnString = null;
bool designMode = (LicenseManager.UsageMode == LicenseUsageMode.Designtime);
if (designMode)
{
connString = new ConnectionStringSettings()
{
ConnectionString = "metadata=res://*/Seguridad.csdl|res://*/Seguridad.ssdl|res://*/Seguridad.msl;provider=System.Data.SqlClient;provider connection string=\"data source=****ServerName****;initial catalog=****DbName****;persist security info=True;user id=****user****;password=****pwd****;MultipleActiveResultSets=True;App=EntityFramework\""
};
DebugConnection Cx = DebugModeConnections.GetConnection("Desarrollo");
_usuario = Cx.Usuario;
_password = Cx.Password;
_ServerName = Cx.Server;
_DbName = Cx.Db;
}
else
{
foreach (ConnectionStringSettings conn in ConfigurationManager.ConnectionStrings)
{
if (conn.Name == ConfiguracionApp.NombreContextoDb)
connString = conn;
}
}
It works fine for my Design and run time and allow me to use real data for GUI design. But now I want to implement test and it doesn't work as I expected.
There is a way to determine if the compiler is on Test Time or something like LicenseManager.UsageMode wich I can use ?