Skip to content

Commit 9a9c721

Browse files
committed
fix EncapsulateFieldTests
Factory_NullSelectionReturnsNullPresenter relied on the implementation for GetQualifiedSelection() of the actual code. Mocks didn't follow suit and returned non-null QualifiedSelection for empty Selection instances. For whatever reason we can't set the mock up to CallBase() so we need to special case it. Using a ternary inside the lambda results in a compiler error
1 parent ce955a9 commit 9a9c721

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

RubberduckTests/Mocks/MockProjectBuilder.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,10 @@ private Mock<ICodePane> CreateCodePaneMock(string name, Selection selection, Moc
332332
var window = windows.CreateWindow(name);
333333
windows.Add(window);
334334

335-
codePane.Setup(p => p.GetQualifiedSelection()).Returns(() =>
336-
new QualifiedSelection(new QualifiedModuleName(component.Object), selection));
335+
codePane.Setup(p => p.GetQualifiedSelection()).Returns(() => {
336+
if (selection.IsEmpty()) { return null; }
337+
return new QualifiedSelection(new QualifiedModuleName(component.Object), selection);
338+
});
337339
codePane.SetupProperty(p => p.Selection, selection);
338340
codePane.Setup(p => p.Show());
339341

0 commit comments

Comments
 (0)