Ejemplo n.º 1
0
        public void OptionalTest()
        {
            var sample = new OptionalClass(14, null);
            var buffer = DsSerializer.Serialize(sample);

            var sample1 = new OptionalClass(14, "kek");
            var buffer1 = DsSerializer.Serialize(sample1);


            var ds = DataStorage.CreateForRead(buffer);

            var res = DsSerializer.DeserializeInto <OptionalClass>(buffer);

            var res1 = DsSerializer.DeserializeInto <OptionalClass>(buffer1);

            Assert.AreEqual(res.A1, sample.A1);
            Assert.AreEqual(res.B1, sample.B1);
            Assert.AreEqual(res1.A1, sample1.A1);
            Assert.AreEqual(res1.B1, sample1.B1);
        }
Ejemplo n.º 2
0
        public void SerializerTest()
        {
            var sample = new Sample(512, "kek", new SampleIn(123, "431"), new List <SampleIn> {
                new SampleIn(123, "kok"),
                new SampleIn(154, "lol"),
                new SampleIn(125, "heh"),
            });
            var buffer = DsSerializer.Serialize(sample);

            var res = DsSerializer.DeserializeInto <Sample>(buffer);

            Assert.AreEqual(res.A, sample.A);
            Assert.AreEqual(res.B, sample.B);
            Assert.AreEqual(res.C.A1, sample.C.A1);
            Assert.AreEqual(res.C.B1, sample.C.B1);
            Assert.AreEqual(res.D.Count, sample.D.Count);
            for (int i = 0; i < res.D.Count; i++)
            {
                Assert.AreEqual(res.D[i].A1, sample.D[i].A1);
                Assert.AreEqual(res.D[i].B1, sample.D[i].B1);
            }
        }