[Test] public void TestSave() { // Arrange var mainForm = new mainForm(); var filePath = @"C:\Users\Hughes Portable Rig\source\repos\GraphicalProgrammingEnvironment\saved_user_input.txt"; var content = "test content"; mainForm.SingleCommandLine.Text = $"save {filePath} \"{content}\""; // Act mainForm.ExecuteCommand(); // Assert Assert.IsTrue(File.Exists(filePath)); Assert.AreEqual(content, File.ReadAllText(filePath)); // Clean up File.Delete(filePath); } }
else if (CommandSplit[0].Equals("save")) { string path = @"C:\Users\Hughes Portable Rig\source\repos\GraphicalProgrammingEnvironment"; string fileName = "saved_user_input.txt"; try { // Combine the path and file name string filePath = Path.Combine(path, fileName); // Save the contents of SingleCommandLine to the specified file File.WriteAllText(filePath, SingleCommandLineSaved); ErrorHandlingWindow.Clear(); SingleCommandLine.Clear(); ErrorHandlingWindow.Text = $"** File '{fileName}' has been saved at '{filePath}' **"; } catch (Exception ex) { ErrorHandlingWindow.Text = $"Error while saving: {ex.Message}"; } }