Esempio n. 1
0
        public void Reset_NoItemsToTraverse_NoCrash()
        {
            var cut = new IndexTraverser(1, 0);

            cut.Reset(5, 0);

            cut.Current.Should().Be(0, "Because it's the default value");
        }
Esempio n. 2
0
        public void MovePrevious_Decreased()
        {
            var cut = new IndexTraverser(1, 2);

            cut.MovePrevious();

            cut.Current.Should().Be(0, "Because it is decreased");
        }
Esempio n. 3
0
        public void MoveNext_Incremented()
        {
            var cut = new IndexTraverser(0, 2);

            cut.MoveNext();

            cut.Current.Should().Be(1, "Because it is increased");
        }
Esempio n. 4
0
        public void MovePrevious_TooLow_GoesAround()
        {
            var cut = new IndexTraverser(1, 2);

            cut.MovePrevious();
            cut.MovePrevious();

            cut.Current.Should().Be(1, "Because it is decreased");
        }
Esempio n. 5
0
        public void MoveNext_TooHigh_GoesAround()
        {
            var cut = new IndexTraverser(0, 2);

            cut.MoveNext();
            cut.MoveNext();

            cut.Current.Should().Be(0, "Because it reached max");
        }
Esempio n. 6
0
        public List <TextLine> GetOutput()
        {
            var output = new List <TextLine>
            {
                new TextLine(string.IsNullOrEmpty(m_textHandler.Text) ? ("Version: " + OpenRepoVersionService.GetCurrentVersion()) : m_textHandler.Text, ConsoleColor.White)
            };

            if (!string.IsNullOrEmpty(LogService.Message))
            {
                output.Add(new TextLine(string.Empty, ConsoleColor.Red));
                output.Add(new TextLine(LogService.Message, ConsoleColor.Red));
                output.Add(new TextLine(string.Empty, ConsoleColor.Red));
            }

            if (m_currentItems.Count > 0)
            {
                var tempTraverser = new IndexTraverser(m_traverser.Current, m_currentItems.Count);
                var visibleItems  = new List <SelectableItem>();
                var max           = m_currentItems.Count > 11 ? 11 : m_currentItems.Count;
                var selected      = max / 3;
                for (var i = 0; i < selected; i++)
                {
                    tempTraverser.MovePrevious();
                }
                for (var i = 0; i < max; i++)
                {
                    visibleItems.Add(m_currentItems[tempTraverser.Current]);
                    tempTraverser.MoveNext();
                }

                for (var i = 0; i < visibleItems.Count; i++)
                {
                    var item = visibleItems[i];
                    if (i == selected)
                    {
                        output.Add(new TextLine($"> {item.Title}", ConsoleColor.Gray));
                    }
                    else
                    {
                        output.Add(new TextLine($"  {item.Title}", ConsoleColor.Gray));
                    }
                }
            }


            return(output);
        }