public void SelectPreviousNextCommandsTest() { var codeFlow = SarifUtilities.CreateSingleThreadedCodeFlow(new[] { new ThreadFlowLocation { NestingLevel = 0 }, new ThreadFlowLocation { NestingLevel = 1 }, new ThreadFlowLocation { NestingLevel = 1 }, new ThreadFlowLocation { NestingLevel = 1 }, new ThreadFlowLocation { NestingLevel = 0 }, new ThreadFlowLocation { NestingLevel = 0 } }); var mockToolWindow = new Mock <IToolWindow>(); mockToolWindow.Setup(s => s.UpdateSelectionList(It.IsAny <object[]>())); CallTree callTree = new CallTree(CodeFlowToTreeConverter.Convert(codeFlow, run: null), mockToolWindow.Object); callTree.FindPrevious().Should().Be(null); callTree.FindNext().Should().Be(null); callTree.SelectedItem = callTree.TopLevelNodes[0]; callTree.FindPrevious().Should().Be(callTree.TopLevelNodes[0]); callTree.FindNext().Should().Be(callTree.TopLevelNodes[0].Children[0]); callTree.SelectedItem = callTree.TopLevelNodes[0].Children[0]; callTree.FindPrevious().Should().Be(callTree.TopLevelNodes[0]); callTree.FindNext().Should().Be(callTree.TopLevelNodes[0].Children[1]); callTree.SelectedItem = callTree.TopLevelNodes[0].Children[2]; callTree.FindPrevious().Should().Be(callTree.TopLevelNodes[0].Children[1]); callTree.FindNext().Should().Be(callTree.TopLevelNodes[1]); callTree.SelectedItem = callTree.TopLevelNodes[1]; callTree.FindPrevious().Should().Be(callTree.TopLevelNodes[0].Children[2]); callTree.FindNext().Should().Be(callTree.TopLevelNodes[2]); callTree.SelectedItem = callTree.TopLevelNodes[2]; callTree.FindPrevious().Should().Be(callTree.TopLevelNodes[1]); callTree.FindNext().Should().Be(callTree.TopLevelNodes[2]); }
public void SelectPreviousNextCommandsCallNoChildrenTest() { var codeFlow = new CodeFlow { Locations = new List <AnnotatedCodeLocation> { new AnnotatedCodeLocation { Kind = AnnotatedCodeLocationKind.Call } } }; var mockToolWindow = new Mock <IToolWindow>(); mockToolWindow.Setup(s => s.UpdateSelectionList(It.IsAny <object[]>())); CallTree callTree = new CallTree(CodeFlowToTreeConverter.Convert(codeFlow), mockToolWindow.Object); callTree.SelectedItem = callTree.TopLevelNodes[0]; callTree.FindPrevious().Should().Be(callTree.TopLevelNodes[0]); callTree.FindNext().Should().Be(callTree.TopLevelNodes[0]); }