Esempio n. 1
0
        public void ToAndFromDataPropertyCollection()
        {
            TestMonkey value = new TestMonkey {
                Monkey = "Yay", HasTail = false
            };
            DataPropertyCollection dpc = value.ToDataPropertyCollection();

            Expect.AreEqual(value.Monkey, dpc.Value <string>("Monkey"));
            Expect.IsFalse(dpc.Value <bool>("HasTail"));

            TestMonkey valueAgain = dpc.ToInstance <TestMonkey>();

            Expect.AreEqual(valueAgain.Monkey, value.Monkey);
            Expect.AreEqual(valueAgain.HasTail, value.HasTail);
        }
Esempio n. 2
0
        public void CanSerializeAndDeserializeDataPropertyList()
        {
            DataPropertyCollection propList = new DataPropertyCollection();

            propList.Add("Prop1", true);
            propList.Add("Prop2", false);
            propList.Add("Name", "Banana");
            byte[] serialized = propList.ToBinaryBytes();

            DataPropertyCollection deserialized = serialized.FromBinaryBytes <DataPropertyCollection>();

            Expect.AreEqual(3, deserialized.Count);
            Expect.IsTrue(deserialized.Value <bool>("Prop1"));
            Expect.IsFalse(deserialized.Value <bool>("Prop2"));
            Expect.AreEqual("Banana", deserialized.Value <string>("Name"));
        }