public void WriteStructWithSingleBlob(int blobSize) { var blob = new byte[blobSize]; new Random().NextBytes(blob); using (var writer = new ManagedBinaryWriter(_memoryStream, Symbols.EmptySymbolTablesArray)) { writer.StepIn(IonType.Struct); writer.SetFieldName("blob"); writer.WriteBlob(blob); writer.StepOut(); writer.Flush(); } var reader = new UserBinaryReader(new MemoryStream(_memoryStream.GetWrittenBuffer())); reader.MoveNext(); reader.StepIn(); Assert.AreEqual(IonType.Blob, reader.MoveNext()); var size = reader.GetLobByteSize(); Assert.AreEqual(blobSize, size); var readBlob = new byte[size]; reader.GetBytes(readBlob); Assert.IsTrue(blob.SequenceEqual(readBlob)); }