public static void TryEncode_DestinationTooSmall_ShouldReturnFalse(object value) { var writer = new CborWriter(); Helpers.WriteValue(writer, value); byte[] encoding = writer.Encode(); byte[] target = new byte[encoding.Length - 1]; bool result = writer.TryEncode(target, out int bytesWritten); Assert.False(result); Assert.Equal(0, bytesWritten); Assert.All(target, b => Assert.Equal(0, b)); }
public static void TryEncode_HappyPath(object value) { var writer = new CborWriter(); Helpers.WriteValue(writer, value); byte[] encoding = writer.Encode(); byte[] target = new byte[encoding.Length]; bool result = writer.TryEncode(target, out int bytesWritten); Assert.True(result); Assert.Equal(encoding.Length, bytesWritten); Assert.Equal(encoding, target); }