public void UnitRdz_Serialization() { string fileName = "DaryScores.bin"; var p1 = new PlayerDary(); p1.Add(new Player("GG", "Floyd"), 11); p1.Add(new Player(null, "Betty"), 22); p1.Add(new Player(null, "Alvin"), 33); p1.Add(new Player("GG", "Chuck"), 44); p1.Add(new Player("A1", "Ziggy"), 55); p1.Add(new Player("GG", null), 66); IFormatter formatter = new BinaryFormatter(); using (var fs = new FileStream(fileName, FileMode.Create)) { formatter.Serialize(fs, p1); } PlayerDary p2 = null; using (var fs = new FileStream(fileName, FileMode.Open)) { p2 = (PlayerDary)formatter.Deserialize(fs); } Assert.AreEqual(6, p2.Count); }
public void CrashRdz_NullCB() { var dary = new PlayerDary((SerializationInfo)null, new StreamingContext()); ((IDeserializationCallback)dary).OnDeserialization(null); }
public void CrashRdz_ArgumentNull() { var dary = new PlayerDary(); ((ISerializable)dary).GetObjectData(null, new StreamingContext()); }