// Create default mocks, and return values for the code context position. void MockCodeContext(ulong address) { // Create mock code context with the specified address. var mockCodeContext = Substitute.For <IDebugCodeContext2>(); System.Action <CONTEXT_INFO[]> setContextInfo = infos => { infos[0].bstrAddress = "0x" + address.ToString("x16"); infos[0].dwFields = enum_CONTEXT_INFO_FIELDS.CIF_ADDRESS; }; ((IDebugMemoryContext2)mockCodeContext) .GetInfo(Arg.Any <enum_CONTEXT_INFO_FIELDS>(), Arg.Do(setContextInfo)) .Returns(VSConstants.S_OK); mockCodeContext .GetInfo(Arg.Any <enum_CONTEXT_INFO_FIELDS>(), Arg.Do(setContextInfo)) .Returns(VSConstants.S_OK); mockMarshal.GetCodeContextFromIntPtr(Arg.Any <IntPtr>()).Returns( mockCodeContext); }