public void SetUp() { string name = ""; mockBreakpoint = Substitute.For <RemoteBreakpoint>(); lineEntry = new LineEntryInfo(); mockPendingBreakpoint = Substitute.For <IDebugPendingBreakpoint2>(); mockBreakpointLocation = Substitute.For <SbBreakpointLocation>(); mockAddress = Substitute.For <SbAddress>(); mockAddress.GetLineEntry().Returns(lineEntry); mockBreakpointLocation.GetHitCount().Returns(HIT_COUNT); mockBreakpointLocation.GetLoadAddress().Returns(ADDRESS); mockBreakpointLocation.GetBreakpoint().Returns(mockBreakpoint); mockBreakpointLocation.GetId().Returns(ID); mockBreakpointLocation.GetAddress().Returns(mockAddress); mockprogram = Substitute.For <IDebugProgram2>(); mockDocumentContext = Substitute.For <IDebugDocumentContext2>(); mockDocumentContext.GetName(enum_GETNAME_TYPE.GN_NAME, out name).Returns( x => { x[1] = NAME; return(VSConstants.S_OK); }); mockBreakpointResolution = Substitute.For <IDebugBreakpointResolution2>(); mockDocumentContextFactory = Substitute.For <DebugDocumentContext.Factory>(); mockDocumentContextFactory.Create(lineEntry).Returns(mockDocumentContext); mockCodeContext = Substitute.For <IDebugCodeContext2>(); mockCodeContextFactory = Substitute.For <DebugCodeContext.Factory>(); mockCodeContextFactory.Create(ADDRESS, NAME, mockDocumentContext, Guid.Empty).Returns(mockCodeContext); mockBreakpointResolutionFactory = Substitute.For <DebugBreakpointResolution.Factory>(); mockBreakpointResolutionFactory.Create(mockCodeContext, mockprogram).Returns( mockBreakpointResolution); boundBreakpointFactory = new DebugBoundBreakpoint.Factory(mockDocumentContextFactory, mockCodeContextFactory, mockBreakpointResolutionFactory); boundBreakpoint = boundBreakpointFactory.Create( mockPendingBreakpoint, mockBreakpointLocation, mockprogram, Guid.Empty); }
// Constructor with factories for tests. DebugBoundBreakpoint(DebugDocumentContext.Factory documentContextFactory, DebugCodeContext.Factory codeContextFactory, DebugBreakpointResolution.Factory breakpointResolutionFactory, IDebugPendingBreakpoint2 pendingBreakpoint, SbBreakpointLocation breakpointLocation, IDebugProgram2 program, Guid languageGuid) { _pendingBreakpoint = pendingBreakpoint; _breakpointLocation = breakpointLocation; _enabled = true; _deleted = false; _disabledByPassCount = false; SbAddress address = breakpointLocation.GetAddress(); if (address != null) { LineEntryInfo lineEntry = address.GetLineEntry(); IDebugDocumentContext2 documentContext = null; string name = ""; // |lineEntry| is null if the breakpoint is set on an external function. if (lineEntry != null) { documentContext = documentContextFactory.Create(lineEntry); documentContext.GetName(enum_GETNAME_TYPE.GN_NAME, out name); } IDebugCodeContext2 codeContext = codeContextFactory.Create( breakpointLocation.GetLoadAddress(), name, documentContext, languageGuid); _breakpointResolution = breakpointResolutionFactory.Create(codeContext, program); } else { Trace.WriteLine("Warning: Unable to obtain address from breakpoint location." + " No breakpoint resolution created."); } }