示例#1
0
        public void SerializeDeserialize()
        {
            SPSKeyValueList keyValuesBefore = new SPSKeyValueList();

            SPSKeyValuePair keyValue0 = new SPSKeyValuePair("KeyA", "Value1");
            SPSKeyValuePair keyValue1 = new SPSKeyValuePair("KeyB", "Value2");

            keyValuesBefore.Add(keyValue0);
            keyValuesBefore.Add(keyValue1);

            string serialized = SPSKeyValueList.Serialize(keyValuesBefore);

            SPSKeyValueList keyValuesAfter = SPSKeyValueList.Deserialize(serialized);

            Assert.IsTrue(keyValuesAfter.Count == keyValuesBefore.Count);

            Assert.IsTrue(keyValuesAfter.Count == keyValuesBefore.Count);

            Assert.IsTrue(keyValuesAfter.Contains("KeyA"));
            Assert.IsTrue(keyValuesAfter.Contains("KeyB"));

            Assert.IsTrue(keyValuesAfter[0].Value == "Value1");
            Assert.IsTrue(keyValuesAfter[1].Value == "Value2");
        }