public void can_add_sub_folders()
        {
            var fs = new InMemoryFileSystem().CreateChildDir(@"C:\rootdir\subdir");
            var rootdir = fs.GetDirectory(@"C:\rootdir");
            rootdir.Exists().Should().Be.True();

            var subdir = rootdir.GetDirectory("subdir");
            subdir.Path.FullPath.ShouldBe(@"C:\rootdir\subdir");
            subdir.Exists().Should().Be.True();
        }
        public void can_move_folder()
        {
            var fs = new InMemoryFileSystem();
            var source = fs.GetDirectory("C:\\source");
            source.GetFile("file-in-folder.txt").MustExist();
            var destination = fs.GetDirectory("C:\\destination");
            source.MoveTo(destination);

            source.GetFile("file-in-folder.txt").Exists().Should().Be.False();
            source.Exists().Should().Be.False();

            destination.Exists().Should().Be.True();
            destination.GetFile("file-in-folder.txt").Exists().Should().Be.True();
        }
        public void non_existing_file(
            [Values(FileMode.Append, FileMode.Create, FileMode.CreateNew, FileMode.Open, FileMode.OpenOrCreate, FileMode.Truncate)] FileMode mode,
            [Values(FileAccess.Read, FileAccess.ReadWrite, FileAccess.Write)] FileAccess access,
            [Values(FileShare.Delete, FileShare.None, FileShare.Read, FileShare.ReadWrite, FileShare.Write)] FileShare share)
        {
            var inMem = new InMemoryFileSystem();
            using (var memTempDir = inMem.CreateTempDirectory())
            using (var localTempDir = LocalFileSystem.Instance.CreateTempDirectory())
            {
                var memTempFile = memTempDir.GetFile(Guid.NewGuid().ToString());
                var localTempFile = localTempDir.GetFile(Guid.NewGuid().ToString());

                TestSameCore(memTempFile, localTempFile, mode, access, share);
            }
        }
        public void content_is_written_correctly()
        {
            var fs = new InMemoryFileSystem();

            using (var file = fs.CreateTempFile())
            {
                var content = string.Join(" ", Enumerable.Repeat("Test value", 5000).ToArray());
                using (var str = file.OpenWrite())
                using (var sw = new StreamWriter(str, Encoding.UTF8))
                {
                    sw.Write(content);
                }
                using (var str = file.OpenRead())
                using (var sr = new StreamReader(str, Encoding.UTF8))
                {
                    sr.ReadToEnd().ShouldBe(content);
                }
            }
        }
 public in_memory_file_system()
 {
     FileSystem = new InMemoryFileSystem();
 }
 public void can_add_folders_to_fs()
 {
     var fs = new InMemoryFileSystem().CreateChildDir(@"C:\added folder");
     fs.Directories.ShouldHaveCountOf(1);
 }
 public file_search_context()
 {
     FileSystem = new InMemoryFileSystem();
 }