Skip to content

Commit a49e5cb

Browse files
committed
1) Changed tests to NUnit tests 2) Made the two inspections to conform to the base class changes. 3) Added localization strings
1 parent e25d536 commit a49e5cb

File tree

8 files changed

+88
-44
lines changed

8 files changed

+88
-44
lines changed

Rubberduck.Inspections/Concrete/StepIsNotSpecifiedInspection.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,11 @@ namespace Rubberduck.Inspections.Concrete
1717
{
1818
public sealed class StepIsNotSpecifiedInspection : ParseTreeInspectionBase
1919
{
20-
public StepIsNotSpecifiedInspection(RubberduckParserState state) : base(state, CodeInspectionSeverity.Warning) { }
21-
22-
public override Type Type => typeof(StepIsNotSpecifiedInspection);
20+
public StepIsNotSpecifiedInspection(RubberduckParserState state) : base(state, CodeInspectionSeverity.DoNotShow) { }
2321

2422
public override CodeInspectionType InspectionType => CodeInspectionType.LanguageOpportunities;
2523

26-
public override IEnumerable<IInspectionResult> GetInspectionResults()
24+
protected override IEnumerable<IInspectionResult> DoGetInspectionResults()
2725
{
2826
return Listener.Contexts
2927
.Where(result => !IsIgnoringInspectionResultFor(result.ModuleName, result.Context.Start.Line))

Rubberduck.Inspections/Concrete/StepOneIsRedundantInspection.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,11 @@ namespace Rubberduck.Inspections.Concrete
1717
{
1818
public sealed class StepOneIsRedundantInspection : ParseTreeInspectionBase
1919
{
20-
public StepOneIsRedundantInspection(RubberduckParserState state) : base(state) { }
21-
22-
public override Type Type => typeof(StepOneIsRedundantInspection);
20+
public StepOneIsRedundantInspection(RubberduckParserState state) : base(state, CodeInspectionSeverity.Hint) { }
2321

2422
public override CodeInspectionType InspectionType => CodeInspectionType.LanguageOpportunities;
2523

26-
public override IEnumerable<IInspectionResult> GetInspectionResults()
24+
protected override IEnumerable<IInspectionResult> DoGetInspectionResults()
2725
{
2826
return Listener.Contexts
2927
.Where(result => !IsIgnoringInspectionResultFor(result.ModuleName, result.Context.Start.Line))

Rubberduck.Parsing/Inspections/Resources/InspectionsUI.Designer.cs

Lines changed: 38 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Rubberduck.Parsing/Inspections/Resources/InspectionsUI.resx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -914,4 +914,16 @@ If the parameter can be null, ignore this inspection result; passing a null valu
914914
<data name="AddStepOneQuickFix" xml:space="preserve">
915915
<value>Add step</value>
916916
</data>
917+
<data name="StepIsNotSpecifiedInspectionMeta" xml:space="preserve">
918+
<value>Step of the for-next loop is not specified. This might be unintentional.</value>
919+
</data>
920+
<data name="StepOneIsRedundantInspectionMeta" xml:space="preserve">
921+
<value>1 is the default step in a for-next loop and therefore is redundant.</value>
922+
</data>
923+
<data name="StepIsNotSpecifiedInspectionName" xml:space="preserve">
924+
<value>'For...Next' loop step is not specified</value>
925+
</data>
926+
<data name="StepOneIsRedundantInspectionName" xml:space="preserve">
927+
<value>'For...Next' loop step 1 is redundant</value>
928+
</data>
917929
</root>

RubberduckTests/Inspections/StepNotSpecifiedInspectionTests.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
using Microsoft.VisualStudio.TestTools.UnitTesting;
1+
using NUnit.Framework;
22
using Rubberduck.Inspections.Concrete;
3+
using Rubberduck.Parsing.Inspections.Resources;
34
using RubberduckTests.Mocks;
45
using System.Linq;
56
using System.Threading;
67

78
namespace RubberduckTests.Inspections
89
{
9-
[TestClass]
10+
[TestFixture]
1011
public class StepNotSpecifiedInspectionTests
1112
{
12-
[TestMethod]
13-
[TestCategory("Inspections")]
13+
[Test]
14+
[Category("Inspections")]
1415
public void StepNotSpecified_ReturnsResult()
1516
{
1617
string inputCode =
@@ -22,8 +23,8 @@ public void StepNotSpecified_ReturnsResult()
2223
this.TestStepNotSpecifiedInspection(inputCode, 1);
2324
}
2425

25-
[TestMethod]
26-
[TestCategory("Inspections")]
26+
[Test]
27+
[Category("Inspections")]
2728
public void StepNotSpecified_NestedLoopsAreDetected()
2829
{
2930
string inputCode =
@@ -42,7 +43,7 @@ private void TestStepNotSpecifiedInspection(string inputCode, int expectedResult
4243
var vbe = MockVbeBuilder.BuildFromSingleStandardModule(inputCode, out _);
4344
var state = MockParser.CreateAndParse(vbe.Object);
4445

45-
var inspection = new StepIsNotSpecifiedInspection(state);
46+
var inspection = new StepIsNotSpecifiedInspection(state) { Severity = CodeInspectionSeverity.Warning };
4647
var inspector = InspectionsHelper.GetInspector(inspection);
4748
var inspectionResults = inspector.FindIssuesAsync(state, CancellationToken.None).Result;
4849

RubberduckTests/Inspections/StepOneIsRedundantInspectionTests.cs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
1-
using Microsoft.VisualStudio.TestTools.UnitTesting;
1+
using NUnit.Framework;
22
using Rubberduck.Inspections.Concrete;
3+
using Rubberduck.Parsing.Inspections.Resources;
34
using RubberduckTests.Mocks;
4-
using System;
5-
using System.Collections.Generic;
65
using System.Linq;
7-
using System.Text;
86
using System.Threading;
9-
using System.Threading.Tasks;
107

118
namespace RubberduckTests.Inspections
129
{
13-
[TestClass]
10+
[TestFixture]
1411
public class StepOneIsRedundantInspectionTests
1512
{
16-
[TestMethod]
17-
[TestCategory("Inspections")]
13+
[Test]
14+
[Category("Inspections")]
1815
public void StepOneIsRedundant_ReturnsResult()
1916
{
2017
string inputCode =
@@ -26,8 +23,8 @@ public void StepOneIsRedundant_ReturnsResult()
2623
this.TestStepOneIsRedundantInspection(inputCode, 1);
2724
}
2825

29-
[TestMethod]
30-
[TestCategory("Inspections")]
26+
[Test]
27+
[Category("Inspections")]
3128
public void StepOneIsRedundant_NestedLoopsAreDetected()
3229
{
3330
string inputCode =
@@ -46,7 +43,7 @@ private void TestStepOneIsRedundantInspection(string inputCode, int expectedResu
4643
var vbe = MockVbeBuilder.BuildFromSingleStandardModule(inputCode, out _);
4744
var state = MockParser.CreateAndParse(vbe.Object);
4845

49-
var inspection = new StepOneIsRedundantInspection(state);
46+
var inspection = new StepOneIsRedundantInspection(state) { Severity = CodeInspectionSeverity.Warning };
5047
var inspector = InspectionsHelper.GetInspector(inspection);
5148
var inspectionResults = inspector.FindIssuesAsync(state, CancellationToken.None).Result;
5249

RubberduckTests/QuickFixes/AddStepOneQuickFixTests.cs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
using Microsoft.VisualStudio.TestTools.UnitTesting;
1+
using NUnit.Framework;
22
using Rubberduck.Inspections.Concrete;
33
using Rubberduck.Inspections.QuickFixes;
4+
using Rubberduck.Parsing.Inspections.Resources;
45
using RubberduckTests.Inspections;
56
using RubberduckTests.Mocks;
67
using System.Threading;
78

89
namespace RubberduckTests.QuickFixes
910
{
10-
[TestClass]
11+
[TestFixture]
1112
public class AddStepOneQuickFixTests
1213
{
13-
[TestMethod]
14-
[TestCategory("QuickFixes")]
14+
[Test]
15+
[Category("QuickFixes")]
1516
public void AddStepOne_QuickFixWorks_Remove()
1617
{
1718
var inputCode =
@@ -29,8 +30,8 @@ public void AddStepOne_QuickFixWorks_Remove()
2930
this.TestAddStepOneQuickFix(expectedCode, inputCode);
3031
}
3132

32-
[TestMethod]
33-
[TestCategory("QuickFixes")]
33+
[Test]
34+
[Category("QuickFixes")]
3435
public void AddStepOne_QuickFixWorks_NestedLoops()
3536
{
3637
var inputCode =
@@ -52,8 +53,8 @@ public void AddStepOne_QuickFixWorks_NestedLoops()
5253
this.TestAddStepOneQuickFix(expectedCode, inputCode);
5354
}
5455

55-
[TestMethod]
56-
[TestCategory("QuickFixes")]
56+
[Test]
57+
[Category("QuickFixes")]
5758
public void AddStepOne_QuickFixWorks_ComplexExpression()
5859
{
5960
var inputCode =
@@ -76,7 +77,7 @@ private void TestAddStepOneQuickFix(string expectedCode, string inputCode)
7677
var vbe = MockVbeBuilder.BuildFromSingleStandardModule(inputCode, out var component);
7778
var state = MockParser.CreateAndParse(vbe.Object);
7879

79-
var inspection = new StepIsNotSpecifiedInspection(state);
80+
var inspection = new StepIsNotSpecifiedInspection(state) { Severity = CodeInspectionSeverity.Warning };
8081
var inspector = InspectionsHelper.GetInspector(inspection);
8182
var inspectionResults = inspector.FindIssuesAsync(state, CancellationToken.None).Result;
8283

RubberduckTests/QuickFixes/RemoveStepOneQuickFixTests.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
using Microsoft.VisualStudio.TestTools.UnitTesting;
1+
using NUnit.Framework;
22
using Rubberduck.Inspections.Concrete;
33
using Rubberduck.Inspections.QuickFixes;
4+
using Rubberduck.Parsing.Inspections.Resources;
45
using RubberduckTests.Inspections;
56
using RubberduckTests.Mocks;
67
using System.Linq;
78
using System.Threading;
89

910
namespace RubberduckTests.QuickFixes
1011
{
11-
[TestClass]
12+
[TestFixture]
1213
public class RemoveStepOneQuickFixTests
1314
{
14-
[TestMethod]
15-
[TestCategory("QuickFixes")]
15+
[Test]
16+
[Category("QuickFixes")]
1617
public void StepOne_QuickFixWorks_Remove()
1718
{
1819
var inputCode =
@@ -30,8 +31,8 @@ public void StepOne_QuickFixWorks_Remove()
3031
this.TestStepOneQuickFix(expectedCode, inputCode);
3132
}
3233

33-
[TestMethod]
34-
[TestCategory("QuickFixes")]
34+
[Test]
35+
[Category("QuickFixes")]
3536
public void StepOne_QuickFixWorks_NestedLoops()
3637
{
3738
var inputCode =
@@ -58,7 +59,7 @@ private void TestStepOneQuickFix(string expectedCode, string inputCode)
5859
var vbe = MockVbeBuilder.BuildFromSingleStandardModule(inputCode, out var component);
5960
var state = MockParser.CreateAndParse(vbe.Object);
6061

61-
var inspection = new StepOneIsRedundantInspection(state);
62+
var inspection = new StepOneIsRedundantInspection(state) { Severity = CodeInspectionSeverity.Warning };
6263
var inspector = InspectionsHelper.GetInspector(inspection);
6364
var inspectionResults = inspector.FindIssuesAsync(state, CancellationToken.None).Result;
6465

0 commit comments

Comments
 (0)