13.6. Chapter Review#
What is the difference between a compile-time error and a runtime exception? Give an example of each.
What are the three blocks in C# exception handling? Describe when each one executes.
Why is it bad practice to catch
Exceptionas the base type for all error handling? What should you do instead?What happens if an exception is thrown inside a
finallyblock?Write a short code snippet that reads a number from the user and handles the case where the input is not a valid integer using
int.TryParserather than a try/catch. When isTryParsepreferable to exception handling?What is the difference between
throwandthrow exwhen re-throwing an exception? Which preserves the original stack trace?Describe the Red-Green-Refactor cycle in TDD. What does each color represent?
What is the role of
[TestClass]and[TestMethod]attributes in MSTest?In the
BasicMathexample, theMultiplymethod used+instead of*. Which test caught the bug, and what didAssert.AreEqualreport?What is the difference between a unit test and an integration test?