Exemplo n.º 1
0
        public void Peek_Test()
        {
            var target = new ListSequence <int>(new[] { 1, 2, 3 }, 0);

            target.Peek().Should().Be(1);
            target.Peek().Should().Be(1);
            target.Peek().Should().Be(1);
        }
Exemplo n.º 2
0
        public void GetNext_Test()
        {
            var target = new ListSequence <int>(new[] { 1, 2, 3 }, 0);

            target.GetNext().Should().Be(1);
            target.GetNext().Should().Be(2);
            target.GetNext().Should().Be(3);
            target.GetNext().Should().Be(0);
        }
Exemplo n.º 3
0
        private ListSequence CreateListSequence(JToken item)
        {
            object source = Create(item["source"]);

            ListSequence result = source is DataReference ? new ListSequence((DataReference)source) : new ListSequence((IList <object>)source);

            result.DebugInfo = GetDebugInfo(item);

            return(result);
        }
Exemplo n.º 4
0
        public void IsAtEnd_Test()
        {
            var target = new ListSequence <int>(new[] { 1, 2, 3 }, 0);

            target.IsAtEnd.Should().BeFalse();
            target.GetNext().Should().Be(1);
            target.IsAtEnd.Should().BeFalse();
            target.GetNext().Should().Be(2);
            target.IsAtEnd.Should().BeFalse();
            target.GetNext().Should().Be(3);
            target.IsAtEnd.Should().BeTrue();
        }
Exemplo n.º 5
0
        public void Where_Test()
        {
            var source = new ListSequence <int>(
                new[] { 1, 2, 3, 4, 5, 6 },
                0
                );
            var target = source.Where(x => x % 2 == 0);

            target.GetNext().Should().Be(2);
            target.GetNext().Should().Be(4);
            target.GetNext().Should().Be(6);
            target.GetNext().Should().Be(0);
        }
Exemplo n.º 6
0
        public void Select_Test()
        {
            var source = new ListSequence <int>(
                new[] { 1, 2, 3 },
                0
                );
            var target = source.Select(x => x * 2);

            target.GetNext().Should().Be(2);
            target.GetNext().Should().Be(4);
            target.GetNext().Should().Be(6);
            target.GetNext().Should().Be(0);
        }
Exemplo n.º 7
0
        public void CurrentLocation_Test()
        {
            var target = new ListSequence <int>(new[] { 1, 2, 3 }, 0);

            target.CurrentLocation.Column.Should().Be(0);
            target.GetNext().Should().Be(1);
            target.CurrentLocation.Column.Should().Be(1);
            target.GetNext().Should().Be(2);
            target.CurrentLocation.Column.Should().Be(2);
            target.GetNext().Should().Be(3);
            target.CurrentLocation.Column.Should().Be(3);
            target.GetNext().Should().Be(0);
            target.CurrentLocation.Column.Should().Be(3);
        }
Exemplo n.º 8
0
        public void Checkpoint_Test()
        {
            var target = new ListSequence <int>(new[] { 1, 2, 3 }, 0);

            target.GetNext().Should().Be(1);
            target.GetNext().Should().Be(2);
            var cp = target.Checkpoint();

            target.GetNext().Should().Be(3);
            target.GetNext().Should().Be(0);
            cp.Rewind();
            target.GetNext().Should().Be(3);
            target.GetNext().Should().Be(0);
        }
Exemplo n.º 9
0
        public void IsAtEnd_Test()
        {
            var source = new ListSequence <int>(
                new[] { 1, 2, 3 },
                0
                );
            var target = source.Select(x => x * 2);

            target.IsAtEnd.Should().BeFalse();
            target.GetNext().Should().Be(2);
            target.IsAtEnd.Should().BeFalse();
            target.GetNext().Should().Be(4);
            target.IsAtEnd.Should().BeFalse();
            target.GetNext().Should().Be(6);
            target.IsAtEnd.Should().BeTrue();
        }
Exemplo n.º 10
0
        public void Location_Rewind()
        {
            var target = new ListSequence <int>(new[] { 1, 2, 3 }, 0);

            target.CurrentLocation.Line.Should().Be(1);
            target.CurrentLocation.Column.Should().Be(0);
            target.GetNext();
            target.CurrentLocation.Line.Should().Be(1);
            target.CurrentLocation.Column.Should().Be(1);
            var checkpoint = target.Checkpoint();

            target.GetNext();
            target.GetNext();
            target.CurrentLocation.Line.Should().Be(1);
            target.CurrentLocation.Column.Should().Be(3);

            checkpoint.Rewind();
            target.CurrentLocation.Line.Should().Be(1);
            target.CurrentLocation.Column.Should().Be(1);
        }
Exemplo n.º 11
0
 public SequenceCheckpoint(ListSequence <T> s, int index)
 {
     _s     = s;
     _index = index;
 }