public void InvalidReadParameterRaisesError(int head, int track, int sector, int length) { // --- Arrange var floppy = VirtualFloppyFile.CreateSpectrumFloppyFile(TestFile); // --- Act floppy.ReadData(head, track, sector, length); }
public void CreatingAFloppyFileWorksAsExpected() { // --- Act VirtualFloppyFile.CreateSpectrumFloppyFile(TestFile); // --- Assert VirtualFloppyFile.OpenFloppyFile(TestFile); }
public void InvalidWriteParameterRaisesError(int head, int track, int sector, int length) { // --- Arrange var floppy = VirtualFloppyFile.CreateSpectrumFloppyFile(TestFile); var data = new byte[length]; // --- Act floppy.WriteData(head, track, sector, data); }
public void OpenOrCreateOpensAnExistingNewFile() { // --- Arrange var floppy = VirtualFloppyFile.CreateSpectrumFloppyFile(TestFile); var data = new byte[] { 0x01, 0x02, 0x03, 0x04 }; floppy.WriteData(1, 3, 5, data); // --- Act floppy = VirtualFloppyFile.OpenOrCreateFloppyFile(TestFile); // --- Assert var dataBack = floppy.ReadData(1, 3, 5, data.Length); dataBack.SequenceEqual(data).ShouldBeTrue(); }
/// <summary> /// Sets the active project to the current project file /// </summary> protected async override Task ExecuteAsync() { // --- Collect export parameters from the UI await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); if (DisplayCreateVfddDialog(out var vm)) { return; } // --- Create a temporary file string fullPath; try { var filename = Path.ChangeExtension(Path.GetFileName(vm.Filename), ".vfdd"); var userPath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); fullPath = Path.Combine(Path.Combine(userPath, "SpectNetFloppies"), filename); VirtualFloppyFile.CreateSpectrumFloppyFile(fullPath, vm.Format); } catch (Exception ex) { VsxDialogs.Show($"Error: {ex.Message}", "Error creating virtual floppy disk file"); return; } // --- Add the temp file to the project SpectrumProject.AddFileToProject(SpectNetPackage.Default.Options.VfddFolder, fullPath, INVALID_FOLDER_MESSAGE, FILE_EXISTS_MESSAGE); // --- Remove the temp file try { File.Delete(fullPath); } catch (Exception) { // --- This exception is intentionally ignored } }