Пример #1
0
        public static void TestWriteFileContent()
        {
            Environment.CurrentDirectory = TestContext.CurrentContext.TestDirectory;

            var expected = @"line1
line2
line3";

            var lines = new[]
            {
                "line1",
                "line2",
                "line3"
            };

            IoHelpers.WriteFileContent("deleteme.txt", lines);
            var allLines = File.ReadAllText("deleteme.txt");

            // File.WriteAllLines appends line break at the end.
            File.WriteAllLines("deleteme.txt", lines);
            var allLinesWithLineBreak = File.ReadAllText("deleteme.txt");

            File.Delete("deleteme.txt");

            Assert.AreEqual(allLines, expected);
            Assert.AreEqual(allLinesWithLineBreak, expected + "\r\n");
        }
Пример #2
0
 /// <summary>Saves the document.</summary>
 protected override void SaveCore() => IoHelpers.WriteFileContent(Origin, _sourceLines.ToArray());