public void TemporaryBuffer_Insert() { using var buffer = new TemporaryBuffer <int>(1) { 100, 200, 300 }; buffer.Insert(2, 700); Assert.True(buffer.EndsWith(new [] { 700, 300 })); }
public void TemporaryBuffer_Add() { using var buffer = new TemporaryBuffer <int>(1); Assert.Equal(0, buffer.Count); buffer.Add(100); Assert.Equal(1, buffer.Count); Assert.True(buffer.EndsWith(100)); Assert.False(buffer.EndsWith(new [] { 100, 200 })); Assert.False(buffer.EndsWith(new [] { 100, 200, 300 })); Assert.Equal(100, buffer.Last()); buffer.Add(200); Assert.Equal(2, buffer.Count); Assert.False(buffer.EndsWith(100)); Assert.True(buffer.EndsWith(new [] { 100, 200 })); Assert.False(buffer.EndsWith(new [] { 100, 200, 300 })); Assert.Equal(200, buffer.Last()); buffer.DiscardLast(); Assert.Equal(1, buffer.Count); Assert.True(buffer.EndsWith(100)); Assert.False(buffer.EndsWith(new [] { 100, 200 })); Assert.False(buffer.EndsWith(new [] { 100, 200, 300 })); Assert.Equal(100, buffer.Last()); buffer.Add(200); buffer.Add(300); Assert.Equal(3, buffer.Count); Assert.False(buffer.EndsWith(100)); Assert.True(buffer.EndsWith(new [] { 200, 300 })); Assert.True(buffer.EndsWith(new [] { 100, 200, 300 })); Assert.Equal(300, buffer.Last()); }