Skip to content

Commit 62c4bd2

Browse files
committed
Add failing test for unexpected behaviour from issue #4558
1 parent b25e5be commit 62c4bd2

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

RubberduckTests/Inspections/IllegalAnnotationsInspectionTests.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Threading;
33
using NUnit.Framework;
44
using Rubberduck.Inspections.Concrete;
5+
using Rubberduck.VBEditor.SafeComWrappers;
56
using RubberduckTests.Mocks;
67

78
namespace RubberduckTests.Inspections
@@ -695,6 +696,32 @@ End Sub
695696
}
696697
}
697698

699+
//Issue #4558.
700+
[Test]
701+
[Category("Inspections")]
702+
public void FolderBelowOptionExplicitAndAboveImplements_NoResult()
703+
{
704+
const string inputCode = @"Option Explicit
705+
'@Folder(""Excel.Abstract"")
706+
Implements IWorkbookData
707+
708+
";
709+
const string interfaceCode = @"Option Explicit
710+
'@Folder(""Excel.Abstract"")
711+
Implements IWorkbookData
712+
713+
";
714+
var vbe = MockVbeBuilder.BuildFromModules(new[]{("testClass", inputCode, ComponentType.ClassModule), ("IWorkbookData", interfaceCode, ComponentType.ClassModule) });
715+
using (var state = MockParser.CreateAndParse(vbe.Object))
716+
{
717+
var inspection = new IllegalAnnotationInspection(state);
718+
var inspector = InspectionsHelper.GetInspector(inspection);
719+
var inspectionResults = inspector.FindIssuesAsync(state, CancellationToken.None).Result;
720+
721+
Assert.IsFalse(inspectionResults.Any());
722+
}
723+
}
724+
698725
[Test]
699726
[Category("Inspections")]
700727
public void InspectionName()

RubberduckTests/Mocks/MockVbeBuilder.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,13 +171,21 @@ public static Mock<IVBE> BuildFromSingleModule(string content, string name, Comp
171171
/// Builds a mock VBE containing multiple standard modules.
172172
/// </summary>
173173
public static Mock<IVBE> BuildFromStdModules(params (string name, string content)[] modules)
174+
{
175+
return BuildFromModules(modules.Select(tpl => (tpl.name, tpl.content, ComponentType.StandardModule)).ToArray());
176+
}
177+
178+
/// <summary>
179+
/// Builds a mock VBE containing one project with multiple modules.
180+
/// </summary>
181+
public static Mock<IVBE> BuildFromModules(params (string name, string content, ComponentType componentType)[] modules)
174182
{
175183
var vbeBuilder = new MockVbeBuilder();
176184

177185
var builder = vbeBuilder.ProjectBuilder(TestProjectName, ProjectProtection.Unprotected);
178186
foreach (var module in modules)
179187
{
180-
builder.AddComponent(module.name, ComponentType.StandardModule, module.content);
188+
builder.AddComponent(module.name, module.componentType, module.content);
181189
}
182190

183191
var project = builder.Build();

0 commit comments

Comments
 (0)