Пример #1
0
        public void EndToEnd()
        {
            using (var stream = new MemoryStream()) {
                using (var writer = new FeatherWriter(stream)) {
                    var payload = new ClassicEncoder();
                    payload.WriteUInt32(1);
                    payload.WriteBoolean(true);
                    payload.WriteString("test");
                    writer.Write(payload);

                    payload = new ClassicEncoder();
                    payload.WriteUInt32(2);
                    payload.WriteBoolean(false);
                    payload.WriteNullableString(null);
                    writer.Write(payload);
                }

                stream.Position = 0;

                using (var reader = new FeatherReader(stream)) {
                    var payload2 = reader.Read <ClassicDecoder>();
                    Assert.AreEqual((UInt32)1, payload2.ReadUInt32());
                    Assert.AreEqual(true, payload2.ReadBoolean());
                    Assert.AreEqual("test", payload2.ReadString());

                    payload2 = reader.Read <ClassicDecoder>();
                    Assert.AreEqual((UInt32)2, payload2.ReadUInt32());
                    Assert.AreEqual(false, payload2.ReadBoolean());
                    Assert.AreEqual(null, payload2.ReadNullableString());

                    Assert.AreEqual(null, reader.Read <ClassicDecoder>());
                }
            }
        }
Пример #2
0
        public void Write_Twice()
        {
            using (var stream = new MemoryStream()) {
                // Write to stream
                using (var writer = new FeatherWriter(stream)) {
                    writer.Write(Payload);
                    writer.Write(Payload);
                }

                Assert.AreEqual("1,true,test\n1,true,test\n", Encoding.UTF8.GetString(stream.ToArray()));
            }
        }