private void AssertDictionaryException(DictionaryCaller callMe, IEnumerable<string> messageComponents)
{
Exception oldEx = null;
try
{
callMe.Invoke(_testOld);
}
catch(Exception e)
{
oldEx = e;
}
Assert.IsNotNull(oldEx, "Original dictionary didn't throw exception.");
Exception newEx = null;
try
{
callMe.Invoke(_testChecked);
}
catch (Exception e)
{
newEx = e;
}
Assert.IsNotNull(newEx, "Checked dictionary didn't throw exception.");
Assert.AreEqual(oldEx.GetType(), newEx.GetType(), "Threw wrong type of exception: " + newEx);
foreach (string component in messageComponents)
{
Assert.Greater(newEx.Message.IndexOf(component), -1, "Message did not contain '" +
component + "'. Exception: " + newEx);
}
Console.WriteLine("Threw correct exception: " + newEx);
}