示例#1
0
        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.");
        }
示例#2
0
        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();
            }
        }
示例#3
0
        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.");
        }