示例#1
0
 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);
     }
 }
示例#2
0
 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);
     }
 }
示例#3
0
        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]);
        }
示例#4
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);
        }