public void InspectionName() { const string inspectionName = "MultipleDeclarationsInspection"; var inspection = new MultipleDeclarationsInspection(null); Assert.AreEqual(inspectionName, inspection.Name); }
public void MultipleDeclarations_QuickFixWorks_StaticVariables() { const string inputCode = @"Public Sub Foo() Static var1 As Integer, var2 As String End Sub"; const string expectedCode = @"Public Sub Foo() Static var1 As Integer Static var2 As String End Sub"; var vbe = MockVbeBuilder.BuildFromSingleStandardModule(inputCode, out var component); using (var state = MockParser.CreateAndParse(vbe.Object)) { var inspection = new MultipleDeclarationsInspection(state); var inspector = InspectionsHelper.GetInspector(inspection); var inspectionResults = inspector.FindIssuesAsync(state, CancellationToken.None).Result; new SplitMultipleDeclarationsQuickFix(state).Fix(inspectionResults.First()); Assert.AreEqual(expectedCode, state.GetRewriter(component).GetText()); } }
public void MultipleDeclarations_ReturnsResult_StaticVariables() { const string inputCode = @"Public Sub Foo() Static var1 As Integer, var2 As String End Sub"; //Arrange var builder = new MockVbeBuilder(); VBComponent component; var vbe = builder.BuildFromSingleStandardModule(inputCode, out component); var mockHost = new Mock <IHostApplication>(); mockHost.SetupAllProperties(); var parser = MockParser.Create(vbe.Object, new RubberduckParserState(new Mock <ISinks>().Object)); parser.Parse(new CancellationTokenSource()); if (parser.State.Status >= ParserState.Error) { Assert.Inconclusive("Parser Error"); } var inspection = new MultipleDeclarationsInspection(parser.State); var inspectionResults = inspection.GetInspectionResults(); Assert.AreEqual(1, inspectionResults.Count()); }
public void MultipleDeclarations_ReturnsResult_StaticVariables() { const string inputCode = @"Public Sub Foo() Static var1 As Integer, var2 As String End Sub"; var vbe = MockVbeBuilder.BuildFromSingleStandardModule(inputCode, out _); var state = MockParser.CreateAndParse(vbe.Object); var inspection = new MultipleDeclarationsInspection(state); var inspector = InspectionsHelper.GetInspector(inspection); var inspectionResults = inspector.FindIssuesAsync(state, CancellationToken.None).Result; Assert.AreEqual(1, inspectionResults.Count()); }
public void MultipleDeclarations_Ignore_DoesNotReturnResult_Variables() { const string inputCode = @"Public Sub Foo() '@Ignore MultipleDeclarations Dim var1 As Integer, var2 As String End Sub"; var vbe = MockVbeBuilder.BuildFromSingleStandardModule(inputCode, out _); var state = MockParser.CreateAndParse(vbe.Object); var inspection = new MultipleDeclarationsInspection(state); var inspector = InspectionsHelper.GetInspector(inspection); var inspectionResults = inspector.FindIssuesAsync(state, CancellationToken.None).Result; Assert.IsFalse(inspectionResults.Any()); }
public void MultipleDeclarations_ReturnsResult_StaticVariables() { const string inputCode = @"Public Sub Foo() Static var1 As Integer, var2 As String End Sub"; IVBComponent component; var vbe = MockVbeBuilder.BuildFromSingleStandardModule(inputCode, out component); var state = MockParser.CreateAndParse(vbe.Object); var inspection = new MultipleDeclarationsInspection(state); var inspectionResults = inspection.GetInspectionResults(); Assert.AreEqual(1, inspectionResults.Count()); }
public void MultipleDeclarations_Ignore_DoesNotReturnResult_Variables() { const string inputCode = @"Public Sub Foo() '@Ignore MultipleDeclarations Dim var1 As Integer, var2 As String End Sub"; IVBComponent component; var vbe = MockVbeBuilder.BuildFromSingleStandardModule(inputCode, out component); var state = MockParser.CreateAndParse(vbe.Object); var inspection = new MultipleDeclarationsInspection(state); var inspectionResults = inspection.GetInspectionResults(); Assert.IsFalse(inspectionResults.Any()); }
public void MultipleDeclarations_QuickFixWorks_Constants() { const string inputCode = @"Public Sub Foo() Const var1 As Integer = 9, var2 As String = ""test"" End Sub"; const string expectedCode = @"Public Sub Foo() Const var1 As Integer = 9 Const var2 As String = ""test"" End Sub"; //Arrange var builder = new MockVbeBuilder(); VBComponent component; var vbe = builder.BuildFromSingleStandardModule(inputCode, out component); var project = vbe.Object.VBProjects.Item(0); var module = project.VBComponents.Item(0).CodeModule; var mockHost = new Mock <IHostApplication>(); mockHost.SetupAllProperties(); var parser = MockParser.Create(vbe.Object, new RubberduckParserState(new Mock <ISinks>().Object)); parser.Parse(new CancellationTokenSource()); if (parser.State.Status >= ParserState.Error) { Assert.Inconclusive("Parser Error"); } var inspection = new MultipleDeclarationsInspection(parser.State); var inspectionResults = inspection.GetInspectionResults(); inspectionResults.First().QuickFixes.First().Fix(); Assert.AreEqual(expectedCode, module.Lines()); }
public void MultipleDeclarations_IgnoreQuickFixWorks() { const string inputCode = @"Public Sub Foo() Dim var1 As Integer, var2 As String End Sub"; const string expectedCode = @"Public Sub Foo() '@Ignore MultipleDeclarations Dim var1 As Integer, var2 As String End Sub"; IVBComponent component; var vbe = MockVbeBuilder.BuildFromSingleStandardModule(inputCode, out component); var state = MockParser.CreateAndParse(vbe.Object); var inspection = new MultipleDeclarationsInspection(state); var inspectionResults = inspection.GetInspectionResults(); inspectionResults.First().QuickFixes.Single(s => s is IgnoreOnceQuickFix).Fix(); Assert.AreEqual(expectedCode, component.CodeModule.Content()); }
public void InspectionType() { var inspection = new MultipleDeclarationsInspection(null); Assert.AreEqual(CodeInspectionType.MaintainabilityAndReadabilityIssues, inspection.InspectionType); }
public void InspectionName() { var inspection = new MultipleDeclarationsInspection(null); Assert.AreEqual(nameof(MultipleDeclarationsInspection), inspection.Name); }