public void DeletingANonExistingFileDoesntCauseAnError() { //Arrange string testText = "hello, world!\n"; string testFilename = Unique("DeletingANonExistingFileDoesntCauseAnError.txt"); // create the file PersistentStorage.Write(testFilename, testText); //Act // delete the file multiple times PersistentStorage.Delete(testFilename); PersistentStorage.Delete(testFilename); PersistentStorage.Delete(testFilename); //Assert // If execution reaches this point, no error occured. Assert.Pass(); }
public void DeleteArchiveData(int index) { ArchivePreviewData previewData = ArchivePreviewData.ArchivePreviewData[index]; PersistentStorage.Delete(GetArchiveName(previewData)); ArchivePreviewData.ArchivePreviewData.Remove(previewData); Data.LocalCacheManager.SetData(ArchivePreviewData); SortArchivePreViewData(); }
public void SaveData(int saveIndex) { if (saveIndex >= 3) { return; } if (m_lastSaveInterval <= 1) { return; } m_lastSaveInterval = 0; bool isNewData = false; if (ArchivePreviewData.ArchivePreviewData.Count <= saveIndex) { isNewData = true; ArchivePreviewData.ArchivePreviewData.Add(new ArchivePreviewData()); } var previewData = ArchivePreviewData.ArchivePreviewData[ArchivePreviewData.ArchivePreviewData.Count - 1]; if (!isNewData) { PersistentStorage.Delete(GetArchiveName(previewData)); } //TODO:写入存档预览信息 previewData.SaveTime = DateTime.Now.Ticks; previewData.Img = "PreviewImg" + saveIndex.ToString(); previewData.EPName = MissionSceneManager.Instance.GetCurrentMission().ToString(); previewData.TotalPlayTime = (int)m_playTime; SortArchivePreViewData(); Data.LocalCacheManager.SetData(ArchivePreviewData); m_localCacheManager = new LocalCacheManager(previewData.SaveTime.ToString()); EventManager.Instance.SendEvent(new PlayerPreSaveArchiveEvent()); m_localCacheManager.SetData(CurrentArchiveData); EventManager.Instance.SendEvent(new PlayerSaveArchiveEvent()); }
public void DeleteActuallyDeletesAFile() { //Arrange string testText = "hello, world!\n"; string testFilename = Unique("DeleteActuallyDeletesAFile.txt"); // create the file PersistentStorage.Write(testFilename, testText); //Act // save the existance status before deletion bool initialExistence = FileExists(testFilename); // delete the file PersistentStorage.Delete(testFilename); // does the file exist? bool actualExistence = FileExists(testFilename); //Assert // the file should have existed initially Assert.IsTrue(initialExistence); // the file should no longer exist Assert.IsFalse(actualExistence); }