-
Notifications
You must be signed in to change notification settings - Fork 300
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d59e8ee
commit 0cd3f46
Showing
7 changed files
with
130 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
110 changes: 110 additions & 0 deletions
110
RubberduckTests/Inspections/InconsistentParamArrayInspectionTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
using NUnit.Framework; | ||
using Rubberduck.CodeAnalysis.Inspections; | ||
using Rubberduck.CodeAnalysis.Inspections.Concrete; | ||
using Rubberduck.Parsing.VBA; | ||
using Rubberduck.VBEditor.SafeComWrappers; | ||
using RubberduckTests.Mocks; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
|
||
namespace RubberduckTests.Inspections | ||
{ | ||
[TestFixture] | ||
public class InconsistentParamArrayBaseInspectionTests : InspectionTestsBase | ||
{ | ||
[Test] | ||
[Category("Inspections")] | ||
public void InconsistentParamArrayBase_ReturnsResult() | ||
{ | ||
const string inputCode = | ||
@"Option Base 1 | ||
Public Sub DoSomething(ParamArray Values) | ||
End Sub"; | ||
Assert.AreEqual(1, InspectionResultsForStandardModule(inputCode).Count()); | ||
} | ||
|
||
[Test] | ||
[Category("Inspections")] | ||
public void WithoutOptionBase_NoResult() | ||
{ | ||
const string inputCode = | ||
@"Public Sub DoSomething(ParamArray Values) | ||
End Sub"; | ||
|
||
Assert.AreEqual(0, InspectionResultsForStandardModule(inputCode).Count()); | ||
|
||
} | ||
|
||
[Test] | ||
[Category("Inspections")] | ||
public void NonParamArrayParameter_NoResult() | ||
{ | ||
const string inputCode = | ||
@"Option Base 1 | ||
Public Sub DoSomething(ByRef Values() As Variant) | ||
End Sub"; | ||
Assert.AreEqual(0, InspectionResultsForStandardModule(inputCode).Count()); | ||
} | ||
|
||
protected override IInspection InspectionUnderTest(RubberduckParserState state) | ||
{ | ||
return new InconsistentParamArrayBaseInspection(state); | ||
} | ||
} | ||
|
||
[TestFixture] | ||
public class InconsistentArrayBaseInspectionTests : InspectionTestsBase | ||
{ | ||
[Test] | ||
[Category("Inspections")] | ||
public void InconsistentArrayBase_ReturnsResult() | ||
{ | ||
const string inputCode = | ||
@"Option Base 1 | ||
Public Sub DoSomething() | ||
Dim Values As Variant | ||
Values = VBA.Array(42) | ||
End Sub"; | ||
|
||
Assert.AreEqual(1, InspectionResults(inputCode).Count()); | ||
} | ||
|
||
[Test] | ||
[Category("Inspections")] | ||
public void WithoutOptionBase_NoResult() | ||
{ | ||
const string inputCode = | ||
@"Public Sub DoSomething() | ||
Dim Values As Variant | ||
Values = VBA.Array(42) | ||
End Sub"; | ||
|
||
Assert.AreEqual(0, InspectionResults(inputCode).Count()); | ||
|
||
} | ||
|
||
[Test] | ||
[Category("Inspections")] | ||
public void WithoutQualifier_NoResult() | ||
{ | ||
const string inputCode = | ||
@"Public Sub DoSomething() | ||
Dim Values As Variant | ||
Values = Array(42) | ||
End Sub"; | ||
|
||
Assert.AreEqual(0, InspectionResults(inputCode).Count()); | ||
|
||
} | ||
|
||
private IEnumerable<IInspectionResult> InspectionResults(string inputCode) | ||
{ | ||
return InspectionResultsForModules(("TestModule1", inputCode, ComponentType.StandardModule), ReferenceLibrary.VBA); | ||
} | ||
|
||
protected override IInspection InspectionUnderTest(RubberduckParserState state) | ||
{ | ||
return new InconsistentArrayBaseInspection(state); | ||
} | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
RubberduckTests/Inspections/MultilineParameterInspectionTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters