Example #1
0
        public async Task MockFile_AppendAllLinesAsync_ShouldPersistNewLinesToNewFile()
        {
            // Arrange
            string path       = XFS.Path(@"c:\something\demo.txt");
            var    fileSystem = new MockFileSystem(new Dictionary <string, MockFileData>
            {
                { XFS.Path(@"c:\something\"), new MockDirectoryData() }
            });
            var file = new MockFile(fileSystem);

            // Act
            await file.AppendAllLinesAsync(path, new[] { "line 1", "line 2", "line 3" });

            // Assert
            Assert.AreEqual(
                "line 1" + Environment.NewLine + "line 2" + Environment.NewLine + "line 3" + Environment.NewLine,
                file.ReadAllText(path));
        }