public void TestIntListObjectSerialization() { ListTestPatternBuffer patternBuffer = new ListTestPatternBuffer(); IntListObject o1 = new IntListObject(new List <int>() { 1, 5, 900, 7038 }); byte[] bytes = patternBuffer.Energize(o1); // 1 byte IntListObject type ID // 1 byte null bits // 1 byte list count // 16 bytes 4 invariant ints Assert.AreEqual(19, bytes.Length); object o2 = patternBuffer.Energize(bytes); IntListObject p1 = (IntListObject)o2; Assert.IsTrue(p1 is IntListObject); Assert.AreEqual(4, p1.IntListValue.Count); Assert.AreEqual(o1.IntListValue.Count, p1.IntListValue.Count); Assert.AreEqual(o1.IntListValue[0], p1.IntListValue[0]); Assert.AreEqual(o1.IntListValue[1], p1.IntListValue[1]); Assert.AreEqual(o1.IntListValue[2], p1.IntListValue[2]); Assert.AreEqual(o1.IntListValue[3], p1.IntListValue[3]); Assert.IsFalse(o1 == p1); }
public void TestIntListObjectNull() { ListTestPatternBuffer patternBuffer = new ListTestPatternBuffer(); IntListObject o1 = new IntListObject(null); byte[] bytes = patternBuffer.Energize(o1); // 1 byte IntListObject type ID // 1 byte list count Assert.AreEqual(2, bytes.Length); object o2 = patternBuffer.Energize(bytes); IntListObject p1 = (IntListObject)o2; Assert.IsTrue(p1 is IntListObject); Assert.IsNull(p1.IntListValue); Assert.IsFalse(o1 == p1); }