hugheselite
hugheselite
CC#
Created by hugheselite on 11/6/2024 in #help
How to pass a caught error from one .cs file to output in a textbox in another .cs file? (same sln)
No description
4 replies
CC#
Created by hugheselite on 11/6/2024 in #help
How to pass a caught error from one .cs file to output in a textbox in another .cs file? (same sln)
here's a visual representation of what i'm trying to do
4 replies
CC#
Created by hugheselite on 11/6/2024 in #help
How to pass a caught error from one .cs file to output in a textbox in another .cs file? (same sln)
https://paste.mod.gg/auczfkhbyxxm/1 Here is a link to my code
4 replies
CC#
Created by hugheselite on 12/13/2023 in #help
✅ My project isn't working when I run a while loop...
!close
3 replies
CC#
Created by hugheselite on 11/23/2023 in #help
✅ Help with unit testing a save function on a simple windows form app
!close
21 replies
CC#
Created by hugheselite on 11/23/2023 in #help
✅ Help with unit testing a save function on a simple windows form app
it's bad I know lol
21 replies
CC#
Created by hugheselite on 11/23/2023 in #help
✅ Help with unit testing a save function on a simple windows form app
my time spent using the debugger is minimal
21 replies
CC#
Created by hugheselite on 11/23/2023 in #help
✅ Help with unit testing a save function on a simple windows form app
I will try my best to show
21 replies
CC#
Created by hugheselite on 11/23/2023 in #help
✅ Help with unit testing a save function on a simple windows form app
when I try to write the file it works as expected
21 replies
CC#
Created by hugheselite on 11/23/2023 in #help
✅ Help with unit testing a save function on a simple windows form app
No description
21 replies
CC#
Created by hugheselite on 11/23/2023 in #help
✅ Help with unit testing a save function on a simple windows form app
No description
21 replies
CC#
Created by hugheselite on 11/23/2023 in #help
✅ Help with unit testing a save function on a simple windows form app
one moment I will post it
21 replies
CC#
Created by hugheselite on 11/23/2023 in #help
✅ Help with unit testing a save function on a simple windows form app
heres a repo to my entire project
21 replies
CC#
Created by hugheselite on 11/23/2023 in #help
✅ Help with unit testing a save function on a simple windows form app
21 replies
CC#
Created by hugheselite on 11/23/2023 in #help
✅ Help with unit testing a save function on a simple windows form app
[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);
}
}
[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);
}
}
here is the test itself
21 replies
CC#
Created by hugheselite on 11/23/2023 in #help
✅ Help with unit testing a save function on a simple windows form app
This is my save function im trying to test
21 replies
CC#
Created by hugheselite on 11/23/2023 in #help
✅ Help with unit testing a save function on a simple windows form app
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}";
}
}
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}";
}
}
21 replies
CC#
Created by hugheselite on 11/21/2023 in #help
✅ else statement executing regardless of whether I want it to or not, windows form app
!close
54 replies