Saturday, February 16, 2008

C# - Debugging and Testing Questions

1. What debugging tools come with the .NET SDK?
1. CorDBG – command-line debugger. To use CorDbg, you must compile the original C# file using the /debug switch. 2. DbgCLR – graphic debugger. Visual Studio .NET uses the DbgCLR.
2. What does assert() method do?

In debug compilation, assert takes in a Boolean condition as a parameter, and shows the error dialog if the condition is false. The program proceeds without any interruption if the condition is true.
3. What’s the difference between the Debug class and Trace class?

Documentation looks the same. Use Debug class for debug builds, use Trace class for both debug and release builds.
4. Why are there five tracing levels in System.Diagnostics.TraceSwitcher?

The tracing dumps can be quite verbose. For applications that are constantly running you run the risk of overloading the machine and the hard drive. Five levels range from None to Verbose, allowing you to fine-tune the tracing activities.
5. Where is the output of TextWriterTraceListener redirected?

To the Console or a text file depending on the parameter passed to the constructor.
6. How do you debug an ASP.NET Web application?

Attach the aspnet_wp.exe process to the DbgClr debugger.
7. What are three test cases you should go through in unit testing?

1. Positive test cases (correct data, correct output).2. Negative test cases (broken or missing data, proper handling).3. Exception test cases (exceptions are thrown and caught properly). Can you change the value of a variable while debugging a C# application? Yes. If you are debugging via Visual Studio.NET, just go to Immediate window.