コード例 #1
0
 private void AssertDictionaryNoException(DictionaryCaller callMe)
 {
     try
     {
         callMe.Invoke(_testOld);
     }
     catch (Exception e)
     {
         Assert.Fail("Original dictionary threw an exception: " + e);
     }
     try
     {
         callMe.Invoke(_testChecked);
     }
     catch (Exception e)
     {
         Assert.Fail("Checked dictionary threw an exception: " + e);
     }
 }
コード例 #2
0
 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);
 }