public void TestDeserializeEmptyShort()
        {
            GuidData data = Program.Build <GuidData>(
                0x0A, 0x00 // prop 1, string:0
                );

            Assert.Equal(Guid.Empty, data.Bar);
        }
        public void TestDeserializeEmptyWide()
        {
            GuidData data = Program.Build <GuidData>(
                0x0A, 0x12,                                           // prop 1, string:18
                0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //1:fixed64:0
                0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00  //2:fixed64:0
                );

            Assert.Equal(Guid.Empty, data.Bar);
        }
 public void TestEmptyGuid() {
     GuidData foo = new GuidData { Bar = Guid.Empty };
     using (MemoryStream ms = new MemoryStream())
     {
         Serializer.Serialize(ms, foo);
         Assert.AreEqual(0, ms.Length); // 1 tag, 1 length (0)
         ms.Position = 0;
         GuidData clone = Serializer.Deserialize<GuidData>(ms);
         Assert.AreEqual(foo.Bar, clone.Bar);
     }
 }
        public void TestNonEmptyGuid()
        {
            GuidData foo = new GuidData {
                Bar = Guid.NewGuid()
            };

            using (MemoryStream ms = new MemoryStream())
            {
                Serializer.Serialize(ms, foo);
                Assert.Equal(20, ms.Length);
                ms.Position = 0;
                GuidData clone = Serializer.Deserialize <GuidData>(ms);
                Assert.Equal(foo.Bar, clone.Bar);
            }
        }
Exemple #5
0
        public void TestEmptyGuid()
        {
            GuidData foo = new GuidData {
                Bar = Guid.Empty
            };

            using (MemoryStream ms = new MemoryStream())
            {
                Serializer.Serialize(ms, foo);
                Assert.AreEqual(0, ms.Length); // 1 tag, 1 length (0)
                ms.Position = 0;
                GuidData clone = Serializer.Deserialize <GuidData>(ms);
                Assert.AreEqual(foo.Bar, clone.Bar);
            }
        }
Exemple #6
0
        public void TestNonEmptyGuid()
        {
            GuidData foo = new GuidData {
                Bar = Guid.NewGuid()
            };

            using (MemoryStream ms = new MemoryStream())
            {
                var tm = TypeModel.Create(false, ProtoCompatibilitySettingsValue.FullCompatibility);
                tm.Serialize(ms, foo);
                Assert.AreEqual(20, ms.Length);
                ms.Position = 0;
                GuidData clone = tm.Deserialize <GuidData>(ms);
                Assert.AreEqual(foo.Bar, clone.Bar);
            }
        }