Exemplo n.º 1
0
        public void DNETSerialize()
        {
            var values = new ClassEntity();

            values.Populate();

            var tested = DNETSerializeHelper.TestDNETSerialize(values);

            Compare(values, tested.Item3 as ClassEntity);

            Debug.WriteLine($"ClassTest.DNETSerialize - Bytes: {tested.Item2.ToString()} - Elapsed: {tested.Item1.ToString()}");
        }
Exemplo n.º 2
0
 public static void Compare(ClassEntity from, ClassEntity to)
 {
     if (!(from != null ^ to != null))
     {
         if (from != null)
         {
             Assert.AreEqual(from.Name, to.Name);
             Assert.AreEqual(from.Index, to.Index);
             Assert.AreEqual(from.Created, to.Created);
             Assert.AreEqual(from.Deeper, to.Deeper);
             Assert.AreEqual(from.DeeperNull, to.DeeperNull);
             Compare(from.Recursive, to.Recursive);
         }
     }
     else
     {
         throw new Exception();
     }
 }
Exemplo n.º 3
0
        public void CustomSerialize()
        {
            var values = new ClassEntity();

            values.Populate();

            var sw = Stopwatch.StartNew();

            var serialize = BinarySerialize.From <ClassEntity>();

            var bytes = serialize.Serialize(values);

            var returnedValues = serialize.Deserialize(bytes);

            sw.Stop();

            Compare(values, returnedValues);

            Debug.WriteLine($"ClassTest.CustomSerialize - Bytes: {bytes.Length.ToString()} - Elapsed: {sw.Elapsed.ToString()}");
        }
Exemplo n.º 4
0
 public void Populate(bool stopRecursive = false)
 {
     Name    = "ClassEntity";
     Index   = 22;
     Created = new System.DateTime(2019, 1, 28);
     Deeper  = new ClassEntityDeeperOne
     {
         Name       = "ClassEntityDeeperOne",
         Index      = 33,
         Created    = new System.DateTime(2018, 6, 18),
         MoreDeeper = new ClasEntityDeeperTwo
         {
             Name  = "ClasEntityDeeperTwo",
             Index = 44
         }
     };
     if (!stopRecursive)
     {
         Recursive = new ClassEntity();
         Recursive.Populate(true);
     }
 }