public void CanSave([Values] SerializationMethodType method) { var manager = CreateManager(method); var testObject = new SaveLoadTestObject() { listOfStrings = new List <string> { "one", "two" }, count = 10, }; const string filename = "Testfile"; manager.Save(testObject, filename); var filepath = $"{SaveLoadUtility.GetSavePath(SaveDirectory, BaseDirectory)}/{filename}"; Assert.IsTrue(File.Exists(filepath)); manager.DeleteSave(filename); Assert.IsFalse(File.Exists(filepath)); Object.Destroy(manager); }
public void CanGetFiles() { var testSave = new SaveLoadTestObject() { testData = "SaveFileExists" }; var serializationMethod = GetSerializationMethod(SerializationMethodType.Binary); var filename = "TestSave.sav"; var folder = "TestFolder"; SaveLoadUtility.Save(testSave, serializationMethod, filename, folder); var files = SaveLoadUtility.GetSavedFiles(folder); Assert.IsTrue(files.Length == 1); //Files should contain a list of names that exactly match the file name used //omits the path of the file Assert.IsTrue(files[0] == filename); SaveLoadUtility.DeleteSavedFile(filename, folder); files = SaveLoadUtility.GetSavedFiles(); Assert.IsTrue(files.Length == 0); }
public void CanCopy([Values] SerializationMethodType method) { var manager = CreateManager(method); var testObject = new SaveLoadTestObject() { listOfStrings = new List <string> { "one", "two" }, count = 10, }; var loadedObject = manager.Copy(testObject); Assert.NotNull(loadedObject); Assert.IsFalse(ReferenceEquals(testObject, loadedObject)); Assert.NotNull(loadedObject.listOfStrings); Assert.IsTrue(loadedObject.listOfStrings.Count == testObject.listOfStrings.Count); for (int i = 0; i < testObject.listOfStrings.Count; i++) { Assert.IsTrue(testObject.listOfStrings[i] == loadedObject.listOfStrings[i]); } Assert.IsTrue(testObject.count == loadedObject.count); Object.Destroy(manager); }
public void SaveLoadAndDelete([Values] SerializationMethodType method) { var testSave = new SaveLoadTestObject() { testData = "SaveFileExists" }; var serializationMethod = GetSerializationMethod(method); var filename = "TestSave.sav"; SaveLoadUtility.Save(testSave, serializationMethod, filename); Assert.IsTrue(SaveLoadUtility.Exists(filename)); var loadedSave = (SaveLoadTestObject)SaveLoadUtility.Load(typeof(SaveLoadTestObject), serializationMethod, filename); Assert.NotNull(loadedSave); Assert.IsTrue(loadedSave.testData == testSave.testData); SaveLoadUtility.DeleteSavedFile(filename); Assert.IsFalse(SaveLoadUtility.Exists(filename)); }