Exemplo n.º 1
0
 public void ReadOnlySpan_CanEncodeUInt16()
 {
     UInt16 valueToWrite = 1790;
     UInt16 valueRead = 0;
     int    numBytesExpected = 0, numBytesRead = 0;
     ReadOnlyMemory <byte> bytes;
     BufferWriter          writer = new BufferWriter();
     {
         writer.Write(valueToWrite);
         numBytesExpected = 2;
         writer.ActiveMemoryPosition.Should().Be(numBytesExpected);
         bytes     = writer.LazinatorMemory.GetConsolidatedMemory();
         valueRead = bytes.Span.ToUInt16(ref numBytesRead);
         valueRead.Should().Be(valueToWrite);
         numBytesRead.Should().Be(numBytesExpected);
     }
 }