public void ObsoleteCallStatement_DoesNotReturnResult() { const string inputCode = @"Sub Foo() Foo 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()); parser.Parse(); if (parser.State.Status == ParserState.Error) { Assert.Inconclusive("Parser Error"); } var inspection = new ObsoleteCallStatementInspection(parser.State); var inspectionResults = inspection.GetInspectionResults(); Assert.AreEqual(0, inspectionResults.Count()); }
public void ObsoleteCallStatement_QuickFixWorks_RemoveCallStatement() { const string inputCode = @"Sub Foo() Call Goo(1, ""test"") End Sub Sub Goo(arg1 As Integer, arg1 As String) Call Foo End Sub"; const string expectedCode = @"Sub Foo() Goo 1, ""test"" End Sub Sub Goo(arg1 As Integer, arg1 As String) Foo 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()); parser.Parse(); if (parser.State.Status == ParserState.Error) { Assert.Inconclusive("Parser Error"); } var inspection = new ObsoleteCallStatementInspection(parser.State); var inspectionResults = inspection.GetInspectionResults(); foreach (var inspectionResult in inspectionResults) { inspectionResult.QuickFixes.First().Fix(); } var actual = module.Lines(); Assert.AreEqual(expectedCode, actual); }