コード例 #1
0
        private void AddDirectory(MockDirectory directory)
        {
            if (this.Directories.ContainsKey(directory.FullName))
            {
                MockDirectory oldDirectory = this.Directories[directory.FullName];
                foreach (MockFile newFile in directory.Files.Values)
                {
                    newFile.FullName = Path.Combine(oldDirectory.FullName, newFile.Name);
                    oldDirectory.AddOrOverwriteFile(newFile, newFile.FullName);
                }

                foreach (MockDirectory newDirectory in directory.Directories.Values)
                {
                    newDirectory.FullName = Path.Combine(oldDirectory.FullName, newDirectory.Name);
                    this.AddDirectory(newDirectory);
                }
            }
            else
            {
                this.Directories.Add(directory.FullName, directory);
            }
        }
コード例 #2
0
        public MockFile CreateFile(string path, string contents, bool createDirectories = false)
        {
            string        parentPath      = path.Substring(0, path.LastIndexOf(Path.DirectorySeparatorChar));
            MockDirectory parentDirectory = this.FindDirectory(parentPath);

            if (createDirectories)
            {
                if (parentDirectory == null)
                {
                    parentDirectory = this.CreateDirectory(parentPath);
                }
            }
            else
            {
                parentDirectory.ShouldNotBeNull();
            }

            MockFile newFile = new MockFile(path, contents);

            parentDirectory.Files.Add(newFile.FullName, newFile);

            return(newFile);
        }
コード例 #3
0
ファイル: MockFileSystem.cs プロジェクト: yijunyu/VFSForGit
 public MockFileSystem(MockDirectory rootDirectory)
 {
     this.RootDirectory = rootDirectory;
     this.DeleteNonExistentFileThrowsException = true;
 }
コード例 #4
0
ファイル: MockFileSystem.cs プロジェクト: yyqyu/GVFS
 public MockFileSystem(MockDirectory rootDirectory)
 {
     this.RootDirectory = rootDirectory;
 }
コード例 #5
0
ファイル: MockFileSystem.cs プロジェクト: yazici/VFSForGit
 public MockFileSystem(MockDirectory rootDirectory)
 {
     this.RootDirectory = rootDirectory;
     this.DeleteNonExistentFileThrowsException = true;
     this.TryCreateOrUpdateDirectoryToAdminModifyPermissionsShouldSucceed = true;
 }
コード例 #6
0
        private bool TryGetDirectoryAndParent(string path, out MockDirectory directory, out MockDirectory parentDirectory)
        {
            if (this.Directories.TryGetValue(path, out directory))
            {
                parentDirectory = this;
                return(true);
            }
            else
            {
                string parentPath = path.Substring(0, path.LastIndexOf(Path.DirectorySeparatorChar));
                parentDirectory = this.FindDirectory(parentPath);
                if (parentDirectory != null)
                {
                    foreach (MockDirectory subDirectory in this.Directories.Values)
                    {
                        directory = subDirectory.FindDirectory(path);
                        if (directory != null)
                        {
                            return(true);
                        }
                    }
                }
            }

            directory       = null;
            parentDirectory = null;
            return(false);
        }
コード例 #7
0
 public void RemoveDirectory(MockDirectory directory)
 {
     this.Directories.ContainsKey(directory.FullName).ShouldEqual(true);
     this.Directories.Remove(directory.FullName);
 }
コード例 #8
0
 public MockFileSystem(MockDirectory rootDirectory)
 {
     this.RootDirectory = rootDirectory;
     this.DeleteNonExistentFileThrowsException = true;
     this.TryCreateDirectoryWithAdminOnlyModifyShouldSucceed = true;
 }