Пример #1
0
            public void NullContent_ExceptionThrown()
            {
                var path = Path.Combine(appendAllTextTestFolder, nameof(NullContent_ExceptionThrown));

                Directory.CreateDirectory(appendAllTextTestFolder);

                Assert.ThrowsAsync <ArgumentNullException>(async() => await AsyncFile.AppendAllTextAsync(path, null));
            }
Пример #2
0
            public void AppendAllTextAsync_NullEncoding_ExceptionThrown()
            {
                var contents = "This is a test line.";
                var path     = Path.Combine(appendAllTextTestFolder, "AppendAllLinesAsync_Default_LinesAppended");

                Directory.CreateDirectory(appendAllTextTestFolder);

                Assert.ThrowsAsync <ArgumentNullException>(async() => await AsyncFile.AppendAllTextAsync(path, contents, null));
            }
Пример #3
0
            public async Task TextAppendedWithEncoding(Encoding encoding)
            {
                var contents = string.Join(Environment.NewLine, Enumerable.Repeat("This is a test line.", 150));
                var path     = Path.Combine(appendAllTextTestFolder, nameof(TextAppendedWithEncoding));

                Directory.CreateDirectory(appendAllTextTestFolder);
                File.WriteAllText(path, contents, encoding);

                await AsyncFile.AppendAllTextAsync(path, contents, encoding);

                contents += string.Join(Environment.NewLine, Enumerable.Repeat("This is a test line.", 150));

                var result = File.ReadAllText(path, encoding);

                Assert.AreEqual(contents, result);
            }