writeToFile() private method

private writeToFile ( string path, string data, System.Boolean append = false ) : void
path string
data string
append System.Boolean
return void
Beispiel #1
0
        public void testWriteAndReadToFileString()
        {
            string data = "This is some yummy data to test write";

            FileIOUtils.writeToFile(FILE_NAME, data, false);
            Assert.IsTrue(File.Exists(FILE_NAME));

            string expected = data;

            Assert.AreEqual(expected, FileIOUtils.readFromFile(FILE_NAME));

            FileIOUtils.writeToFile(FILE_NAME, data, true);
            Assert.AreEqual(expected + expected, FileIOUtils.readFromFile(FILE_NAME));
        }
Beispiel #2
0
        public void testWriteAndReadToFileArray()
        {
            string[] data =
            {
                "This is some yummy data to test write...",
                "And this is even more scrumptiousness...",
                "Then to top it all off, here's a tasty little morsel."
            };

            FileIOUtils.writeToFile(FILE_NAME, data, false);
            Assert.IsTrue(File.Exists(FILE_NAME));

            string expected = data[0] + StringUtils.CRLF + data[1] + StringUtils.CRLF + data[2] + StringUtils.CRLF;

            Assert.AreEqual(expected, FileIOUtils.readFromFile(FILE_NAME));

            FileIOUtils.writeToFile(FILE_NAME, data, true);
            Assert.AreEqual(expected + expected, FileIOUtils.readFromFile(FILE_NAME));
        }