Created
May 6, 2022 19:27
-
-
Save MichalBrylka/fc4f3e2ecae81c7ae708145cc0731bc3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [TestCase(0, 0, "")] | |
| [TestCase(1, 1, "3")] | |
| [TestCase(2, 2, "3|4")] | |
| [TestCase(3, 3, "3|4|5")] | |
| [TestCase(4, 3, "3|4|5|0")] | |
| [TestCase(5, 3, "3|4|5|0|0")] | |
| public void Read_ToBuffer_ShouldBeAbleToReadBytes(int bufferSize, int expectedCount, string expectedArray) | |
| { | |
| var sut = new SpanBinaryReader(new byte[] { 1, 2, 3, 4, 5 }, 2); | |
| // ^ | |
| Span<byte> buffer = stackalloc byte[bufferSize]; | |
| var count = sut.ReadTo(MemoryMarshal.CreateSpan(ref MemoryMarshal.GetReference(buffer), buffer.Length)); | |
| var actualText = string.Join("|", buffer.ToArray()); | |
| Assert.That(actualText, Is.EqualTo(expectedArray)); | |
| Assert.That(count, Is.EqualTo(expectedCount)); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment