public void ObsoleteCallStatement_FieldWithDoubleTypeHintReturnsResult() { const string inputCode = @"Public Foo#"; //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 ObsoleteTypeHintInspection(parser.State); var inspectionResults = inspection.GetInspectionResults(); Assert.AreEqual(1, inspectionResults.Count()); }
public void InspectionName() { const string inspectionName = "ObsoleteTypeHintInspection"; var inspection = new ObsoleteTypeHintInspection(null); Assert.AreEqual(inspectionName, inspection.Name); }
public void InspectionType() { var inspection = new ObsoleteTypeHintInspection(null); Assert.AreEqual(CodeInspectionType.LanguageOpportunities, inspection.InspectionType); }
public void ObsoleteCallStatement_QuickFixWorks_FunctionReferencesAreUpdated_ParentIsNotChanged_StringTypeHint() { const string inputCode = @"Public Function Foo(ByVal bar as Boolean) As String Foo$ = ""test"" End Function Public Sub Buzz() Dim bat As String bat$ = Foo$() End Sub"; const string expectedCode = @"Public Function Foo(ByVal bar as Boolean) As String Foo = ""test"" End Function Public Sub Buzz() Dim bat As String bat = 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 ObsoleteTypeHintInspection(parser.State); var inspectionResults = inspection.GetInspectionResults(); foreach (var inspectionResult in inspectionResults) { inspectionResult.QuickFixes.First().Fix(); } Assert.AreEqual(expectedCode, module.Lines()); }
public void ObsoleteCallStatement_QuickFixWorks_PropertyGet_StringTypeHint() { const string inputCode = @"Public Property Get Foo$(ByVal fizz As Integer) Foo = ""test"" End Property"; const string expectedCode = @"Public Property Get Foo(ByVal fizz As Integer) As String Foo = ""test"" End Property"; //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 ObsoleteTypeHintInspection(parser.State); var inspectionResults = inspection.GetInspectionResults(); foreach (var inspectionResult in inspectionResults) { inspectionResult.QuickFixes.First().Fix(); } Assert.AreEqual(expectedCode, module.Lines()); }