Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions Tests/Helpers/Testably.Abstractions.TestHelpers/Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Testably.Abstractions.TestHelpers;
public class Test
{
public static bool IsNet7OrGreater
#if NET7_0_OR_GREATER
#if NET7_0_OR_GREATER
=> true;
#else
=> false;
Expand Down Expand Up @@ -54,13 +54,13 @@ public static void SkipIfLongRunningTestsShouldBeSkipped(IFileSystem fileSystem)

public static void SkipIfTestsOnRealFileSystemShouldBeSkipped(IFileSystem fileSystem)
{
#if NCRUNCH
#if NCRUNCH
Skip.If(fileSystem is RealFileSystem, "NCrunch should not test the real file system.");
#endif
#if DEBUG && SKIP_TESTS_ON_REAL_FILESYSTEM
Skip.If(fileSystem is RealFileSystem,
#if DEBUG && SKIP_TESTS_ON_REAL_FILESYSTEM
Skip.If(fileSystem is RealFileSystem,
"Tests against real FileSystem are skipped in DEBUG mode with the build constant 'SKIP_TESTS_ON_REAL_FILESYSTEM'.");
#endif
// Do nothing when in release mode or `SKIP_TESTS_ON_REAL_FILESYSTEM` is not set
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,10 @@ public void CreateDirectory_TrailingDirectorySeparator_ShouldNotBeTrimmed(
result.Name.Should().Be(expectedName.TrimEnd(
FileSystem.Path.DirectorySeparatorChar,
FileSystem.Path.AltDirectorySeparatorChar));
result.FullName.Should().Be($"{BasePath}{FileSystem.Path.DirectorySeparatorChar}{expectedName}"
.Replace(FileSystem.Path.AltDirectorySeparatorChar, FileSystem.Path.DirectorySeparatorChar));
result.FullName.Should().Be(
$"{BasePath}{FileSystem.Path.DirectorySeparatorChar}{expectedName}"
.Replace(FileSystem.Path.AltDirectorySeparatorChar,
FileSystem.Path.DirectorySeparatorChar));
FileSystem.Should().HaveDirectory(nameWithSuffix);
}
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,207 +138,207 @@ public static TheoryData<Expression<Action<IDirectory>>, string, bool, Func<Test
Expression<Action<IDirectory>> Callback, Func<Test, bool>? SkipTest)>
GetDirectoryCallbackTestParameters(string value)
{
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
=> directory.CreateDirectory(value),
null);
#if FEATURE_FILESYSTEM_UNIXFILEMODE
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
=> directory.CreateDirectory(value, UnixFileMode.None),
test => test.RunsOnWindows);
#endif
#if FEATURE_FILESYSTEM_LINK
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
=> directory.CreateSymbolicLink(value, "foo"),
null);
yield return (ExceptionTestHelper.TestTypes.NullOrEmpty, "pathToTarget",
directory
yield return (ExceptionTestHelper.TestTypes.NullOrEmpty, "pathToTarget",
directory
=> directory.CreateSymbolicLink("foo", value),
null);
#endif
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
=> directory.Delete(value),
null);
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
=> directory.Delete(value, true),
null);
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
=> directory.EnumerateDirectories(value),
null);
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
=> directory.EnumerateDirectories(value, "foo"),
null);
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
=> directory.EnumerateDirectories(value, "foo", SearchOption.AllDirectories),
null);
#if FEATURE_FILESYSTEM_ENUMERATION_OPTIONS
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
=> directory.EnumerateDirectories(value, "foo", new EnumerationOptions()),
null);
#endif
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
=> directory.EnumerateFiles(value),
null);
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
=> directory.EnumerateFiles(value, "foo"),
null);
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
=> directory.EnumerateFiles(value, "foo", SearchOption.AllDirectories),
null);
#if FEATURE_FILESYSTEM_ENUMERATION_OPTIONS
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
=> directory.EnumerateFiles(value, "foo", new EnumerationOptions()),
null);
#endif
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
=> directory.EnumerateFileSystemEntries(value),
null);
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
=> directory.EnumerateFileSystemEntries(value, "foo"),
null);
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
=> directory.EnumerateFileSystemEntries(value, "foo", SearchOption.AllDirectories),
null);
#if FEATURE_FILESYSTEM_ENUMERATION_OPTIONS
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
=> directory.EnumerateFileSystemEntries(value, "foo", new EnumerationOptions()),
null);
#endif
// `Directory.Exists` doesn't throw an exception on `null`
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
=> directory.GetCreationTime(value),
null);
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
=> directory.GetCreationTimeUtc(value),
null);
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
=> directory.GetDirectories(value),
null);
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
=> directory.GetDirectories(value, "foo"),
null);
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
=> directory.GetDirectories(value, "foo", SearchOption.AllDirectories),
null);
#if FEATURE_FILESYSTEM_ENUMERATION_OPTIONS
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
=> directory.GetDirectories(value, "foo", new EnumerationOptions()),
null);
#endif
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
=> directory.GetFiles(value),
null);
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
=> directory.GetFiles(value, "foo"),
null);
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
=> directory.GetFiles(value, "foo", SearchOption.AllDirectories),
null);
#if FEATURE_FILESYSTEM_ENUMERATION_OPTIONS
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
=> directory.GetFiles(value, "foo", new EnumerationOptions()),
null);
#endif
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
=> directory.GetFileSystemEntries(value),
null);
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
=> directory.GetFileSystemEntries(value, "foo"),
null);
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
=> directory.GetFileSystemEntries(value, "foo", SearchOption.AllDirectories),
null);
#if FEATURE_FILESYSTEM_ENUMERATION_OPTIONS
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
=> directory.GetFileSystemEntries(value, "foo", new EnumerationOptions()),
null);
#endif
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
=> directory.GetLastAccessTime(value),
null);
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
=> directory.GetLastAccessTimeUtc(value),
null);
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
=> directory.GetLastWriteTime(value),
null);
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
=> directory.GetLastWriteTimeUtc(value),
null);
yield return (ExceptionTestHelper.TestTypes.AllExceptInvalidPath, "path",
directory
yield return (ExceptionTestHelper.TestTypes.AllExceptInvalidPath, "path",
directory
=> directory.GetParent(value),
null);
yield return (ExceptionTestHelper.TestTypes.NullOrEmpty, "sourceDirName",
directory
yield return (ExceptionTestHelper.TestTypes.NullOrEmpty, "sourceDirName",
directory
=> directory.Move(value, "foo"),
null);
yield return (ExceptionTestHelper.TestTypes.NullOrEmpty, "destDirName",
directory
yield return (ExceptionTestHelper.TestTypes.NullOrEmpty, "destDirName",
directory
=> directory.Move("foo", value),
null);
#if FEATURE_FILESYSTEM_LINK
yield return (ExceptionTestHelper.TestTypes.AllExceptWhitespace, "linkPath",
directory
yield return (ExceptionTestHelper.TestTypes.AllExceptWhitespace, "linkPath",
directory
=> directory.ResolveLinkTarget(value, false),
null);
#endif
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
=> directory.SetCreationTime(value, DateTime.Now),
null);
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
=> directory.SetCreationTimeUtc(value, DateTime.Now),
null);
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
=> directory.SetLastAccessTime(value, DateTime.Now),
null);
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
=> directory.SetLastAccessTimeUtc(value, DateTime.Now),
null);
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
=> directory.SetLastWriteTime(value, DateTime.Now),
null);
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
yield return (ExceptionTestHelper.TestTypes.All, "path",
directory
=> directory.SetLastWriteTimeUtc(value, DateTime.Now),
null);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#if FEATURE_FILESYSTEM_LINK
using System.IO;
using Testably.Abstractions.FluentAssertions;

namespace Testably.Abstractions.Tests.FileSystem.Directory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public void Delete_MissingDirectory_ShouldThrowDirectoryNotFoundException(string

[SkippableTheory]
[AutoData]
public void Delete_Recursive_WithOpenFile_ShouldThrowIOException(
public void Delete_Recursive_WithOpenFile_ShouldThrowIOException_OnWindows(
string path, string filename)
{
FileSystem.Initialize()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,22 @@ public void

#region Helpers

public static TheoryData<Expression<Action<IDirectoryInfo>>, string, bool> GetDirectoryInfoCallbacks(string? path)
public static TheoryData<Expression<Action<IDirectoryInfo>>, string, bool>
GetDirectoryInfoCallbacks(string? path)
{
TheoryData<Expression<Action<IDirectoryInfo>>, string, bool> theoryData = new();
foreach (var item in GetDirectoryInfoCallbackTestParameters(path!)
.Where(item => item.TestType.HasFlag(path.ToTestType())))
foreach ((ExceptionTestHelper.TestTypes TestType,
string ParamName,
Expression<Action<IDirectoryInfo>> Callback) item in
GetDirectoryInfoCallbackTestParameters(path!)
.Where(item => item.TestType.HasFlag(path.ToTestType())))
{
theoryData.Add(
item.Callback,
item.ParamName,
item.TestType.HasFlag(ExceptionTestHelper.TestTypes.IgnoreParamNameCheck));
}

return theoryData;
}

Expand Down
Loading