public void Data_added_to_existing_exception() { // Arrange NullReferenceException exception = null; try { ExceptionFactory.ThrowIf <NullReferenceException>(true, "Custom Message"); } catch (NullReferenceException ex) { exception = ex; } var data = new KeyValuePair <string, string>("Key", "Value"); // Arrange ExceptionFactory.AddExceptionData(exception, data); // Assert Assert.IsTrue(exception.Data.Contains(data.Key)); Assert.AreEqual(data.Value, exception.Data[data.Key]); }