public void CheckSavingFiles() { //Creates an instance of the editor var editor = new uxEditor(); //Creates a Builder with sample text StringBuilder sb = new StringBuilder("Test if file can be saved."); string path = "./testFile.txt"; //Path to temporary test file //If test file does not exist if (!File.Exists(path)) { //Create the text file. //We also want to dispose of the stream reader created properly by running this with the using keyword. using (File.CreateText(path)); } //Use the test method editor.SaveFile(sb, path); string results = ""; //Read through file using (StreamReader sr = new StreamReader(path)) { //Loops through until the end of the file while (!sr.EndOfStream) { //Reads in the results results = results + sr.ReadLine(); } } //Checks to see if the results from the file are the same as the data written in. Assert.AreEqual(sb.ToString(), results); //Make sure the test file wasn't deleted during the test if (File.Exists(path)) { //Deletes the temporary file. File.Delete(path); } }