public void HungarianNotation_DoesNotReturnResult_WhenIgnored() { const string inputCode = @"Sub MagyarRendbenVan() '@Ignore HungarianNotation Dim strFoo As Variant End Sub"; var builder = new MockVbeBuilder(); var project = builder.ProjectBuilder("VBAProject", ProjectProtection.Unprotected) .AddComponent("MyClass", ComponentType.ClassModule, inputCode) .Build(); var vbe = builder.AddProject(project).Build(); using (var state = MockParser.CreateAndParse(vbe.Object)) { var inspection = new UseMeaningfulNameInspection(state, UseMeaningfulNameInspectionTests.GetInspectionSettings().Object); var inspectionResults = inspection.GetInspectionResults(); Assert.IsFalse(inspectionResults.Any()); } }
private void AssertVbaFragmentYieldsExpectedInspectionResultCount(string inputCode, int expectedCount) { var builder = new MockVbeBuilder(); var project = builder.ProjectBuilder("VBAProject", ProjectProtection.Unprotected) .AddComponent("MyClass", ComponentType.ClassModule, inputCode) .Build(); var vbe = builder.AddProject(project).Build(); var parser = MockParser.Create(vbe.Object, new RubberduckParserState(vbe.Object)); parser.Parse(new CancellationTokenSource()); if (parser.State.Status >= ParserState.Error) { Assert.Inconclusive("Parser Error"); } var inspection = new UseMeaningfulNameInspection(null, parser.State, GetInspectionSettings().Object); var inspectionResults = inspection.GetInspectionResults(); Assert.AreEqual(expectedCount, inspectionResults.Count()); }
public void UseMeaningfulName_NoResultForLineNumberLabels() { const string inputCode = @" Sub DoSomething() 10 Debug.Print 42 End Sub "; var vbe = MockVbeBuilder.BuildFromSingleStandardModule(inputCode, out _); var parser = MockParser.Create(vbe.Object); parser.Parse(new CancellationTokenSource()); if (parser.State.Status >= ParserState.Error) { Assert.Inconclusive("Parser Error"); } var inspection = new UseMeaningfulNameInspection(parser.State, GetInspectionSettings().Object); var inspectionResults = inspection.GetInspectionResults().Where(i => i.Target.DeclarationType == DeclarationType.LineLabel); Assert.IsFalse(inspectionResults.Any()); }
public void UseMeaningfulName_IgnoreQuickFixWorks() { const string inputCode = @"Sub Ffffff() End Sub"; const string expectedCode = @"'@Ignore UseMeaningfulName Sub Ffffff() End Sub"; //Arrange var builder = new MockVbeBuilder(); var project = builder.ProjectBuilder("VBAProject", vbext_ProjectProtection.vbext_pp_none) .AddComponent("MyClass", vbext_ComponentType.vbext_ct_ClassModule, inputCode) .Build(); var module = project.Object.VBComponents.Item(0).CodeModule; var vbe = builder.AddProject(project).Build(); 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 UseMeaningfulNameInspection(null, parser.State, GetInspectionSettings().Object); var inspectionResults = inspection.GetInspectionResults(); inspectionResults.First().QuickFixes.Single(s => s is IgnoreOnceQuickFix).Fix(); Assert.AreEqual(expectedCode, module.Lines()); }