public void TestReplaceEnvIntolerantExceptions()
{
bool threw = false;
try
{
Config.ReplaceEnvironmentVariables("%fake%windir%", false);
}
catch (Exception e)
{
threw = true;
Assert.IsTrue(e.Message.Contains("%fake%windir%"),
"Exception didn't contain the value");
}
Assert.IsTrue(threw, "Didn't throw with leading extraneous %.");
threw = false;
try
{
Config.ReplaceEnvironmentVariables("start%fake%windir%%%%%os%end", false);
}
catch (Exception e)
{
threw = true;
Assert.IsTrue(e.Message.Contains("start%fake%windir%%%%%os%end"),
"Exception didn't contain the value");
}
Assert.IsTrue(threw, "Didn't throw with many extraneous %s.");
threw = false;
try
{
Config.ReplaceEnvironmentVariables("Testing %windir%os% Testing", false);
}
catch (Exception e)
{
threw = true;
Assert.IsTrue(e.Message.Contains("Testing %windir%os% Testing"),
"Exception didn't contain the value");
}
Assert.IsTrue(threw, "Didn't throw with missing % for second var.");
threw = false;
try
{
Config.ReplaceEnvironmentVariables("Testing %NOT_A_REAL_VAR% Testing", false);
}
catch (Exception e)
{
threw = true;
Assert.IsTrue(e.Message.Contains("Testing %NOT_A_REAL_VAR% Testing"),
"Exception didn't contain the value");
}
Assert.IsTrue(threw, "Didn't throw with fake variable.");
}