public void BindCondition() { // Set a condition on the request, and create a new pending breakpoint. var testCondition = "testCondition"; SetCondition(enum_BP_COND_STYLE.BP_COND_WHEN_TRUE, testCondition); pendingBreakpoint = debugPendingBreakpointFactory.Create( mockBreakpointManager, mockProgram, mockBreakpointRequest, mockTarget, mockMarshal); List <SbBreakpointLocation> mockBreakpointLocations = CreateMockBreakpointLocations(1); MockBreakpoint(mockBreakpointLocations); MockDocumentPosition(TEST_FILE_NAME, LINE_NUMBER, COLUMN_NUMBER); var mockBoundBreakpoint = Substitute.For <IBoundBreakpoint>(); mockBoundBreakpointFactory.Create(pendingBreakpoint, mockBreakpointLocations[0], mockProgram, Guid.Empty).Returns(mockBoundBreakpoint); var result = pendingBreakpoint.Bind(); IDebugErrorBreakpoint2 breakpointError = GetBreakpointError(); var boundBreakpoints = GetBoundBreakpoints(); Assert.AreEqual(1, boundBreakpoints.Count); Assert.AreSame(mockBoundBreakpoint, boundBreakpoints[0]); mockBoundBreakpoint.Received().SetCondition(requestInfo.bpCondition); mockBreakpointManager.Received().RegisterPendingBreakpoint(pendingBreakpoint); Assert.AreEqual(null, breakpointError); Assert.AreEqual(VSConstants.S_OK, result); }
public void GetBreakpointResolutionNullAddress() { SbBreakpointLocation breakpointLocationNullAddress = Substitute.For <SbBreakpointLocation>(); const SbAddress NULL_ADDRESS = null; breakpointLocationNullAddress.GetAddress().Returns(NULL_ADDRESS); IDebugBoundBreakpoint2 boundBreakpointNullAddress = boundBreakpointFactory.Create( mockPendingBreakpoint, breakpointLocationNullAddress, mockprogram, Guid.Empty); IDebugBreakpointResolution2 breakpointResolutionNullAddress; Assert.AreEqual(VSConstants.E_FAIL, boundBreakpointNullAddress.GetBreakpointResolution( out breakpointResolutionNullAddress)); Assert.AreEqual(null, breakpointResolutionNullAddress); }
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); }