public void SerializationUtility_SaveToFile_1() { string fileName = Path.GetTempFileName(); CanaryClass first = _GetCanary(); first.SaveToFile(fileName); CanaryClass second = SerializationUtility.RestoreObjectFromFile <CanaryClass>(fileName); first.EnsureSame(second); }
public void SerializationUtility_SaveToFile_2() { const int arraySize = 10; string fileName = Path.GetTempFileName(); CanaryClass[] first = new CanaryClass[arraySize]; for (int i = 0; i < arraySize; i++) { first[i] = _GetCanary(); first[i].Age = i; } first.SaveToFile(fileName); CanaryClass[] second = SerializationUtility.RestoreArrayFromFile <CanaryClass>(fileName); Assert.IsNotNull(second); Assert.AreEqual(first.Length, second.Length); for (int i = 0; i < arraySize; i++) { first[i].EnsureSame(second[i]); } }