hugheselite
hugheselite
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
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
right on, well thank you again for you time, have a great day
54 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
awesome good to know going forward
54 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
If you don't mind sharing how you went about figuring out the problem? that'd be wonderful
54 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
You are completely correct and fixed the issue
54 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
Your logic sounds 100% correct here to me so thank you vm for your time
54 replies