private void WriteAllText(string path, MockFileData mockFileData) { if (mockFileDataAccessor.FileExists(path)) mockFileDataAccessor.RemoveFile(path); mockFileDataAccessor.AddFile(path, mockFileData); }
public void AddFile(string path, MockFileData mockFile) { var fixedPath = FixPath(path); lock (files) { if (FileExists(fixedPath)) { var isReadOnly = (files[fixedPath].Attributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly; var isHidden = (files[fixedPath].Attributes & FileAttributes.Hidden) == FileAttributes.Hidden; if (isReadOnly || isHidden) { throw new UnauthorizedAccessException(string.Format(CultureInfo.InvariantCulture, Properties.Resources.ACCESS_TO_THE_PATH_IS_DENIED, path)); } } var directoryPath = Path.GetDirectoryName(fixedPath); if (!directory.Exists(directoryPath)) { AddDirectory(directoryPath); } files[fixedPath] = mockFile; } }
public void AddFile(string path, MockFileData mockFile) { var fixedPath = FixPath(path); lock (files) { if (FileExists(fixedPath)) { var isReadOnly = (files[fixedPath].Attributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly; var isHidden = (files[fixedPath].Attributes & FileAttributes.Hidden) == FileAttributes.Hidden; if (isReadOnly || isHidden) { throw new UnauthorizedAccessException(string.Format(CultureInfo.InvariantCulture, "Access to the path '{0}' is denied.", path)); } } var directoryPath = Path.GetDirectoryName(fixedPath); if (!directory.Exists(directoryPath)) { AddDirectory(directoryPath); } files[fixedPath] = mockFile; } }
public void AddFileWithCreate(string path, MockFileData value) { var fixedPath = FixPath(path); var directoryName = Path.GetDirectoryName(fixedPath); if (!directory.Exists(directoryName)) { directory.CreateDirectory(directoryName); } AddFile(fixedPath, value); }
private Stream CreateInternal(string path, FileOptions options) { if (path == null) { throw new ArgumentNullException(nameof(path), "Path cannot be null."); } mockFileDataAccessor.PathVerifier.IsLegalAbsoluteOrRelative(path, nameof(path)); VerifyDirectoryExists(path); var mockFileData = new MockFileData(new byte[0]); mockFileDataAccessor.AddFile(path, mockFileData); return(OpenWriteInternal(path, options)); }
public void posts_without_front_matter_uses_convention_to_render_folder() { var file = new MockFileData("# Title"); var lastmod = new DateTime(2000,1,1); file.LastWriteTime = lastmod; fileSystem.AddFile(@"C:\TestSite\_posts\SomeFile.md", file); var outputPath = string.Format("/{0}/{1}", lastmod.ToString("yyyy'/'MM'/'dd"), "SomeFile.html"); // act var siteContext = generator.BuildContext(@"C:\TestSite", @"C:\TestSite\_site", false); var firstPost = siteContext.Posts.First(); Assert.Equal(outputPath, firstPost.Url); }
/// <summary> /// Creates a new file, writes the specified string to the file using the specified encoding, and then closes the file. If the target file already exists, it is overwritten. /// </summary> /// <param name="path">The file to write to. </param> /// <param name="contents">The string to write to the file. </param> /// <param name="encoding">The encoding to apply to the string.</param> /// <exception cref="ArgumentException"><paramref name="path"/> is a zero-length string, contains only white space, or contains one or more invalid characters as defined by <see cref="Path.GetInvalidPathChars"/>.</exception> /// <exception cref="ArgumentNullException"><paramref name="path"/> is <see langword="null"/> or contents is empty.</exception> /// <exception cref="PathTooLongException"> /// The specified path, file name, or both exceed the system-defined maximum length. /// For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. /// </exception> /// <exception cref="DirectoryNotFoundException">The specified path is invalid (for example, it is on an unmapped drive).</exception> /// <exception cref="IOException">An I/O error occurred while opening the file.</exception> /// <exception cref="UnauthorizedAccessException"> /// path specified a file that is read-only. /// -or- /// This operation is not supported on the current platform. /// -or- /// path specified a directory. /// -or- /// The caller does not have the required permission. /// </exception> /// <exception cref="FileNotFoundException">The file specified in <paramref name="path"/> was not found.</exception> /// <exception cref="NotSupportedException"><paramref name="path"/> is in an invalid format.</exception> /// <exception cref="System.Security.SecurityException">The caller does not have the required permission.</exception> /// <remarks> /// Given a string and a file path, this method opens the specified file, writes the string to the file using the specified encoding, and then closes the file. /// The file handle is guaranteed to be closed by this method, even if exceptions are raised. /// </remarks> public override void WriteAllText(string path, string contents, Encoding encoding) { mockFileDataAccessor.PathVerifier.IsLegalAbsoluteOrRelative(path, "path"); VerifyValueIsNotNull(path, "path"); if (mockFileDataAccessor.Directory.Exists(path)) { throw CommonExceptions.AccessDenied(path); } VerifyDirectoryExists(path); MockFileData data = contents == null ? new MockFileData(new byte[0]) : new MockFileData(contents, encoding); mockFileDataAccessor.AddFile(path, data); }
public void AddFile(string path, MockFileData mockFile) { var fixedPath = FixPath(path); if (FileExists(fixedPath) && (files[fixedPath].Attributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly) throw new UnauthorizedAccessException(string.Format("Access to the path '{0}' is denied.", path)); var directoryPath = Path.GetDirectoryName(fixedPath); lock (files) { if (!directory.Exists(directoryPath)) directory.CreateDirectory(directoryPath); files[fixedPath] = mockFile; } }
/// <summary> /// Creates a new file, writes the specified string to the file using the specified encoding, and then closes the file. If the target file already exists, it is overwritten. /// </summary> /// <param name="path">The file to write to. </param> /// <param name="contents">The string to write to the file. </param> /// <param name="encoding">The encoding to apply to the string.</param> /// <exception cref="ArgumentException"><paramref name="path"/> is a zero-length string, contains only white space, or contains one or more invalid characters as defined by <see cref="Path.GetInvalidPathChars"/>.</exception> /// <exception cref="ArgumentNullException"><paramref name="path"/> is <see langword="null"/> or contents is empty.</exception> /// <exception cref="PathTooLongException"> /// The specified path, file name, or both exceed the system-defined maximum length. /// For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. /// </exception> /// <exception cref="DirectoryNotFoundException">The specified path is invalid (for example, it is on an unmapped drive).</exception> /// <exception cref="IOException">An I/O error occurred while opening the file.</exception> /// <exception cref="UnauthorizedAccessException"> /// path specified a file that is read-only. /// -or- /// This operation is not supported on the current platform. /// -or- /// path specified a directory. /// -or- /// The caller does not have the required permission. /// </exception> /// <exception cref="FileNotFoundException">The file specified in <paramref name="path"/> was not found.</exception> /// <exception cref="NotSupportedException"><paramref name="path"/> is in an invalid format.</exception> /// <exception cref="System.Security.SecurityException">The caller does not have the required permission.</exception> /// <remarks> /// Given a string and a file path, this method opens the specified file, writes the string to the file using the specified encoding, and then closes the file. /// The file handle is guaranteed to be closed by this method, even if exceptions are raised. /// </remarks> public override void WriteAllText(string path, string contents, Encoding encoding) { if (path == null) { throw new ArgumentNullException("path", Properties.Resources.VALUE_CANNOT_BE_NULL); } if (mockFileDataAccessor.Directory.Exists(path)) { throw new UnauthorizedAccessException(string.Format(CultureInfo.InvariantCulture, Properties.Resources.ACCESS_TO_THE_PATH_IS_DENIED, path)); } MockFileData data = contents == null ? new MockFileData(new byte[0]) : new MockFileData(contents, encoding); mockFileDataAccessor.AddFile(path, data); }
/// <summary> /// Creates a new file, writes the specified string to the file using the specified encoding, and then closes the file. If the target file already exists, it is overwritten. /// </summary> /// <param name="path">The file to write to. </param> /// <param name="contents">The string to write to the file. </param> /// <param name="encoding">The encoding to apply to the string.</param> /// <exception cref="ArgumentException"><paramref name="path"/> is a zero-length string, contains only white space, or contains one or more invalid characters as defined by <see cref="Path.GetInvalidPathChars"/>.</exception> /// <exception cref="ArgumentNullException"><paramref name="path"/> is <see langword="null"/> or contents is empty.</exception> /// <exception cref="PathTooLongException"> /// The specified path, file name, or both exceed the system-defined maximum length. /// For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters. /// </exception> /// <exception cref="DirectoryNotFoundException">The specified path is invalid (for example, it is on an unmapped drive).</exception> /// <exception cref="IOException">An I/O error occurred while opening the file.</exception> /// <exception cref="UnauthorizedAccessException"> /// path specified a file that is read-only. /// -or- /// This operation is not supported on the current platform. /// -or- /// path specified a directory. /// -or- /// The caller does not have the required permission. /// </exception> /// <exception cref="FileNotFoundException">The file specified in <paramref name="path"/> was not found.</exception> /// <exception cref="NotSupportedException"><paramref name="path"/> is in an invalid format.</exception> /// <exception cref="System.Security.SecurityException">The caller does not have the required permission.</exception> /// <remarks> /// Given a string and a file path, this method opens the specified file, writes the string to the file using the specified encoding, and then closes the file. /// The file handle is guaranteed to be closed by this method, even if exceptions are raised. /// </remarks> public override void WriteAllText(string path, string contents, Encoding encoding) { mockFileDataAccessor.PathVerifier.IsLegalAbsoluteOrRelative(path, "path"); VerifyValueIsNotNull(path, "path"); if (mockFileDataAccessor.Directory.Exists(path)) { throw new UnauthorizedAccessException(string.Format(CultureInfo.InvariantCulture, StringResources.Manager.GetString("ACCESS_TO_THE_PATH_IS_DENIED"), path)); } VerifyDirectoryExists(path); MockFileData data = contents == null ? new MockFileData(new byte[0]) : new MockFileData(contents, encoding); mockFileDataAccessor.AddFile(path, data); }
private DateTime GetTimeFromFile(string path, Func <MockFileData, DateTime> existingFileFunction, Func <DateTime> nonExistingFileFunction) { DateTime result; MockFileData file = mockFileDataAccessor.GetFile(path); if (file != null) { result = existingFileFunction(file); } else { result = nonExistingFileFunction(); } return(result); }
public void AddFile(string path, MockFileData mockFile) { var fixedPath = FixPath(path); throwExceptionWhenReadonly(path, fixedPath); var directoryPath = Path.GetDirectoryName(fixedPath); lock (files) { if (!directory.Exists(directoryPath)) { directory.CreateDirectory(directoryPath); } files[fixedPath] = mockFile; } }
public void AddFile(string path, MockFileData mockFile) { var fixedPath = FixPath(path); if (FileExists(fixedPath) && (files[fixedPath].Attributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly) { throw new UnauthorizedAccessException(string.Format("Access to the path '{0}' is denied.", path)); } var directoryPath = Path.GetDirectoryName(fixedPath); lock (files) { if (!directory.Exists(directoryPath)) { directory.CreateDirectory(directoryPath); } files[fixedPath] = mockFile; } }
/// <summary> /// Gets the <see cref="FileAttributes"/> of the file on the path. /// </summary> /// <param name="path">The path to the file.</param> /// <returns>The <see cref="FileAttributes"/> of the file on the path.</returns> /// <exception cref="ArgumentException"><paramref name="path"/> is empty, contains only white spaces, or contains invalid characters.</exception> /// <exception cref="PathTooLongException">The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.</exception> /// <exception cref="NotSupportedException"><paramref name="path"/> is in an invalid format.</exception> /// <exception cref="FileNotFoundException"><paramref name="path"/> represents a file and is invalid, such as being on an unmapped drive, or the file cannot be found.</exception> /// <exception cref="DirectoryNotFoundException"><paramref name="path"/> represents a directory and is invalid, such as being on an unmapped drive, or the directory cannot be found.</exception> /// <exception cref="IOException">This file is being used by another process.</exception> /// <exception cref="UnauthorizedAccessException">The caller does not have the required permission.</exception> public override FileAttributes GetAttributes(string path) { if (path?.Length == 0) { throw new ArgumentException(Properties.Resources.THE_PATH_IS_NOT_OF_A_LEGAL_FORM, nameof(path)); } _mockFileDataAccessor.PathVerifier.IsLegalAbsoluteOrRelative(path, nameof(path)); MockFileData possibleFileData = _mockFileDataAccessor.GetFile(path); FileAttributes result; if (possibleFileData != null) { result = possibleFileData.Attributes; } else { DirectoryInfoBase directoryInfo = _mockFileDataAccessor.DirectoryInfo.FromDirectoryName(path); if (directoryInfo.Exists) { result = directoryInfo.Attributes; } else { DirectoryInfoBase parentDirectoryInfo = directoryInfo.Parent; if (!parentDirectoryInfo.Exists) { throw new DirectoryNotFoundException(string.Format(CultureInfo.InvariantCulture, Properties.Resources.COULD_NOT_FIND_PART_OF_PATH_EXCEPTION, path)); } throw new FileNotFoundException($"Could not find file '{path}'."); } } return(result); }
public override void Copy(string sourceFileName, string destFileName, bool overwrite) { if (sourceFileName == null) { throw new ArgumentNullException(nameof(sourceFileName), Properties.Resources.FILENAME_CANNOT_BE_NULL); } if (destFileName == null) { throw new ArgumentNullException(nameof(destFileName), Properties.Resources.FILENAME_CANNOT_BE_NULL); } _mockFileDataAccessor.PathVerifier.IsLegalAbsoluteOrRelative(sourceFileName, nameof(sourceFileName)); _mockFileDataAccessor.PathVerifier.IsLegalAbsoluteOrRelative(destFileName, nameof(destFileName)); string directoryNameOfDestination = _mockPath.GetDirectoryName(destFileName); if (!_mockFileDataAccessor.Directory.Exists(directoryNameOfDestination)) { throw new DirectoryNotFoundException(string.Format(CultureInfo.InvariantCulture, Properties.Resources.COULD_NOT_FIND_PART_OF_PATH_EXCEPTION, destFileName)); } bool fileExists = _mockFileDataAccessor.FileExists(destFileName); if (fileExists) { if (!overwrite) { throw new IOException($"The file {destFileName} already exists."); } _mockFileDataAccessor.RemoveFile(destFileName); } MockFileData sourceFile = _mockFileDataAccessor.GetFile(sourceFileName); _mockFileDataAccessor.AddFile(destFileName, sourceFile); }
public override Stream Create(string path, int bufferSize, FileOptions options) { if (path == null) { throw new ArgumentNullException(nameof(path), "Path cannot be null."); } mockFileDataAccessor.PathVerifier.IsLegalAbsoluteOrRelative(path, "path"); var directoryPath = mockPath.GetDirectoryName(path); if (!mockFileDataAccessor.Directory.Exists(directoryPath)) { throw new DirectoryNotFoundException(string.Format(CultureInfo.InvariantCulture, StringResources.Manager.GetString("COULD_NOT_FIND_PART_OF_PATH_EXCEPTION"), path)); } MockFileData mockFileData = new MockFileData(new byte[bufferSize]); mockFileDataAccessor.AddFile(path, mockFileData); var stream = OpenWrite(path); return(stream); }
public override void Move(string sourceFileName, string destFileName) { if (sourceFileName == null) { throw new ArgumentNullException(nameof(sourceFileName), Properties.Resources.FILENAME_CANNOT_BE_NULL); } if (destFileName == null) { throw new ArgumentNullException(nameof(destFileName), Properties.Resources.FILENAME_CANNOT_BE_NULL); } _mockFileDataAccessor.PathVerifier.IsLegalAbsoluteOrRelative(sourceFileName, nameof(sourceFileName)); _mockFileDataAccessor.PathVerifier.IsLegalAbsoluteOrRelative(destFileName, nameof(destFileName)); if (_mockFileDataAccessor.GetFile(destFileName) != null) { throw new IOException("A file can not be created if it already exists."); } MockFileData sourceFile = _mockFileDataAccessor.GetFile(sourceFileName); if (sourceFile == null) { throw new FileNotFoundException($"The file \"{sourceFileName}\" could not be found.", sourceFileName); } DirectoryInfoBase destDir = _mockFileDataAccessor.Directory.GetParent(destFileName); if (!destDir.Exists) { throw new DirectoryNotFoundException("Could not find a part of the path."); } _mockFileDataAccessor.AddFile(destFileName, new MockFileData(sourceFile.Contents)); _mockFileDataAccessor.RemoveFile(sourceFileName); }
public void page_default_values() { var filename = @"C:\TestSite\SomeFile.md"; var file = new MockFileData(@"--- param: value ---# Title"); var lastmod = new DateTime(2012,03,21); file.LastWriteTime = lastmod; fileSystem.AddFile(filename, file); // act var siteContext = generator.BuildContext(@"C:\TestSite", @"C:\TestSite\_site", false); Assert.Equal(1, siteContext.Pages.Count); Assert.Equal("this is a post", siteContext.Pages[0].Title); Assert.Equal(lastmod, siteContext.Pages[0].Date.Date); Assert.Equal("<h1>Title</h1>", siteContext.Pages[0].Content.TrimEnd()); Assert.Equal(@"C:\TestSite\_site\SomeFile.md", siteContext.Pages[0].Filepath); Assert.Equal(@"C:\TestSite\SomeFile.md", siteContext.Pages[0].File); Assert.Equal(2, siteContext.Pages[0].Bag.Count); // param, date Assert.Equal("value", siteContext.Pages[0].Bag["param"]); }
public void site_context_pages_have_date_in_bag(string fileName, bool useDefault) { // note - this test does not include the time component. var lastmod = new DateTime(2014, 09, 22); // arrange var expectedDate = useDefault ? lastmod.ToString("yyyy-MM-dd") : "2014-01-01"; var file = new MockFileData(ToPageContent("# Title")); file.LastWriteTime = lastmod; fileSystem.AddFile(fileName, file); // act var siteContext = generator.BuildContext(@"C:\TestSite", @"C:\TestSite\_site", false); // assert Assert.True(siteContext.Pages[0].Bag.ContainsKey("date")); Assert.IsType<DateTime>(siteContext.Pages[0].Bag["date"]); var actualDate = ((DateTime)siteContext.Pages[0].Bag["date"]).ToString("yyyy-MM-dd"); Assert.Equal(expectedDate, actualDate); }
public void AddFile(string path, MockFileData mockFile) { path = FixPath(path); files.Add(path, mockFile); }
public void AddFile(string path, MockFileData mockFile) { files.Add(path, mockFile); }
public void page_with_false_date_in_title() { var currentDate = new DateTime(2015, 1, 26).ToShortDateString(); var lastmod = new DateTime(2012,03,12); var filePath = string.Format(@"C:\TestSite\{0}SomeFile.md", currentDate.Replace("/", "-")); var file = new MockFileData(string.Format(@"--- param: value ---# Title", currentDate)); file.LastWriteTime = lastmod; fileSystem.AddFile(filePath, file); // act var siteContext = generator.BuildContext(@"C:\TestSite", @"C:\TestSite\_site", false); Assert.Equal(1, siteContext.Pages.Count); Assert.Equal("this is a post", siteContext.Pages[0].Title); Assert.Equal(lastmod, siteContext.Pages[0].Date.Date); Assert.Equal("<h1>Title</h1>", siteContext.Pages[0].Content.RemoveWhiteSpace()); Assert.Equal(string.Format(@"C:\TestSite\_site\{0}SomeFile.md", currentDate.Replace("/", "-")), siteContext.Pages[0].Filepath); Assert.Equal(filePath, siteContext.Pages[0].File); Assert.Equal(2, siteContext.Pages[0].Bag.Count); // param, date Assert.Equal("value", siteContext.Pages[0].Bag["param"]); }
private void SetEntry(string path, MockFileData mockFile) { path = FixPath(path, true).TrimSlashes(); files[path] = mockFile; }
public void post_with_false_date_in_title() { Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; var lastmod = new DateTime(2011,10,11); var currentDate = new DateTime(2015, 1, 26).ToShortDateString(); var expectedContent = string.Format(@"--- param: value ---# Title", currentDate); var filePath = string.Format(@"C:\TestSite\_posts\{0}SomeFile.md", currentDate.Replace("/", "-")); var file = new MockFileData(expectedContent); file.LastWriteTime = lastmod; fileSystem.AddFile(filePath, file); // act var siteContext = generator.BuildContext(@"C:\TestSite", @"C:\TestSite\_site", false); Assert.Equal(1, siteContext.Posts.Count); Assert.Equal("this is a post", siteContext.Posts[0].Title); Assert.Equal(lastmod, siteContext.Posts[0].Date.Date); Assert.Equal(expectedContent, siteContext.Posts[0].Content); Assert.Equal(string.Format(@"C:\TestSite\_site\{0}SomeFile.md", currentDate.Replace("/", "\\")), siteContext.Posts[0].Filepath); Assert.Equal(filePath, siteContext.Posts[0].File); Assert.Equal(2, siteContext.Posts[0].Bag.Count); // param, date Assert.Equal("value", siteContext.Posts[0].Bag["param"]); }
private void WriteAllText(string path, MockFileData mockFileData) { mockFileDataAccessor.AddFile(path, mockFileData); }
public void post_default_values() { var filename = @"C:\TestSite\_posts\SomeFile.md"; var expectedContent = @"--- param: value ---# Title"; var file = new MockFileData(expectedContent); var lastmod = new DateTime(2014, 04, 01); file.LastWriteTime = lastmod; fileSystem.AddFile(filename, file); // act var siteContext = generator.BuildContext(@"C:\TestSite", @"C:\TestSite\_site", false); Assert.Equal(1, siteContext.Posts.Count); Assert.Equal("this is a post", siteContext.Posts[0].Title); Assert.Equal(lastmod, siteContext.Posts[0].Date.Date); Assert.Equal(expectedContent, siteContext.Posts[0].Content); Assert.Equal(@"C:\TestSite\_site\SomeFile.md", siteContext.Posts[0].Filepath); Assert.Equal(@"C:\TestSite\_posts\SomeFile.md", siteContext.Posts[0].File); Assert.Equal(2, siteContext.Posts[0].Bag.Count); // param, date Assert.Equal("value", siteContext.Posts[0].Bag["param"]); }
public void posts_without_front_matter_and_override_config_renders_folder() { var post = new MockFileData("# Title"); var lastmod = new DateTime(2015, 03, 14); post.LastWriteTime = lastmod; fileSystem.AddFile(@"C:\TestSite\_posts\SomeFile.md", post); fileSystem.AddFile(@"C:\TestSite\_config.yml", new MockFileData("permalink: /blog/:year/:month/:day/:title.html")); var outputPath = string.Format("/blog/{0}/{1}",lastmod.ToString("yyyy'/'MM'/'dd"), "SomeFile.html"); // act var siteContext = generator.BuildContext(@"C:\TestSite", @"C:\TestSite\_site", false); var firstPost = siteContext.Posts.First(); Assert.Equal(outputPath, firstPost.Url); }
private string ReadAllTextInternal(string path, Encoding encoding) { MockFileData mockFileData = _mockFileDataAccessor.GetFile(path); return(ReadAllBytes(mockFileData.Contents, encoding)); }
private static MockFileSystem CreateFileSystem(IEnumerable<string> fileNames) { var output = new Dictionary<string, MockFileData>(); foreach (var f in fileNames) { output[@"C:\" + f] = new MockFileData(GetByteArrayFromStream(Assembly.GetExecutingAssembly().GetManifestResourceStream("ILRepackTests.BasicSampleOutput." + f))); } return new MockFileSystem(output); }
public async Task Get_Files(string basePath, IDictionary<string, string> files, string keyPrefix, bool recursive, IDictionary<string, ItemType> expectedFiles) { var provider = GetProvider(basePath); var config = GetConfig(basePath); foreach (var file in files) { var filePath = Path.Combine(basePath, file.Key); var fileData = new MockFileData(file.Value) { LastWriteTime = DateTime.UtcNow }; this.mockFileSystem.AddFile(filePath, fileData); } var actualFiles = await provider.GetItemsAsync(config, keyPrefix: keyPrefix, recursive: recursive); Assert.Equal(expectedFiles.Count, actualFiles.Count()); Assert.Equal(expectedFiles.Count(f => f.Value == ItemType.File), actualFiles.Count(f => f.Type == ItemType.File)); Assert.Equal(expectedFiles.Count(f => f.Value == ItemType.Directory), actualFiles.Count(f => f.Type == ItemType.Directory)); Assert.Equal(expectedFiles.Keys, actualFiles.Select(a => a.Key)); }