/
AdjustAttributeValuesQuickFixTests.cs
109 lines (96 loc) · 3.68 KB
/
AdjustAttributeValuesQuickFixTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
using NUnit.Framework;
using Rubberduck.Inspections.Concrete;
using Rubberduck.Inspections.QuickFixes;
using Rubberduck.Parsing.Inspections.Abstract;
using Rubberduck.Parsing.VBA;
using Rubberduck.Parsing.VBA.Parsing;
namespace RubberduckTests.QuickFixes
{
public class AdjustAttributeValuesQuickFixTests : QuickFixTestBase
{
[Test]
[Category("QuickFixes")]
public void ModuleAttributeOutOfSync_QuickFixWorks()
{
const string inputCode =
@"Attribute VB_Description = ""NotDesc""
'@ModuleAttribute VB_Description, ""Desc""
Public Sub Foo()
Const const1 As Integer = 9
End Sub";
const string expectedCode =
@"Attribute VB_Description = ""Desc""
'@ModuleAttribute VB_Description, ""Desc""
Public Sub Foo()
Const const1 As Integer = 9
End Sub";
var actualCode = ApplyQuickFixToFirstInspectionResult(inputCode, state => new AttributeValueOutOfSyncInspection(state), CodeKind.AttributesCode);
Assert.AreEqual(expectedCode, actualCode);
}
[Test]
[Category("QuickFixes")]
public void VbExtKeyModuleAttributeOutOfSync_QuickFixWorks()
{
const string inputCode =
@"Attribute VB_Ext_Key = ""Key"", ""NotValue""
Attribute VB_Ext_Key = ""OtherKey"", ""OtherValue""
'@ModuleAttribute VB_Ext_Key, ""Key"", ""Value""
Public Sub Foo()
Const const1 As Integer = 9
End Sub";
const string expectedCode =
@"Attribute VB_Ext_Key = ""Key"", ""Value""
Attribute VB_Ext_Key = ""OtherKey"", ""OtherValue""
'@ModuleAttribute VB_Ext_Key, ""Key"", ""Value""
Public Sub Foo()
Const const1 As Integer = 9
End Sub";
var actualCode = ApplyQuickFixToFirstInspectionResult(inputCode, state => new AttributeValueOutOfSyncInspection(state), CodeKind.AttributesCode);
Assert.AreEqual(expectedCode, actualCode);
}
[Test]
[Category("QuickFixes")]
public void MemberAttributeOutOfSync_QuickFixWorks()
{
const string inputCode =
@"'@MemberAttribute VB_Description, ""Desc""
Public Sub Foo()
Attribute Foo.VB_Description = ""NotDesc""
Const const1 As Integer = 9
End Sub";
const string expectedCode =
@"'@MemberAttribute VB_Description, ""Desc""
Public Sub Foo()
Attribute Foo.VB_Description = ""Desc""
Const const1 As Integer = 9
End Sub";
var actualCode = ApplyQuickFixToFirstInspectionResult(inputCode, state => new AttributeValueOutOfSyncInspection(state), CodeKind.AttributesCode);
Assert.AreEqual(expectedCode, actualCode);
}
[Test]
[Category("QuickFixes")]
public void VbExtKeyMemberAttributeOutOfSync_QuickFixWorks()
{
const string inputCode =
@"'@MemberAttribute VB_Ext_Key, ""Key"", ""Value""
Public Sub Foo()
Attribute Foo.VB_Ext_Key = ""Key"", ""NotValue""
Attribute Foo.VB_Ext_Key = ""OtherKey"", ""OtherValue""
Const const1 As Integer = 9
End Sub";
const string expectedCode =
@"'@MemberAttribute VB_Ext_Key, ""Key"", ""Value""
Public Sub Foo()
Attribute Foo.VB_Ext_Key = ""Key"", ""Value""
Attribute Foo.VB_Ext_Key = ""OtherKey"", ""OtherValue""
Const const1 As Integer = 9
End Sub";
var actualCode = ApplyQuickFixToFirstInspectionResult(inputCode, state => new AttributeValueOutOfSyncInspection(state), CodeKind.AttributesCode);
Assert.AreEqual(expectedCode, actualCode);
}
protected override IQuickFix QuickFix(RubberduckParserState state)
{
return new AdjustAttributeValuesQuickFix(new AttributesUpdater(state));
}
}
}