static void TestSync(string propertyName, object value) { // Get the property var property = typeof(TestClass).GetProperty(propertyName); // Set the value and ensure it was set correctly var cSrc = new TestClass(); property.SetValue(cSrc, value, null); Assert.AreEqual(value, property.GetValue(cSrc, null)); // Serialize var bs = new BitStream(); cSrc.Serialize(bs); // Deserialize var cDest = new TestClass(); bs.PositionBits = 0; cDest.Deserialize(bs); // Check Assert.AreEqual(value, property.GetValue(cDest, null)); }