public void ctor1_StartWithinRange_SliceUntilEnd(int start, int expectedLength) { // Act/Assert using (var memory = new SlicedMemoryOwner <byte>(MemoryPool <byte> .Shared.Rent(32), start)) { Assert.Equal(expectedLength, memory.Memory.Length); } }
public void ctor2_StartWithinRange_SliceLength(int start, int length) { // Act/Assert using (var memory = new SlicedMemoryOwner <byte>(MemoryPool <byte> .Shared.Rent(32), start, length)) { Assert.Equal(length, memory.Memory.Length); } }
public void ctor1_StartWithinRange_SliceStart(int start) { // Arrange var bytes = Enumerable.Range(0, 32).Select(p => (byte)p).ToArray(); var fakeMemoryOwner = new FakeMemoryOwner <byte>(bytes); // Act var slicedOwner = new SlicedMemoryOwner <byte>(fakeMemoryOwner, start); // Assert Assert.Equal(bytes[start], slicedOwner.Memory.Span[0]); }
public void Dispose_DisposesInnerMemory() { // Arrange var bytes = Enumerable.Range(0, 32).Select(p => (byte)p).ToArray(); var fakeMemoryOwner = new FakeMemoryOwner <byte>(bytes); var slicedOwner = new SlicedMemoryOwner <byte>(fakeMemoryOwner, 0); // Act slicedOwner.Dispose(); // Assert Assert.True(fakeMemoryOwner.Disposed); }