public void ReadFileActionTest() { String path = "..\\Debug\\Items\\test.txt";; RichTextBox rtb = new RichTextBox(); var fs = new FileStream(path, FileMode.Open, FileAccess.Read); var ac = new OpenTextAction(rtb, fs); ac.Execute(); Assert.AreEqual("All Watched Over By Machines Of Loving Grace", rtb.Text, "File is opened."); }
private void openToolStripMenuItem_Click(object sender, EventArgs e) { Stream myStream; OpenFileDialog openFile = new OpenFileDialog(); if (openFile.ShowDialog() == DialogResult.OK && (myStream = openFile.OpenFile()) != null) { OpenTextAction accc = new OpenTextAction(RTB, myStream); accc.Execute(); } }
public void WriteFileActionTest() { String path = "..\\Debug\\Items\\data.txt"; RichTextBox rtb = new RichTextBox(); rtb.Text = "All Watched Over By Machines Of Loving Grace"; // Write to file var saveAction = new SaveTextAction(rtb, path); saveAction.Execute(); rtb.Text = ""; // Read from file var fs = new FileStream(path, FileMode.Open, FileAccess.Read); var readAction = new OpenTextAction(rtb, fs); readAction.Execute(); Assert.AreEqual("All Watched Over By Machines Of Loving Grace", rtb.Text, "File has been created."); }