コード例 #1
0
        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);
            }
        }
コード例 #2
0
        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);
            }
        }