public void RemoveRemovesComment() { var input = @"Dim d As Variant ' bug should be Integer"; var expected = @"Dim d As Variant "; var builder = new MockVbeBuilder(); var project = builder.ProjectBuilder("TestProject1", vbext_ProjectProtection.vbext_pp_none) .AddComponent("Module1", vbext_ComponentType.vbext_ct_StdModule, input) .Build(); 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)); var vm = new ToDoExplorerViewModel(parser.State, GetConfigService(), GetOperatingSystemMock().Object); parser.Parse(new CancellationTokenSource()); if (parser.State.Status >= ParserState.Error) { Assert.Inconclusive("Parser Error"); } vm.SelectedItem = vm.Items.Single(); vm.RemoveCommand.Execute(null); Assert.AreEqual(expected, project.Object.VBComponents.Item(0).CodeModule.Lines()); Assert.IsFalse(vm.Items.Any()); }
public void RemoveRemovesComment() { var input = @"Dim d As Variant ' bug should be Integer"; var expected = @"Dim d As Variant "; var builder = new MockVbeBuilder(); var project = builder.ProjectBuilder("TestProject1", ProjectProtection.Unprotected) .AddComponent("Module1", ComponentType.StandardModule, input) .Build(); var vbe = builder.AddProject(project).Build(); var parser = MockParser.Create(vbe.Object); var vm = new ToDoExplorerViewModel(parser.State, GetConfigService(), GetOperatingSystemMock().Object); parser.Parse(new CancellationTokenSource()); if (parser.State.Status >= ParserState.Error) { Assert.Inconclusive("Parser Error"); } vm.SelectedItem = vm.Items.Single(); vm.RemoveCommand.Execute(null); var module = project.Object.VBComponents[0].CodeModule; Assert.AreEqual(expected, module.Content()); Assert.IsFalse(vm.Items.Any()); }
public void PicksUpComments_StrangeCasing() { var content = @"' tODO this is a todo comment ' NOTE this is a note comment ' bug this is a bug comment ' bUg this is a bug comment "; var builder = new MockVbeBuilder(); var project = builder.ProjectBuilder("TestProject1", vbext_ProjectProtection.vbext_pp_none) .AddComponent("Module1", vbext_ComponentType.vbext_ct_StdModule, content); var vbe = builder.AddProject(project.Build()).Build(); var mockHost = new Mock <IHostApplication>(); mockHost.SetupAllProperties(); var parser = MockParser.Create(vbe.Object, new RubberduckParserState(new Mock <ISinks>().Object)); var vm = new ToDoExplorerViewModel(parser.State, GetConfigService(), GetOperatingSystemMock().Object); parser.Parse(new CancellationTokenSource()); if (parser.State.Status >= ParserState.Error) { Assert.Inconclusive("Parser Error"); } var comments = vm.Items.Select(s => s.Type); Assert.IsTrue(comments.SequenceEqual(new[] { "TODO ", "NOTE ", "BUG ", "BUG " })); }
public void PicksUpComments() { var content = @"' Todo this is a todo comment ' Note this is a note comment ' Bug this is a bug comment "; var builder = new MockVbeBuilder(); var project = builder.ProjectBuilder("TestProject1", ProjectProtection.Unprotected) .AddComponent("Module1", ComponentType.StandardModule, content); var vbe = builder.AddProject(project.Build()).Build(); var parser = MockParser.Create(vbe.Object); var vm = new ToDoExplorerViewModel(parser.State, GetConfigService(), GetOperatingSystemMock().Object); parser.Parse(new CancellationTokenSource()); if (parser.State.Status >= ParserState.Error) { Assert.Inconclusive("Parser Error"); } var comments = vm.Items.Select(s => s.Type); Assert.IsTrue(comments.SequenceEqual(new[] { "TODO ", "NOTE ", "BUG " })); }
public void PicksUpComments_SpecialCharacters() { const string inputCode = @"' To-do - this is a todo comment ' N@TE this is a note comment ' bug this should work with a trailing space ' bug: this should not be seen due to the colon "; var builder = new MockVbeBuilder(); var project = builder.ProjectBuilder("TestProject1", ProjectProtection.Unprotected) .AddComponent("Module1", ComponentType.StandardModule, inputCode) .Build(); var vbe = builder.AddProject(project).Build(); var parser = MockParser.Create(vbe.Object); using (var state = parser.State) { var cs = GetConfigService(new[] { "TO-DO", "N@TE", "BUG " }); var vm = new ToDoExplorerViewModel(state, cs, null); parser.Parse(new CancellationTokenSource()); if (state.Status >= ParserState.Error) { Assert.Inconclusive("Parser Error"); } var comments = vm.Items.Select(s => s.Type); Assert.IsTrue(comments.SequenceEqual(new[] { "TO-DO", "N@TE", "BUG " })); } }
public void PicksUpComments_StrangeCasing() { const string inputCode = @"' tODO this is a todo comment ' NOTE this is a note comment ' bug this is a bug comment ' bUg this is a bug comment "; var builder = new MockVbeBuilder(); var project = builder.ProjectBuilder("TestProject1", ProjectProtection.Unprotected) .AddComponent("Module1", ComponentType.StandardModule, inputCode) .Build(); var vbe = builder.AddProject(project).Build(); var parser = MockParser.Create(vbe.Object); using (var state = parser.State) { var cs = GetConfigService(new[] { "TODO", "NOTE", "BUG" }); var vm = new ToDoExplorerViewModel(state, cs, null); parser.Parse(new CancellationTokenSource()); if (state.Status >= ParserState.Error) { Assert.Inconclusive("Parser Error"); } var comments = vm.Items.Select(s => s.Type); Assert.IsTrue(comments.SequenceEqual(new[] { "TODO", "NOTE", "BUG", "BUG" })); } }
public void AvoidsFalsePositiveComments() { const string inputCode = @"' Todon't should not get picked up ' Debug.print() would trigger false positive if word boundaries not used ' Denoted "; var builder = new MockVbeBuilder(); var project = builder.ProjectBuilder("TestProject1", ProjectProtection.Unprotected) .AddComponent("Module1", ComponentType.StandardModule, inputCode) .Build(); var vbe = builder.AddProject(project).Build(); var parser = MockParser.Create(vbe.Object); using (var state = parser.State) { var cs = GetConfigService(new[] { "TODO", "NOTE", "BUG" }); var vm = new ToDoExplorerViewModel(state, cs, null); parser.Parse(new CancellationTokenSource()); if (state.Status >= ParserState.Error) { Assert.Inconclusive("Parser Error"); } var comments = vm.Items.Select(s => s.Type); Assert.IsTrue(comments.Count() == 0); } }
public void RemoveRemovesComment() { const string inputCode = @"Dim d As Variant ' bug should be Integer"; const string expected = @"Dim d As Variant "; var selectionService = new Mock <ISelectionService>().Object; var builder = new MockVbeBuilder(); var project = builder.ProjectBuilder("TestProject1", ProjectProtection.Unprotected) .AddComponent("Module1", ComponentType.StandardModule, inputCode) .Build(); var vbe = builder.AddProject(project).Build(); var parser = MockParser.Create(vbe.Object); using (var state = parser.State) { var cs = GetConfigService(new[] { "TODO", "NOTE", "BUG" }); var vm = new ToDoExplorerViewModel(state, cs, null, selectionService, GetMockedUiDispatcher()) { RefreshCommand = new ReparseCommand(vbe.Object, new Mock <IConfigProvider <GeneralSettings> >().Object, state, null, null, null) }; parser.Parse(new CancellationTokenSource()); if (state.Status >= ParserState.Error) { Assert.Inconclusive("Parser Error"); } vm.SelectedItem = vm.Items.OfType <ToDoItem>().Single(); vm.RemoveCommand.Execute(null); var module = project.Object.VBComponents[0].CodeModule; Assert.AreEqual(expected, module.Content()); } }