public void ReadAllText_ShouldReturnAllTextInFile() { using (var sandboxPath = new SandboxPath()) { //---------------Set up test pack------------------- var filePath = CreateDefaultConfigFile(sandboxPath); var fileSystemAdapter = new FileSystemAdapter(); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- var fileContents = fileSystemAdapter.ReadAllText(filePath); //---------------Test Result ----------------------- Assert.AreEqual("Line 1\\r\\nLine2", fileContents); } }
public void AppendAllLines_ShouldWriteToFile() { using (var sandboxPath = new SandboxPath()) { //---------------Set up test pack------------------- const string expected = "This is text"; var fileSystemAdapter = new FileSystemAdapter(); //---------------Assert Precondition---------------- //---------------Execute Test ---------------------- var newFile = Path.Combine(sandboxPath.FullPath, Guid.NewGuid().ToString()); fileSystemAdapter.AppendAllLines(newFile, new [] { expected }); //---------------Test Result ----------------------- var actual = fileSystemAdapter.ReadAllText(newFile).Trim(); Assert.AreEqual(expected, actual); } }