public MockFileSystem(IDictionary<string, MockFileData> files)
        {
            this.files = new Dictionary<string, MockFileData>(
                files,
                StringComparer.InvariantCultureIgnoreCase);

            file = new MockFile(this);
            directory = new MockDirectory(this, file);
            fileInfoFactory = new MockFileInfoFactory(this);
            path = new MockPath();
            directoryInfoFactory = new MockDirectoryInfoFactory(this);
        }
        public MockFileSystem(IDictionary<string, MockFileData> files, string currentDirectory = @"C:\Foo\Bar")
        {
            this.files = new Dictionary<string, MockFileData>(StringComparer.OrdinalIgnoreCase);
            pathField = new MockPath(this);
            file = new MockFile(this);
            directory = new MockDirectory(this, file, FixPath(currentDirectory));
            fileInfoFactory = new MockFileInfoFactory(this);
            directoryInfoFactory = new MockDirectoryInfoFactory(this);

            if (files == null) return;
            foreach (var entry in files)
                AddFile(entry.Key, entry.Value);
        }
        public MockFileSystem(IDictionary<string, MockFileData> files, string currentDirectory = "")
        {
            if (String.IsNullOrEmpty(currentDirectory))
                currentDirectory = IO.Path.GetTempPath();

            this.files = new Dictionary<string, MockFileData>(StringComparer.OrdinalIgnoreCase);
            pathField = new MockPath(this);
            file = new MockFile(this);
            directory = new MockDirectory(this, file, currentDirectory);
            fileInfoFactory = new MockFileInfoFactory(this);
            directoryInfoFactory = new MockDirectoryInfoFactory(this);

            if (files == null) return;
            foreach (var entry in files)
                AddFileWithCreate(entry.Key, entry.Value);
        }
        public MockFileSystem(IDictionary<string, MockFileData> files)
        {
            file = new MockFile(this);
            directory = new MockDirectory(this, file);
            fileInfoFactory = new MockFileInfoFactory(this);
            path = new MockPath();
            directoryInfoFactory = new MockDirectoryInfoFactory(this);

            //For each mock file add a file to the files dictionary
            //Also add a file entry for all directories leading up to this file
            this.files = new Dictionary<string, MockFileData>(StringComparer.InvariantCultureIgnoreCase);
            foreach (var entry in files)
            {
                var directoryPath = Path.GetDirectoryName(entry.Key);
                if (!directory.Exists(directoryPath))
                    directory.CreateDirectory(directoryPath);

                if (!file.Exists(entry.Key))
                    this.files.Add(entry.Key, entry.Value);
            }
        }
 public MockFileData GetFile(string path)
 {
     path = FixPath(path);
     return FileExists(path) ? files[path] : null;
 }
Exemplo n.º 6
0
#pragma warning restore 649

            /// <inheritdoc />
            public Task <FileExistenceResult> CheckFileExistsAsync(PathBase path, TimeSpan timeout, CancellationToken cancellationToken)
            => Task.FromResult(CheckFileExistsAsyncResult);
Exemplo n.º 7
0
 /// <inheritdoc />
 public byte[] GetPathLocation(PathBase path) => new byte[]
 {
 };
Exemplo n.º 8
0
        public void ReturnsFalseIfOtherIsNull()
        {
            const PathBase nullPath = null;

            Assert.False(new AbsolutePath(Constants.ValidAbsoluteLocalRootPath + @"dir").Equals(nullPath));
        }
 public bool FileExists(string path)
 {
     path = FixPath(path);
     return files.ContainsKey(path);
 }
Exemplo n.º 10
0
 public Directory(PathBase Base)
     : this(new Path(Base))
 {
 }
Exemplo n.º 11
0
 public override int GetHashCode() => Method.GetHashCode() ^ Host.GetHashCode() ^ PathBase.GetHashCode() ^ Path.GetHashCode() ^ QueryString.GetHashCode();
Exemplo n.º 12
0
#pragma warning restore 649

            /// <inheritdoc />
            public Task <CopyFileResult> CopyToAsync(PathBase sourcePath, Stream destinationStream, long expectedContentSize, CancellationToken cancellationToken)
            => Task.FromResult(CopyToAsyncResult);
Exemplo n.º 13
0
 /// <inheritdoc />
 public Task <CopyFileResult> CopyFileAsync(PathBase path, AbsolutePath destinationPath, long contentSize, bool overwrite, CancellationToken cancellationToken)
 => Task.FromResult(CopyFileAsyncResult);
 public override string ToString()
 {
     if (IsUnixPipe)
     {
         if (String.IsNullOrEmpty(PathBase))
         {
             return(Scheme.ToLowerInvariant() + "://" + Host.ToLowerInvariant());
         }
         else
         {
             return(Scheme.ToLowerInvariant() + "://" + Host.ToLowerInvariant() + ":" + PathBase.ToLowerInvariant());
         }
     }
     else
     {
         return(Scheme.ToLowerInvariant() + "://" + Host.ToLowerInvariant() + ":" + Port.ToString(CultureInfo.InvariantCulture) + PathBase.ToLowerInvariant());
     }
 }
Exemplo n.º 15
0
 /// <summary>
 ///     Build a string from the path with special characters removed/replaced.
 /// </summary>
 /// <remarks>
 ///     The result can be used to name system-wide resources like mutexes, pipes, etc.
 /// </remarks>
 public static string ToGlobalResourceName(this PathBase path)
 {
     // Names for Mutexs can not have any slashes - need to skip "/" for unix
     return(@"Global\" + path.Path.ToUpperInvariant().Replace(":", string.Empty).Replace('\\', '_').Replace('/', '_'));
 }
 public void AddFile(string path, MockFileData mockFile)
 {
     path = FixPath(path);
     files.Add(path, mockFile);
 }
 public void RemoveFile(string path)
 {
     path = FixPath(path);
     files.Remove(path);
 }
Exemplo n.º 18
0
 public override string ToString()
 {
     return(Scheme.ToLowerInvariant() + "://" + Host.ToLowerInvariant() + ":" + Port.ToString(CultureInfo.InvariantCulture) + PathBase.ToLowerInvariant());
 }
Exemplo n.º 19
0
        public void ReturnsFalseIfOtherIsNull()
        {
            const PathBase nullPath = null;

            Assert.False(new RelativePath(Constants.ValidLevelTwoRelativePath).Equals(nullPath));
        }
Exemplo n.º 20
0
 public void Serialize(PathBase path)
 {
     Serialize(path.Path);
 }