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); }
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); }
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); }
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(); }
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); }
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); }
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); }
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); }
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(); }
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); }
public SequenceCheckpoint(ListSequence <T> s, int index) { _s = s; _index = index; }