Пример #1
0
        public void UnitRmz_Serialization()
        {
            string fileName = "MapScores.bin";
            var    map1     = new PlayerMap();

            map1.Add(new Player("GG", "Floyd"), 11);
            map1.Add(new Player(null, "Betty"), 22);
            map1.Add(new Player(null, "Alvin"), 33);
            map1.Add(new Player("GG", "Chuck"), 44);
            map1.Add(new Player("A1", "Ziggy"), 55);
            map1.Add(new Player("GG", null), 66);

            IFormatter formatter = new BinaryFormatter();

            using (var fs = new FileStream(fileName, FileMode.Create))
            { formatter.Serialize(fs, map1); }

            PlayerMap map2 = null;

            using (var fs = new FileStream(fileName, FileMode.Open))
            { map2 = (PlayerMap)formatter.Deserialize(fs); }

            Assert.AreEqual(6, map2.Count);
        }
Пример #2
0
        public void CrashRmz_NullCB()
        {
            var map = new PlayerMap((SerializationInfo)null, new StreamingContext());

            ((IDeserializationCallback)map).OnDeserialization(null);
        }
Пример #3
0
        public void CrashRmz_ArgumentNull()
        {
            var map = new PlayerMap();

            ((ISerializable)map).GetObjectData(null, new StreamingContext());
        }