public void CustomTypeToStreamUtf8()
 {
     byte[] buffer = new byte[1024];
     MemoryStream stream = new MemoryStream(buffer);
     var writer = new StreamFormatter(stream, FormattingData.InvariantUtf8);
     writer.Append(new Age(56));
     writer.Append(new Age(14, inMonths: true));
     var writtenText = Encoding.UTF8.GetString(buffer, 0, (int)stream.Position);
     Assert.Equal(writtenText, "56y14m");
 }
        public void CustomTypeToStreamUtf16()
        {
            byte[] buffer = new byte[1024];
            MemoryStream stream = new MemoryStream(buffer);
            using(var writer = new StreamFormatter(stream, pool)) {
                writer.Append(new Age(56));
                writer.Append(new Age(14, inMonths: true));

                var writtenText = Encoding.Unicode.GetString(buffer, 0, (int)stream.Position);
                Assert.Equal(writtenText, "56y14m");
            }
        }