public void CouldFillThenAddValues() { var sm = new SortedMap <int, double> { { 1, 0 }, { 3, 2 }, { 5, 4 } }; var fc = new Fill <int, double, Cursor <int, double> >(sm.GetWrapper(), 41).Initialize(); var c = (fc.Source + 1).GetEnumerator(); Assert.True(c.MoveNext()); Assert.AreEqual(1, c.CurrentValue); Assert.True(c.MoveNext()); Assert.AreEqual(3, c.CurrentValue); Assert.True(c.MoveNext()); Assert.AreEqual(5, c.CurrentValue); Assert.False(c.MoveNext()); Assert.AreEqual(5, c.CurrentValue); Assert.True(c.MoveLast()); Assert.AreEqual(5, c.CurrentValue); Assert.False(c.MoveAt(4, Lookup.EQ)); Assert.AreEqual(5, c.CurrentValue); Assert.True(c.MoveAt(4, Lookup.LE)); Assert.AreEqual(3, c.CurrentValue); Assert.True(c.TryGetValue(2, out var x)); Assert.AreEqual(3, c.CurrentValue); Assert.AreEqual(42, x); var clone = c.Clone(); Assert.True(c.MoveAt(4, Lookup.GT)); Assert.AreEqual(5, c.CurrentValue); Assert.AreEqual(3, clone.CurrentValue); Assert.True(clone.TryGetValue(0, out var y)); Assert.AreEqual(42, y); c.Dispose(); }
public void CouldFillValues() { var sm = new SortedMap <int, double> { { 1, 1 }, { 3, 3 }, { 5, 5 } }; var c = new Fill <int, double, Cursor <int, double> >(sm.GetWrapper(), 42).Initialize(); Assert.True(c.MoveNext()); Assert.AreEqual(1, c.CurrentValue); Assert.True(c.MoveNext()); Assert.AreEqual(3, c.CurrentValue); Assert.True(c.MoveNext()); Assert.AreEqual(5, c.CurrentValue); Assert.False(c.MoveNext()); Assert.AreEqual(5, c.CurrentValue); Assert.True(c.MoveLast()); Assert.AreEqual(5, c.CurrentValue); Assert.False(c.MoveAt(4, Lookup.EQ)); Assert.AreEqual(5, c.CurrentValue); Assert.True(c.MoveAt(4, Lookup.LE)); Assert.AreEqual(3, c.CurrentValue); Assert.True(c.TryGetValue(2, out var x)); Assert.AreEqual(3, c.CurrentValue); Assert.AreEqual(42, x); var clone = c.Clone(); Assert.True(c.MoveAt(4, Lookup.GT)); Assert.AreEqual(5, c.CurrentValue); Assert.AreEqual(3, clone.CurrentValue); Assert.True(clone.TryGetValue(0, out var y)); Assert.AreEqual(42, y); }