public void TestFilenameExistsExist() { CreateProject.CreateFolder(@"Model\exist"); LoadSave.ZipFolderRenameToDCIP(@"Model\exist"); Assert.True(ValidateInput.FileNameExists("exist", @"Model\")); LoadSave.DeleteOriginalFolder(@"Model\exist"); System.IO.File.Delete(@"Model\exist.dcip"); }
/// <summary> /// Gets called when a .dcip needs to be loaded into memory. /// </summary> public static void Load() { // Configure open file dialog box System.Windows.Forms.OpenFileDialog fileDialog = new System.Windows.Forms.OpenFileDialog(); fileDialog.Filter = "DCIP Files|*.dcip"; fileDialog.Title = "Choose project to open: "; System.Windows.Forms.DialogResult result = fileDialog.ShowDialog(); //Save user filename if (result == System.Windows.Forms.DialogResult.OK) { destfile = fileDialog.FileName; BinaryFormatter formatter = new BinaryFormatter(); StreamReader framesOpen = null, stateOpen = null; FramesContainer container = null; ProjectState projectState = null; string destfilenoext = destfile.Substring(0, destfile.Length - 5); try { LoadSave.UnZipFolder(destfilenoext); framesOpen = new StreamReader(destfilenoext + @"\data.frames"); stateOpen = new StreamReader(destfilenoext + @"\data.state"); container = (FramesContainer)formatter.Deserialize(framesOpen.BaseStream); projectState = (ProjectState)formatter.Deserialize(stateOpen.BaseStream); stateOpen.Close(); framesOpen.Close(); LoadSave.DeleteOriginalFolder(destfilenoext); } catch (SerializationException e) { Prompt("Application error", e.Message); return; } //Event to fire back StateEventArgs stateeventargs = new StateEventArgs(); stateeventargs.Framescontainer = container; stateeventargs.Projectstate = projectState; //Return values to caller // Check if there are any Subscribers if (LoadSaveEvent != null) { LoadSaveEvent(null, stateeventargs); } } }
public void TestUnzipFolder() { CreateProject.CreateFolder(@"Model\TestUnzip"); LoadSave.ZipFolderRenameToDCIP(@"Model\TestUnzip"); LoadSave.DeleteOriginalFolder(@"Model\TestUnzip"); Assert.True(File.Exists(@"Model\TestUnzip.dcip")); LoadSave.UnZipFolder(@"Model\TestUnzip"); File.Delete(@"Model\TestUnzip.dcip"); Assert.True(Directory.Exists(@"Model\TestUnzip\")); LoadSave.DeleteOriginalFolder(@"Model\TestUnzip\"); }
public void TestDeleteOriginalFolderOK() { CreateProject.CreateFolder(@"Model\TestDelete\"); CreateProject.CreateFolder(@"Model\TestDelete\Test"); Assert.True(Directory.Exists(@"Model\TestDelete\")); Assert.True(Directory.Exists(@"Model\TestDelete\Test")); LoadSave.DeleteOriginalFolder(@"Model\TestDelete\"); Assert.False(Directory.Exists(@"Model\TestDelete\")); Assert.False(Directory.Exists(@"Model\TestDelete\Test")); }
/// <summary> /// Gets called when a project needs to be saved to the disk. /// </summary> /// <param name="givenprojectstate"></param> /// <returns>void</returns> public static void Save(ProjectState givenprojectstate, FramesContainer framescontainer) { string pathstring = ValidateInput.PathString(givenprojectstate.FileName, givenprojectstate.Destination); LoadSave.UnZipFolder(pathstring); File.Delete(pathstring + ".dcip"); WriteData(pathstring, givenprojectstate, framescontainer); LoadSave.ZipFolderRenameToDCIP(pathstring); LoadSave.DeleteOriginalFolder(pathstring); }
public void TestCreateOK() { CreateProject.Create("testproject", @"Model\TestCreate\"); LoadSave.DeleteOriginalFolder(@"Model\TestCreate\"); }