Ejemplo n.º 1
0
 public void ExtensionCanBeParsedCorrectly()
 {
     var expected = ".config";
     var fileName = "web.Debug.config";
     MemoryFile file = new MemoryFile(fileName, null);
     Assert.Equal(expected, file.Extension);
 }
Ejemplo n.º 2
0
        public static IFile CreateFile(this IDirectory directory, string name)
        {
            if (directory == null)
            {
                throw new ArgumentNullException("directory");
            }

            IDirectory dir;
            string fileName;
            directory.EnsureDirectory(name, out dir, out fileName);

            var file = new MemoryFile(fileName, dir);
            dir.CreateFile(file);
            return file;
        }
Ejemplo n.º 3
0
        public static IFile CreateFileFromDisk(this IDirectory directory, string name, FileInfo fileInfo)
        {
            if (directory == null)
            {
                throw new ArgumentNullException("directory");
            }

            IDirectory dir;
            string fileName;
            directory.EnsureDirectory(name, out dir, out fileName);

            var file = new MemoryFile(fileName, dir, new DiskFileStreamProvider(fileInfo));
            dir.CreateFile(file);
            return file;
        }
Ejemplo n.º 4
0
        public void MemoryFileCanReadAndWrite()
        {
            var expected = "test";
            string actual;
            MemoryFile file = new MemoryFile("test.txt", null);
            using (StreamWriter writer = new StreamWriter(file.StreamProvider.OpenWrite()))
            {
                writer.Write(expected);
            }

            using (StreamReader reader = new StreamReader(file.StreamProvider.OpenRead()))
            {
                actual = reader.ReadToEnd();
            }

            Assert.Equal(expected, actual);
        }
Ejemplo n.º 5
0
        public static IFile CreateFile(this IDirectory directory, string name)
        {
            if (directory == null)
            {
                throw new ArgumentNullException("directory");
            }

            IDirectory dir;
            string     fileName;

            directory.EnsureDirectory(name, out dir, out fileName);

            var file = new MemoryFile(fileName, dir);

            dir.CreateFile(file);
            return(file);
        }
Ejemplo n.º 6
0
        public static IFile CreateFileFromDisk(this IDirectory directory, string name, FileInfo fileInfo)
        {
            if (directory == null)
            {
                throw new ArgumentNullException("directory");
            }

            IDirectory dir;
            string     fileName;

            directory.EnsureDirectory(name, out dir, out fileName);

            var file = new MemoryFile(fileName, dir, new DiskFileStreamProvider(fileInfo));

            dir.CreateFile(file);
            return(file);
        }