public void HungarianNotation_ReturnsResult_ForClass() { const string inputCode = @"Sub Test() Debug.Print ""Ez egy objektum"" End Sub"; var builder = new MockVbeBuilder(); var project = builder.ProjectBuilder("VBAProject", ProjectProtection.Unprotected) .AddComponent("clsMagyar", 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 HungarianNotationInspection(null, parser.State, UseMeaningfulNameInspectionTests.GetInspectionSettings().Object); var inspectionResults = inspection.GetInspectionResults(); Assert.AreEqual(1, inspectionResults.Count()); }
public void HungarianNotation_DoesNotReturnsResult_ThreeLetterVariable() { const string inputCode = @"Sub InExcelSomewhere() Dim col As Long 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(); 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 HungarianNotationInspection(null, parser.State, UseMeaningfulNameInspectionTests.GetInspectionSettings().Object); var inspectionResults = inspection.GetInspectionResults(); Assert.IsFalse(inspectionResults.Any()); }
public void HungarianNotation_ReturnsResult_VariableWithOneLetterPrefix() { const string inputCode = @"Sub Hungarian() Dim oFoo As Object 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(); var parser = MockParser.Create(vbe.Object); parser.Parse(new CancellationTokenSource()); if (parser.State.Status >= ParserState.Error) { Assert.Inconclusive("Parser Error"); } var inspection = new HungarianNotationInspection(parser.State, UseMeaningfulNameInspectionTests.GetInspectionSettings().Object); var inspectionResults = inspection.GetInspectionResults(); Assert.AreEqual(1, inspectionResults.Count()); }
public void HungarianNotation_DoesNotReturnsResult_UpperCaseFirstLetter() { const string inputCode = @"Option Explicit"; var builder = new MockVbeBuilder(); var project = builder.ProjectBuilder("VBAProject", ProjectProtection.Unprotected) .AddComponent("Stripper", ComponentType.ClassModule, inputCode) .Build(); var vbe = builder.AddProject(project).Build(); using (var state = MockParser.CreateAndParse(vbe.Object)) { var inspection = new HungarianNotationInspection(state, UseMeaningfulNameInspectionTests.GetInspectionSettings().Object); var inspectionResults = inspection.GetInspectionResults(); Assert.IsFalse(inspectionResults.Any()); } }
public void HungarianNotation_DoesNotReturnsResult_ThreeLetterVariable() { const string inputCode = @"Sub InExcelSomewhere() Dim col As Long 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 HungarianNotationInspection(state, UseMeaningfulNameInspectionTests.GetInspectionSettings().Object); var inspectionResults = inspection.GetInspectionResults(); Assert.IsFalse(inspectionResults.Any()); } }
public void HungarianNotation_ReturnsResult_ForClass() { const string inputCode = @"Sub Test() Debug.Print ""Ez egy objektum"" End Sub"; var builder = new MockVbeBuilder(); var project = builder.ProjectBuilder("VBAProject", ProjectProtection.Unprotected) .AddComponent("clsMagyar", ComponentType.ClassModule, inputCode) .Build(); var vbe = builder.AddProject(project).Build(); using (var state = MockParser.CreateAndParse(vbe.Object)) { var inspection = new HungarianNotationInspection(state, UseMeaningfulNameInspectionTests.GetInspectionSettings().Object); var inspectionResults = inspection.GetInspectionResults(); Assert.AreEqual(1, inspectionResults.Count()); } }
public void HungarianNotation_ReturnsResult_VariableWithOneLetterPrefix() { const string inputCode = @"Sub Hungarian() Dim oFoo As Object 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 HungarianNotationInspection(state, UseMeaningfulNameInspectionTests.GetInspectionSettings().Object); var inspectionResults = inspection.GetInspectionResults(); Assert.AreEqual(1, inspectionResults.Count()); } }
public void HungarianNotation_DoesNotReturnsResult_AllLowerCase() { const string inputCode = @"Sub NoHungarianHere() Dim strong 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 HungarianNotationInspection(state, UseMeaningfulNameInspectionTests.GetInspectionSettings().Object); var inspectionResults = inspection.GetInspectionResults(CancellationToken.None); Assert.IsFalse(inspectionResults.Any()); } }
public void HungarianNotation_DoesNotReturnResult_LibraryFunction() { const string inputCode = @" Private Declare Sub chkVoid Lib ""somelib.dll"" Alias ""chkVoidA"" (number As Long) "; 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 HungarianNotationInspection(state, UseMeaningfulNameInspectionTests.GetInspectionSettings().Object); var inspectionResults = inspection.GetInspectionResults(CancellationToken.None); Assert.AreEqual(0, inspectionResults.Count()); } }
public void HungarianNotation_DoesNotReturnsResult_UpperCaseFirstLetter() { const string inputCode = @"Option Explicit"; var builder = new MockVbeBuilder(); var project = builder.ProjectBuilder("VBAProject", ProjectProtection.Unprotected) .AddComponent("Stripper", ComponentType.ClassModule, inputCode) .Build(); var vbe = builder.AddProject(project).Build(); var parser = MockParser.Create(vbe.Object); parser.Parse(new CancellationTokenSource()); if (parser.State.Status >= ParserState.Error) { Assert.Inconclusive("Parser Error"); } var inspection = new HungarianNotationInspection(parser.State, UseMeaningfulNameInspectionTests.GetInspectionSettings().Object); var inspectionResults = inspection.GetInspectionResults(); Assert.IsFalse(inspectionResults.Any()); }