internal void ToTtbCell(OtpOutputStream os) { if (isNull) { os.WriteNil(); return; } if (valueType == ColumnType.Varchar || valueType == ColumnType.Blob) { os.WriteBinary(varcharValue); } else if (valueType == ColumnType.SInt64) { os.WriteLong(sint64Value); } else if (valueType == ColumnType.Timestamp) { os.WriteLong(timestampValue); } else if (valueType == ColumnType.Boolean) { os.WriteBoolean(booleanValue); } else if (valueType == ColumnType.Double) { os.WriteDouble(doubleValue); } else { throw new InvalidOperationException("Could not convert to TTB value."); } }
public void Write_Binary() { var r = new Random(); byte[] rnd = new byte[65536]; r.NextBytes(rnd); byte[] want = BuildBinBuffer(rnd); byte[] got; using (var os = new OtpOutputStream()) { os.WriteBinary(rnd); Assert.AreEqual(want.Length, os.Position); got = os.ToArray(); } CollectionAssert.AreEqual(want, got); }