public unsafe void WriteVariable() { const int i32ExpectedWriteSize = 1 + 5; const int i64ExpectedWriteSize = 1 + 10; const int u32ExpectedWriteSize = 1 + 5; const int u64ExpectedWriteSize = 1 + 9; var expectedValues = VariableValesSerialized; int expectedTotalWritten = 0; var buffer = new byte[expectedValues.Length]; using (var stream = new MemoryStream(buffer)) using (var writer = new global::WireType.WireTypeWriter(stream)) { writer.Write(1, i32ExpectedValue); expectedTotalWritten += i32ExpectedWriteSize; Assert.Equal(i32ExpectedWriteSize, writer.TotalWritten); AssertValues(expectedValues, buffer, expectedTotalWritten); writer.Write(2, i64ExpectedValue); expectedTotalWritten += i64ExpectedWriteSize; Assert.Equal(expectedTotalWritten, writer.TotalWritten); AssertValues(expectedValues, buffer, expectedTotalWritten); writer.Write(3, u32ExpectedValue); expectedTotalWritten += u32ExpectedWriteSize; Assert.Equal(expectedTotalWritten, writer.TotalWritten); AssertValues(expectedValues, buffer, expectedTotalWritten); writer.Write(4, u64ExpectedValue); expectedTotalWritten += u64ExpectedWriteSize; Assert.Equal(expectedTotalWritten, writer.TotalWritten); AssertValues(expectedValues, buffer, expectedTotalWritten); } }
public unsafe void WriteBlob() { const int blobExpectedWrittenSize = 95; var expectedBlobContents = BlobSerialized; var buffer = new byte[512]; using (var stream = new MemoryStream(buffer)) using (var writer = new global::WireType.WireTypeWriter(stream)) { writer.Write(1, BlobDeserialized); Assert.Equal(blobExpectedWrittenSize, writer.TotalWritten); AssertValues(BlobSerialized, buffer, blobExpectedWrittenSize); } }