public void ExceptionPropertyTest() { IClrThread thread = Thread.Current.ClrThread; Assert.False(thread.IsFinalizerThread); ClrException exception = Variable.CastAs <ClrException>(thread.LastThrownException); Assert.NotNull(exception); Assert.Equal("IOE Message", exception.Message); Assert.Equal("System.InvalidOperationException", exception.GetCodeType().Name); Assert.NotNull(exception.InnerException); Assert.Equal("FNF Message", exception.InnerException.Message); Assert.Equal("System.IO.FileNotFoundException", exception.InnerException.GetCodeType().Name); CodeFunction[] stackTrace = exception.StackTrace; Assert.Equal(4, stackTrace.Length); Assert.Equal("Program.Inner()", stackTrace[0].FunctionNameWithoutModule); Assert.Equal("Program.Middle()", stackTrace[1].FunctionNameWithoutModule); Assert.Equal("Program.Outer()", stackTrace[2].FunctionNameWithoutModule); Assert.Equal("Program.Main(System.String[])", stackTrace[3].FunctionNameWithoutModule); Assert.Equal((uint)11, stackTrace[3].SourceFileLine); Assert.Equal("nestedexception.cs", Path.GetFileName(stackTrace[3].SourceFileName).ToLowerInvariant()); Assert.Equal(0x80131509, (uint)exception.HResult); Assert.Null(exception.HelpLink); Assert.Null(exception.Source); Assert.Null(exception.StackTraceString); try { IDictionary data = exception.Data; throw new Exception("This should never happen"); } catch (NotImplementedException) { } }
public void CodeCoverageTest() { DataReader dataReader = new DataReader(Process.Current); Thread thread = Thread.Current; int contextLength = thread.ThreadContext.Bytes.Length; Microsoft.Diagnostics.Runtime.VirtualQueryData vq; Assert.False(dataReader.CanReadAsync); Assert.NotEmpty(dataReader.EnumerateAllThreads()); Assert.True(dataReader.GetThreadContext(thread.SystemId, 0, (uint)contextLength, new byte[contextLength])); Assert.Equal(thread.TebAddress, dataReader.GetThreadTeb(thread.SystemId)); Assert.Equal((uint)0, dataReader.ReadDwordUnsafe(0)); Assert.Equal((ulong)0, dataReader.ReadPointerUnsafe(0)); Assert.False(dataReader.VirtualQuery(0, out vq)); Debugger.DontUseDumpReader = true; ClrException exception = Variable.CastAs<ClrException>(thread.ClrThread.LastThrownException); Assert.Equal("IOE Message", exception.Message); Debugger.DontUseDumpReader = false; dataReader.Flush(); dataReader.Close(); }