Skip to content

Commit 94ce49d

Browse files
committed
Add more tests for the AddAttributeAnnotationQuickFix
1 parent 6d4a334 commit 94ce49d

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

RubberduckTests/QuickFixes/AddAttributeAnnotationQuickFixTests.cs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,32 @@ Public Sub Foo()
5454
Assert.AreEqual(expectedCode, actualCode);
5555
}
5656

57+
[Test]
58+
[Category("QuickFixes")]
59+
public void KnownModuleAttributeWithoutAnnotationWhileOtherAttributeWithAnnotationPresent_QuickFixWorks()
60+
{
61+
const string inputCode =
62+
@"Attribute VB_PredeclaredID = True
63+
Attribute VB_Exposed = True
64+
'@Exposed
65+
Public Sub Foo()
66+
Const const1 As Integer = 9
67+
End Sub";
68+
//The attribute not present in the code pane code in the VBE.
69+
//So adding on top is OK.
70+
const string expectedCode =
71+
@"'@PredeclaredId
72+
Attribute VB_PredeclaredID = True
73+
Attribute VB_Exposed = True
74+
'@Exposed
75+
Public Sub Foo()
76+
Const const1 As Integer = 9
77+
End Sub";
78+
79+
var actualCode = ApplyQuickFixToFirstInspectionResult(inputCode, state => new MissingModuleAnnotationInspection(state));
80+
Assert.AreEqual(expectedCode, actualCode);
81+
}
82+
5783
[Test]
5884
[Category("QuickFixes")]
5985
public void KnownMemberAttributeWithoutAnnotation_QuickFixWorks()
@@ -100,6 +126,31 @@ Public Sub Foo()
100126
Assert.AreEqual(expectedCode, actualCode);
101127
}
102128

129+
[Test]
130+
[Category("QuickFixes")]
131+
public void KnownMemberAttributeWithoutAnnotationWhileOtherAttributeWithAnnotationPresent_QuickFixWorks()
132+
{
133+
const string inputCode =
134+
@"'@DefaultMember
135+
Public Sub Foo()
136+
Attribute Foo.VB_Description = ""Desc""
137+
Attribute Foo.VB_UserMemId = 0
138+
Const const1 As Integer = 9
139+
End Sub";
140+
141+
const string expectedCode =
142+
@"'@DefaultMember
143+
'@Description ""Desc""
144+
Public Sub Foo()
145+
Attribute Foo.VB_Description = ""Desc""
146+
Attribute Foo.VB_UserMemId = 0
147+
Const const1 As Integer = 9
148+
End Sub";
149+
150+
var actualCode = ApplyQuickFixToFirstInspectionResult(inputCode, state => new MissingMemberAnnotationInspection(state));
151+
Assert.AreEqual(expectedCode, actualCode);
152+
}
153+
103154
protected override IQuickFix QuickFix(RubberduckParserState state)
104155
{
105156
return new AddAttributeAnnotationQuickFix(new AnnotationUpdater(), new AttributeAnnotationProvider());

0 commit comments

Comments
 (0)