public void It_Should_Ignore_Static_Properties() { ClassWithStaticProperty.StaticField1 = "aaa"; var testClass = new ClassWithStaticProperty { Field1 = "bbb" }; var result = _converter.Convert(testClass); Assert.True(result.HasValue); var objAsHash = (LiquidHash)result.Value; Assert.Equal(1, objAsHash.Keys.Count); Assert.True(objAsHash.ContainsKey("field1")); Assert.Equal(LiquidString.Create(testClass.Field1), objAsHash["field1"].Value); }
public void StaticDataIsNotSerialised() { // Only instance fields will be serialised, which means that any fields / properties will be unaffected by the deserialisation process. To illustrate this.. // - Create something to clone that has a property and set that property to a known value var source = new ClassWithStaticProperty(); ClassWithStaticProperty.Count = 1; // - Serialise that data (if fields were going to be serialised then the value of the field would be captured here) var serialisedData = BinarySerialisation.Serialise(source, new ISerialisationTypeConverter[0], _referenceReuseStrategy); // - Change the property to a different value ClassWithStaticProperty.Count = 2; // - Deserialise.. if this were to read a value for the property from the serialised data and set it then the property value would revert back to // the value that it had when it was serialised var clone = BinarySerialisation.Deserialise <ClassWithStaticProperty>(serialisedData); // - Confirm that the property was NOT reverted back to the value that it had when the data was serialised Assert.Equal(2, ClassWithStaticProperty.Count); }