diff --git a/Directory.Packages.props b/Directory.Packages.props
index 980557f00..6f10bd3eb 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -22,6 +22,7 @@
+
diff --git a/Tests/Directory.Build.props b/Tests/Directory.Build.props
index ac69bb5ec..b913ab435 100644
--- a/Tests/Directory.Build.props
+++ b/Tests/Directory.Build.props
@@ -24,8 +24,8 @@
+
-
diff --git a/Tests/Helpers/Testably.Abstractions.TestHelpers/Testably.Abstractions.TestHelpers.csproj b/Tests/Helpers/Testably.Abstractions.TestHelpers/Testably.Abstractions.TestHelpers.csproj
index 701d14815..a62987979 100644
--- a/Tests/Helpers/Testably.Abstractions.TestHelpers/Testably.Abstractions.TestHelpers.csproj
+++ b/Tests/Helpers/Testably.Abstractions.TestHelpers/Testably.Abstractions.TestHelpers.csproj
@@ -19,8 +19,8 @@
+
-
diff --git a/Tests/Helpers/Testably.Abstractions.Tests.SourceGenerator/ClassGenerators/FileSystemClassGenerator.cs b/Tests/Helpers/Testably.Abstractions.Tests.SourceGenerator/ClassGenerators/FileSystemClassGenerator.cs
index b914e6e1b..fe06ff70e 100644
--- a/Tests/Helpers/Testably.Abstractions.Tests.SourceGenerator/ClassGenerators/FileSystemClassGenerator.cs
+++ b/Tests/Helpers/Testably.Abstractions.Tests.SourceGenerator/ClassGenerators/FileSystemClassGenerator.cs
@@ -91,12 +91,12 @@ public RealFileSystemTests(ITestOutputHelper testOutputHelper, TestSettingsFixtu
#if DEBUG
if (fixture.RealFileSystemTests != TestSettingStatus.AlwaysEnabled)
{{
- throw new SkipException($""Tests against the real file system are {{fixture.RealFileSystemTests}}. You can enable them by executing the corresponding tests in Testably.Abstractions.TestSettings.RealFileSystemTests."");
+ throw new Xunit.SkipException($""Tests against the real file system are {{fixture.RealFileSystemTests}}. You can enable them by executing the corresponding tests in Testably.Abstractions.TestSettings.RealFileSystemTests."");
}}
#else
if (fixture.RealFileSystemTests == TestSettingStatus.AlwaysDisabled)
{{
- throw new SkipException($""Tests against the real file system are {{fixture.RealFileSystemTests}}. You can enable them by executing the corresponding tests in Testably.Abstractions.TestSettings.RealFileSystemTests."");
+ throw new Xunit.SkipException($""Tests against the real file system are {{fixture.RealFileSystemTests}}. You can enable them by executing the corresponding tests in Testably.Abstractions.TestSettings.RealFileSystemTests."");
}}
#endif
_fixture = fixture;
@@ -111,24 +111,24 @@ public void Dispose()
#if DEBUG
///
public override void SkipIfBrittleTestsShouldBeSkipped(bool condition = true)
- => Skip.If(condition && _fixture.BrittleTests != TestSettingStatus.AlwaysEnabled,
+ => Xunit.Skip.If(condition && _fixture.BrittleTests != TestSettingStatus.AlwaysEnabled,
$""Brittle tests are {{_fixture.BrittleTests}}. You can enable them by executing the corresponding tests in Testably.Abstractions.TestSettings.BrittleTests."");
#else
///
public override void SkipIfBrittleTestsShouldBeSkipped(bool condition = true)
- => Skip.If(condition && _fixture.BrittleTests == TestSettingStatus.AlwaysDisabled,
+ => Xunit.Skip.If(condition && _fixture.BrittleTests == TestSettingStatus.AlwaysDisabled,
$""Brittle tests are {{_fixture.BrittleTests}}. You can enable them by executing the corresponding tests in Testably.Abstractions.TestSettings.BrittleTests."");
#endif
#if DEBUG
///
public override void SkipIfLongRunningTestsShouldBeSkipped()
- => Skip.If(_fixture.LongRunningTests != TestSettingStatus.AlwaysEnabled,
+ => Xunit.Skip.If(_fixture.LongRunningTests != TestSettingStatus.AlwaysEnabled,
$""Long-running tests are {{_fixture.LongRunningTests}}. You can enable them by executing the corresponding tests in Testably.Abstractions.TestSettings.LongRunningTests."");
#else
///
public override void SkipIfLongRunningTestsShouldBeSkipped()
- => Skip.If(_fixture.LongRunningTests == TestSettingStatus.AlwaysDisabled,
+ => Xunit.Skip.If(_fixture.LongRunningTests == TestSettingStatus.AlwaysDisabled,
$""Long-running tests are {{_fixture.LongRunningTests}}. You can enable them by executing the corresponding tests in Testably.Abstractions.TestSettings.LongRunningTests."");
#endif
}}
diff --git a/Tests/Helpers/Testably.Abstractions.Tests.SourceGenerator/ClassGenerators/TimeSystemClassGenerator.cs b/Tests/Helpers/Testably.Abstractions.Tests.SourceGenerator/ClassGenerators/TimeSystemClassGenerator.cs
index fcde46bf9..ed3e8bfc7 100644
--- a/Tests/Helpers/Testably.Abstractions.Tests.SourceGenerator/ClassGenerators/TimeSystemClassGenerator.cs
+++ b/Tests/Helpers/Testably.Abstractions.Tests.SourceGenerator/ClassGenerators/TimeSystemClassGenerator.cs
@@ -58,12 +58,12 @@ public RealTimeSystemTests(TestSettingsFixture fixture) : base(new RealTimeSyste
#if DEBUG
///
public override void SkipIfBrittleTestsShouldBeSkipped(bool condition = true)
- => Skip.If(condition && _fixture.BrittleTests != TestSettingStatus.AlwaysEnabled,
+ => Xunit.Skip.If(condition && _fixture.BrittleTests != TestSettingStatus.AlwaysEnabled,
$""Brittle tests are {{_fixture.BrittleTests}}. You can enable them by executing the corresponding tests in Testably.Abstractions.TestSettings.BrittleTests."");
#else
///
public override void SkipIfBrittleTestsShouldBeSkipped(bool condition = true)
- => Skip.If(condition && _fixture.BrittleTests == TestSettingStatus.AlwaysDisabled,
+ => Xunit.Skip.If(condition && _fixture.BrittleTests == TestSettingStatus.AlwaysDisabled,
$""Brittle tests are {{_fixture.BrittleTests}}. You can enable them by executing the corresponding tests in Testably.Abstractions.TestSettings.BrittleTests."");
#endif
}}
diff --git a/Tests/Testably.Abstractions.AccessControl.Tests/AccessControlHelperTests.cs b/Tests/Testably.Abstractions.AccessControl.Tests/AccessControlHelperTests.cs
index 171397afc..0709aebb7 100644
--- a/Tests/Testably.Abstractions.AccessControl.Tests/AccessControlHelperTests.cs
+++ b/Tests/Testably.Abstractions.AccessControl.Tests/AccessControlHelperTests.cs
@@ -1,4 +1,6 @@
-using System.IO;
+using aweXpect;
+using System.IO;
+using System.Threading.Tasks;
namespace Testably.Abstractions.AccessControl.Tests;
@@ -8,41 +10,26 @@ public abstract partial class AccessControlHelperTests
where TFileSystem : IFileSystem
{
[SkippableFact]
- public void GetExtensibilityOrThrow_DirectoryInfo_ShouldNotThrow()
+ public async Task GetExtensibilityOrThrow_DirectoryInfo_ShouldNotThrow()
{
IDirectoryInfo sut = FileSystem.DirectoryInfo.New("foo");
- Exception? exception = Record.Exception(() =>
- {
- sut.GetExtensibilityOrThrow();
- });
-
- exception.Should().BeNull();
+ await That(() => sut.GetExtensibilityOrThrow()).Should().NotThrow();
}
[SkippableFact]
- public void GetExtensibilityOrThrow_FileInfo_ShouldNotThrow()
+ public async Task GetExtensibilityOrThrow_FileInfo_ShouldNotThrow()
{
IFileInfo sut = FileSystem.FileInfo.New("foo");
- Exception? exception = Record.Exception(() =>
- {
- sut.GetExtensibilityOrThrow();
- });
-
- exception.Should().BeNull();
+ await That(() => sut.GetExtensibilityOrThrow()).Should().NotThrow();
}
[SkippableFact]
- public void GetExtensibilityOrThrow_FileSystemStream_ShouldNotThrow()
+ public async Task GetExtensibilityOrThrow_FileSystemStream_ShouldNotThrow()
{
FileSystemStream sut = FileSystem.FileStream.New("foo", FileMode.Create);
- Exception? exception = Record.Exception(() =>
- {
- sut.GetExtensibilityOrThrow();
- });
-
- exception.Should().BeNull();
+ await That(() => sut.GetExtensibilityOrThrow()).Should().NotThrow();
}
}
diff --git a/Tests/Testably.Abstractions.AccessControl.Tests/DirectoryAclExtensionsTests.cs b/Tests/Testably.Abstractions.AccessControl.Tests/DirectoryAclExtensionsTests.cs
index cfc63f4e9..ff04f28ca 100644
--- a/Tests/Testably.Abstractions.AccessControl.Tests/DirectoryAclExtensionsTests.cs
+++ b/Tests/Testably.Abstractions.AccessControl.Tests/DirectoryAclExtensionsTests.cs
@@ -1,6 +1,8 @@
+using aweXpect;
using System.Security.AccessControl;
using System.Threading.Tasks;
using Testably.Abstractions.AccessControl.Tests.TestHelpers;
+using Skip = Xunit.Skip;
namespace Testably.Abstractions.AccessControl.Tests;
@@ -10,25 +12,23 @@ public abstract partial class DirectoryAclExtensionsTests
where TFileSystem : IFileSystem
{
[SkippableFact]
- public void CreateDirectory_NullDirectorySecurity_ShouldThrowArgumentNullException()
+ public async Task CreateDirectory_NullDirectorySecurity_ShouldThrowArgumentNullException()
{
Skip.IfNot(Test.RunsOnWindows);
#pragma warning disable CA1416
- Exception? exception = Record.Exception(() =>
- {
+ void Act() =>
FileSystem.Directory.CreateDirectory("foo", null!);
- });
#pragma warning restore CA1416
- exception.Should().BeOfType()
- .Which.ParamName.Should().Be("directorySecurity");
+ await That(Act).Should().Throw()
+ .WithParamName("directorySecurity");
}
[SkippableTheory]
[InlineData("bar")]
[InlineData("bar\\foo")]
- public void CreateDirectory_ShouldChangeAccessControl(string path)
+ public async Task CreateDirectory_ShouldChangeAccessControl(string path)
{
Skip.IfNot(Test.RunsOnWindows);
@@ -39,12 +39,12 @@ public void CreateDirectory_ShouldChangeAccessControl(string path)
DirectorySecurity result = FileSystem.Directory.GetAccessControl(path);
#pragma warning restore CA1416
- result.HasSameAccessRightsAs(directorySecurity).Should().BeTrue();
- FileSystem.Directory.Exists(path).Should().BeTrue();
+ await That(result.HasSameAccessRightsAs(directorySecurity)).Should().BeTrue();
+ await That(FileSystem.Directory.Exists(path)).Should().BeTrue();
}
[SkippableFact]
- public void GetAccessControl_ShouldBeInitializedWithNotNullValue()
+ public async Task GetAccessControl_ShouldBeInitializedWithNotNullValue()
{
Skip.IfNot(Test.RunsOnWindows);
@@ -53,13 +53,13 @@ public void GetAccessControl_ShouldBeInitializedWithNotNullValue()
#pragma warning disable CA1416
DirectorySecurity result =
FileSystem.Directory.GetAccessControl("foo");
- #pragma warning restore CA1416
- result.Should().NotBeNull();
+ await That(result).Should().NotBeNull();
+ #pragma warning restore CA1416
}
[SkippableFact]
- public void GetAccessControl_ShouldReturnSetResult()
+ public async Task GetAccessControl_ShouldReturnSetResult()
{
Skip.IfNot(Test.RunsOnWindows);
Skip.If(FileSystem is RealFileSystem);
@@ -74,13 +74,13 @@ public void GetAccessControl_ShouldReturnSetResult()
DirectorySecurity result =
FileSystem.Directory.GetAccessControl("foo");
- #pragma warning restore CA1416
- result.Should().Be(originalResult);
+ await That(result).Should().Be(originalResult);
+ #pragma warning restore CA1416
}
[SkippableFact]
- public void GetAccessControl_WithAccessControlSections_ShouldBeInitializedWithNotNullValue()
+ public async Task GetAccessControl_WithAccessControlSections_ShouldBeInitializedWithNotNullValue()
{
Skip.IfNot(Test.RunsOnWindows);
SkipIfLongRunningTestsShouldBeSkipped();
@@ -90,13 +90,13 @@ public void GetAccessControl_WithAccessControlSections_ShouldBeInitializedWithNo
#pragma warning disable CA1416
DirectorySecurity result =
FileSystem.Directory.GetAccessControl("foo", AccessControlSections.None);
- #pragma warning restore CA1416
- result.Should().NotBeNull();
+ await That(result).Should().NotBeNull();
+ #pragma warning restore CA1416
}
[SkippableFact]
- public void GetAccessControl_WithAccessControlSections_ShouldReturnSetResult()
+ public async Task GetAccessControl_WithAccessControlSections_ShouldReturnSetResult()
{
Skip.IfNot(Test.RunsOnWindows);
Skip.If(FileSystem is RealFileSystem);
@@ -111,13 +111,13 @@ public void GetAccessControl_WithAccessControlSections_ShouldReturnSetResult()
DirectorySecurity result =
FileSystem.Directory.GetAccessControl("foo", AccessControlSections.None);
- #pragma warning restore CA1416
- result.Should().Be(originalResult);
+ await That(result).Should().Be(originalResult);
+ #pragma warning restore CA1416
}
[SkippableFact]
- public void SetAccessControl_ShouldChangeAccessControl()
+ public async Task SetAccessControl_ShouldChangeAccessControl()
{
Skip.IfNot(Test.RunsOnWindows);
@@ -131,7 +131,7 @@ public void SetAccessControl_ShouldChangeAccessControl()
AccessControlSections.Access);
#pragma warning restore CA1416
- currentAccessControl.HasSameAccessRightsAs(originalAccessControl)
+ await That(currentAccessControl.HasSameAccessRightsAs(originalAccessControl))
.Should().BeTrue();
}
@@ -154,8 +154,8 @@ public async Task SetAccessControl_ShouldNotUpdateTimes()
DateTime lastAccessTimeUtc = FileSystem.File.GetLastAccessTimeUtc("foo.txt");
DateTime lastWriteTimeUtc = FileSystem.File.GetLastWriteTimeUtc("foo.txt");
- creationTimeUtc.Should().Be(previousCreationTimeUtc);
- lastAccessTimeUtc.Should().Be(previousLastAccessTimeUtc);
- lastWriteTimeUtc.Should().Be(previousLastWriteTimeUtc);
+ await That(creationTimeUtc).Should().Be(previousCreationTimeUtc);
+ await That(lastAccessTimeUtc).Should().Be(previousLastAccessTimeUtc);
+ await That(lastWriteTimeUtc).Should().Be(previousLastWriteTimeUtc);
}
}
diff --git a/Tests/Testably.Abstractions.AccessControl.Tests/DirectoryInfoAclExtensionsTests.cs b/Tests/Testably.Abstractions.AccessControl.Tests/DirectoryInfoAclExtensionsTests.cs
index d6ea9df85..f74811fcc 100644
--- a/Tests/Testably.Abstractions.AccessControl.Tests/DirectoryInfoAclExtensionsTests.cs
+++ b/Tests/Testably.Abstractions.AccessControl.Tests/DirectoryInfoAclExtensionsTests.cs
@@ -1,8 +1,8 @@
using AutoFixture.Xunit2;
using System.IO;
using System.Security.AccessControl;
-using System.Threading.Tasks;
using Testably.Abstractions.AccessControl.Tests.TestHelpers;
+using Skip = Xunit.Skip;
namespace Testably.Abstractions.AccessControl.Tests;
@@ -12,26 +12,24 @@ public abstract partial class DirectoryInfoAclExtensionsTests
where TFileSystem : IFileSystem
{
[SkippableFact]
- public void Create_NullDirectorySecurity_ShouldThrowArgumentNullException()
+ public async Task Create_NullDirectorySecurity_ShouldThrowArgumentNullException()
{
Skip.IfNot(Test.RunsOnWindows);
FileSystem.Directory.CreateDirectory("foo");
+
#pragma warning disable CA1416
- Exception? exception = Record.Exception(() =>
- {
- FileSystem.DirectoryInfo.New("foo").Create(null!);
- });
+ void Act() => FileSystem.DirectoryInfo.New("foo").Create(null!);
#pragma warning restore CA1416
- exception.Should().BeOfType()
- .Which.ParamName.Should().Be("directorySecurity");
+ await That(Act).Should().Throw()
+ .WithParamName("directorySecurity");
}
[SkippableTheory]
[InlineData("foo")]
[InlineData("foo\\bar")]
- public void Create_ShouldChangeAccessControl(string path)
+ public async Task Create_ShouldChangeAccessControl(string path)
{
Skip.IfNot(Test.RunsOnWindows);
@@ -42,29 +40,26 @@ public void Create_ShouldChangeAccessControl(string path)
DirectorySecurity result = FileSystem.Directory.GetAccessControl(path);
#pragma warning restore CA1416
- result.HasSameAccessRightsAs(directorySecurity).Should().BeTrue();
- FileSystem.Directory.Exists(path).Should().BeTrue();
+ await That(result.HasSameAccessRightsAs(directorySecurity)).Should().BeTrue();
+ await That(FileSystem.Directory.Exists(path)).Should().BeTrue();
}
[SkippableFact]
- public void GetAccessControl_MissingDirectory_ShouldThrowDirectoryNotFoundException()
+ public async Task GetAccessControl_MissingDirectory_ShouldThrowDirectoryNotFoundException()
{
Skip.IfNot(Test.RunsOnWindows);
IDirectoryInfo sut = FileSystem.DirectoryInfo.New("foo");
- Exception? exception = Record.Exception(() =>
- {
- #pragma warning disable CA1416
- _ = sut.GetAccessControl();
- #pragma warning restore CA1416
- });
+ #pragma warning disable CA1416
+ void Act() => sut.GetAccessControl();
+ #pragma warning restore CA1416
- exception.Should().BeOfType()
- .Which.HResult.Should().Be(-2147024893);
+ await That(Act).Should().Throw()
+ .WithHResult(-2147024893);
}
[SkippableFact]
- public void GetAccessControl_ShouldBeInitializedWithNotNullValue()
+ public async Task GetAccessControl_ShouldBeInitializedWithNotNullValue()
{
Skip.IfNot(Test.RunsOnWindows);
@@ -73,13 +68,13 @@ public void GetAccessControl_ShouldBeInitializedWithNotNullValue()
#pragma warning disable CA1416
DirectorySecurity result =
FileSystem.DirectoryInfo.New("foo").GetAccessControl();
- #pragma warning restore CA1416
- result.Should().NotBeNull();
+ await That(result).Should().NotBeNull();
+ #pragma warning restore CA1416
}
[SkippableFact]
- public void GetAccessControl_ShouldReturnSetResult()
+ public async Task GetAccessControl_ShouldReturnSetResult()
{
Skip.IfNot(Test.RunsOnWindows);
Skip.If(FileSystem is RealFileSystem);
@@ -94,31 +89,29 @@ public void GetAccessControl_ShouldReturnSetResult()
DirectorySecurity result =
FileSystem.DirectoryInfo.New("foo").GetAccessControl();
- #pragma warning restore CA1416
- result.Should().Be(originalResult);
+ await That(result).Should().Be(originalResult);
+ #pragma warning restore CA1416
}
[SkippableFact]
- public void
+ public async Task
GetAccessControl_WithAccessControlSections_MissingDirectory_ShouldThrowDirectoryNotFoundException()
{
Skip.IfNot(Test.RunsOnWindows);
IDirectoryInfo sut = FileSystem.DirectoryInfo.New("foo");
- Exception? exception = Record.Exception(() =>
- {
- #pragma warning disable CA1416
- _ = sut.GetAccessControl(AccessControlSections.None);
- #pragma warning restore CA1416
- });
+ #pragma warning disable CA1416
+ void Act() => sut.GetAccessControl(AccessControlSections.None);
+ #pragma warning restore CA1416
- exception.Should().BeOfType()
- .Which.HResult.Should().Be(-2147024893);
+ await That(Act).Should().Throw()
+ .WithHResult(-2147024893);
}
[SkippableFact]
- public void GetAccessControl_WithAccessControlSections_ShouldBeInitializedWithNotNullValue()
+ public async Task
+ GetAccessControl_WithAccessControlSections_ShouldBeInitializedWithNotNullValue()
{
Skip.IfNot(Test.RunsOnWindows);
SkipIfLongRunningTestsShouldBeSkipped();
@@ -128,13 +121,13 @@ public void GetAccessControl_WithAccessControlSections_ShouldBeInitializedWithNo
#pragma warning disable CA1416
DirectorySecurity result =
FileSystem.DirectoryInfo.New("foo").GetAccessControl(AccessControlSections.None);
- #pragma warning restore CA1416
- result.Should().NotBeNull();
+ await That(result).Should().NotBeNull();
+ #pragma warning restore CA1416
}
[SkippableFact]
- public void GetAccessControl_WithAccessControlSections_ShouldReturnSetResult()
+ public async Task GetAccessControl_WithAccessControlSections_ShouldReturnSetResult()
{
Skip.IfNot(Test.RunsOnWindows);
Skip.If(FileSystem is RealFileSystem);
@@ -149,13 +142,13 @@ public void GetAccessControl_WithAccessControlSections_ShouldReturnSetResult()
DirectorySecurity result =
FileSystem.DirectoryInfo.New("foo").GetAccessControl(AccessControlSections.None);
- #pragma warning restore CA1416
- result.Should().Be(originalResult);
+ await That(result).Should().Be(originalResult);
+ #pragma warning restore CA1416
}
[SkippableFact]
- public void SetAccessControl_ShouldChangeAccessControl()
+ public async Task SetAccessControl_ShouldChangeAccessControl()
{
Skip.IfNot(Test.RunsOnWindows);
@@ -169,7 +162,7 @@ public void SetAccessControl_ShouldChangeAccessControl()
AccessControlSections.Access);
#pragma warning restore CA1416
- currentAccessControl.HasSameAccessRightsAs(originalAccessControl)
+ await That(currentAccessControl.HasSameAccessRightsAs(originalAccessControl))
.Should().BeTrue();
}
@@ -193,8 +186,8 @@ public async Task SetAccessControl_ShouldNotUpdateTimes(string path)
DateTime lastAccessTimeUtc = FileSystem.File.GetLastAccessTimeUtc(path);
DateTime lastWriteTimeUtc = FileSystem.File.GetLastWriteTimeUtc(path);
- creationTimeUtc.Should().Be(previousCreationTimeUtc);
- lastAccessTimeUtc.Should().Be(previousLastAccessTimeUtc);
- lastWriteTimeUtc.Should().Be(previousLastWriteTimeUtc);
+ await That(creationTimeUtc).Should().Be(previousCreationTimeUtc);
+ await That(lastAccessTimeUtc).Should().Be(previousLastAccessTimeUtc);
+ await That(lastWriteTimeUtc).Should().Be(previousLastWriteTimeUtc);
}
}
diff --git a/Tests/Testably.Abstractions.AccessControl.Tests/ExceptionMissingFileTests.cs b/Tests/Testably.Abstractions.AccessControl.Tests/ExceptionMissingFileTests.cs
index 363602af1..90c18fc4c 100644
--- a/Tests/Testably.Abstractions.AccessControl.Tests/ExceptionMissingFileTests.cs
+++ b/Tests/Testably.Abstractions.AccessControl.Tests/ExceptionMissingFileTests.cs
@@ -2,6 +2,7 @@
using System.IO;
using System.Linq;
using Testably.Abstractions.AccessControl.Tests.TestHelpers;
+using Skip = Xunit.Skip;
namespace Testably.Abstractions.AccessControl.Tests;
@@ -13,7 +14,7 @@ public abstract partial class ExceptionMissingFileTests
[SkippableTheory]
[MemberData(nameof(GetFileCallbacks),
parameters: (int)(BaseTypes.Directory | BaseTypes.DirectoryInfo))]
- public void DirectoryOperations_WhenDirectoryIsMissing_ShouldThrowDirectoryNotFoundException(
+ public async Task DirectoryOperations_WhenDirectoryIsMissing_ShouldThrowDirectoryNotFoundException(
Action callback, BaseTypes baseType, MethodType exceptionType)
{
Skip.IfNot(Test.RunsOnWindows);
@@ -28,20 +29,20 @@ public void DirectoryOperations_WhenDirectoryIsMissing_ShouldThrowDirectoryNotFo
switch (exceptionType)
{
case MethodType.Create:
- exception.Should()
- .BeNull(
+ await That(exception).Should()
+ .BeNull().Because(
$"\n{exceptionType} on {baseType}\n was called with a missing directory");
break;
case MethodType.GetAccessControl:
- exception.Should()
- .BeOfType(
- $"\n{exceptionType} on {baseType}\n was called with a missing directory")
- .Which.HResult.Should().Be(-2147024893);
+ await That(exception).Should()
+ .Be()
+ .Because($"\n{exceptionType} on {baseType}\n was called with a missing directory")
+ .Which(e => e.HResult, h => h.Should().Be(-2147024893));
break;
case MethodType.SetAccessControl:
- exception.Should()
- .BeNull(
- $"\n{exceptionType} on {baseType}\n was called with a missing directory");
+ await That(exception).Should()
+ .BeNull()
+ .Because($"\n{exceptionType} on {baseType}\n was called with a missing directory");
break;
default:
throw new NotSupportedException();
@@ -51,7 +52,7 @@ public void DirectoryOperations_WhenDirectoryIsMissing_ShouldThrowDirectoryNotFo
[SkippableTheory]
[MemberData(nameof(GetFileCallbacks),
parameters: (int)(BaseTypes.Directory | BaseTypes.DirectoryInfo))]
- public void DirectoryOperations_WhenFileIsMissing_ShouldThrowFileNotFoundException(
+ public async Task DirectoryOperations_WhenFileIsMissing_ShouldThrowFileNotFoundException(
Action callback, BaseTypes baseType, MethodType exceptionType)
{
Skip.IfNot(Test.RunsOnWindows);
@@ -66,18 +67,20 @@ public void DirectoryOperations_WhenFileIsMissing_ShouldThrowFileNotFoundExcepti
switch (exceptionType)
{
case MethodType.Create:
- exception.Should()
- .BeNull($"\n{exceptionType} on {baseType}\n was called with a missing file");
+ await That(exception).Should()
+ .BeNull()
+ .Because($"\n{exceptionType} on {baseType}\n was called with a missing file");
break;
case MethodType.GetAccessControl:
- exception.Should()
- .BeOfType(
- $"\n{exceptionType} on {baseType}\n was called with a missing file")
- .Which.HResult.Should().Be(-2147024893);
+ await That(exception).Should()
+ .Be()
+ .Because($"\n{exceptionType} on {baseType}\n was called with a missing file")
+ .Which(e => e.HResult, h => h.Should().Be(-2147024893));
break;
case MethodType.SetAccessControl:
- exception.Should()
- .BeNull($"\n{exceptionType} on {baseType}\n was called with a missing file");
+ await That(exception).Should()
+ .BeNull()
+ .Because($"\n{exceptionType} on {baseType}\n was called with a missing file");
break;
default:
throw new NotSupportedException();
@@ -87,7 +90,7 @@ public void DirectoryOperations_WhenFileIsMissing_ShouldThrowFileNotFoundExcepti
[SkippableTheory]
[MemberData(nameof(GetFileCallbacks),
parameters: (int)(BaseTypes.File | BaseTypes.FileInfo | BaseTypes.FileStream))]
- public void FileOperations_WhenDirectoryIsMissing_ShouldThrowDirectoryNotFoundException(
+ public async Task FileOperations_WhenDirectoryIsMissing_ShouldThrowDirectoryNotFoundException(
Action callback, BaseTypes baseType, MethodType exceptionType)
{
Skip.IfNot(Test.RunsOnWindows);
@@ -102,21 +105,21 @@ public void FileOperations_WhenDirectoryIsMissing_ShouldThrowDirectoryNotFoundEx
switch (exceptionType)
{
case MethodType.Create:
- exception.Should()
- .BeOfType(
- $"\n{exceptionType} on {baseType}\n was called with a missing directory")
- .Which.HResult.Should().Be(-2147024891);
+ await That(exception).Should()
+ .Be()
+ .Because($"\n{exceptionType} on {baseType}\n was called with a missing directory")
+ .Which(e => e.HResult, h => h.Should().Be(-2147024891));
break;
case MethodType.GetAccessControl:
- exception.Should()
- .BeOfType(
- $"\n{exceptionType} on {baseType}\n was called with a missing directory")
- .Which.HResult.Should().Be(-2147024894);
+ await That(exception).Should()
+ .Be()
+ .Because($"\n{exceptionType} on {baseType}\n was called with a missing directory")
+ .Which(e => e.HResult, h => h.Should().Be(-2147024894));
break;
case MethodType.SetAccessControl:
- exception.Should()
- .BeNull(
- $"\n{exceptionType} on {baseType}\n was called with a missing directory");
+ await That(exception).Should()
+ .BeNull()
+ .Because($"\n{exceptionType} on {baseType}\n was called with a missing directory");
break;
default:
throw new NotSupportedException();
@@ -126,7 +129,7 @@ public void FileOperations_WhenDirectoryIsMissing_ShouldThrowDirectoryNotFoundEx
[SkippableTheory]
[MemberData(nameof(GetFileCallbacks),
parameters: (int)(BaseTypes.File | BaseTypes.FileInfo | BaseTypes.FileStream))]
- public void FileOperations_WhenFileIsMissing_ShouldThrowFileNotFoundException(
+ public async Task FileOperations_WhenFileIsMissing_ShouldThrowFileNotFoundException(
Action callback, BaseTypes baseType, MethodType exceptionType)
{
Skip.IfNot(Test.RunsOnWindows);
@@ -141,18 +144,20 @@ public void FileOperations_WhenFileIsMissing_ShouldThrowFileNotFoundException(
switch (exceptionType)
{
case MethodType.Create:
- exception.Should()
- .BeNull($"\n{exceptionType} on {baseType}\n was called with a missing file");
+ await That(exception).Should()
+ .BeNull()
+ .Because($"\n{exceptionType} on {baseType}\n was called with a missing file");
break;
case MethodType.GetAccessControl:
- exception.Should()
- .BeOfType(
- $"\n{exceptionType} on {baseType}\n was called with a missing file")
- .Which.HResult.Should().Be(-2147024894);
+ await That(exception).Should()
+ .Be()
+ .Because($"\n{exceptionType} on {baseType}\n was called with a missing file")
+ .Which(e => e.HResult, h => h.Should().Be(-2147024894));
break;
case MethodType.SetAccessControl:
- exception.Should()
- .BeNull($"\n{exceptionType} on {baseType}\n was called with a missing file");
+ await That(exception).Should()
+ .BeNull()
+ .Because($"\n{exceptionType} on {baseType}\n was called with a missing file");
break;
default:
throw new NotSupportedException();
diff --git a/Tests/Testably.Abstractions.AccessControl.Tests/ExceptionTests.cs b/Tests/Testably.Abstractions.AccessControl.Tests/ExceptionTests.cs
index 403ef051c..bc57158ee 100644
--- a/Tests/Testably.Abstractions.AccessControl.Tests/ExceptionTests.cs
+++ b/Tests/Testably.Abstractions.AccessControl.Tests/ExceptionTests.cs
@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Security.AccessControl;
+using Skip = Xunit.Skip;
namespace Testably.Abstractions.AccessControl.Tests;
@@ -12,54 +13,40 @@ public abstract partial class ExceptionTests
[SkippableTheory]
[MemberData(nameof(GetFileCallbacks),
parameters: (int)BaseTypes.All)]
- public void Operations_WhenPathIsEmpty_ShouldThrowArgumentException(
+ public async Task Operations_WhenPathIsEmpty_ShouldThrowArgumentException(
Action callback, BaseTypes baseType, MethodType exceptionType)
{
Skip.IfNot(Test.RunsOnWindows || exceptionType == MethodType.GetAccessControl);
- Exception? exception = Record.Exception(() =>
- {
- callback.Invoke(FileSystem, "");
- });
-
- exception.Should().BeException(
- hResult: -2147024809,
- because: $"\n{exceptionType} on {baseType}\n was called with an empty path");
+ await That(() => callback.Invoke(FileSystem, "")).Should()
+ .Throw().WithHResult(-2147024809)
+ .Because($"\n{exceptionType} on {baseType}\n was called with an empty path");
}
[SkippableTheory]
[MemberData(nameof(GetFileCallbacks),
parameters: (int)BaseTypes.All)]
- public void Operations_WhenPathIsNull_ShouldThrowArgumentNullException(
+ public async Task Operations_WhenPathIsNull_ShouldThrowArgumentNullException(
Action callback, BaseTypes baseType, MethodType exceptionType)
{
Skip.IfNot(Test.RunsOnWindows || exceptionType == MethodType.GetAccessControl);
- Exception? exception = Record.Exception(() =>
- {
- callback.Invoke(FileSystem, null!);
- });
-
- exception.Should().BeException(
- because: $"\n{exceptionType} on {baseType}\n was called with a null path");
+ await That(() => callback.Invoke(FileSystem, null!)).Should()
+ .Throw()
+ .Because($"\n{exceptionType} on {baseType}\n was called with a null path");
}
[SkippableTheory]
[MemberData(nameof(GetFileCallbacks),
parameters: (int)BaseTypes.All)]
- public void Operations_WhenPathIsWhiteSpace_ShouldThrowArgumentException(
+ public async Task Operations_WhenPathIsWhiteSpace_ShouldThrowArgumentException(
Action callback, BaseTypes baseType, MethodType exceptionType)
{
Skip.IfNot(Test.RunsOnWindows);
- Exception? exception = Record.Exception(() =>
- {
- callback.Invoke(FileSystem, " ");
- });
-
- exception.Should().BeException(
- hResult: -2147024809,
- because: $"\n{exceptionType} on {baseType}\n was called with a whitespace path");
+ await That(() => callback.Invoke(FileSystem, " ")).Should()
+ .Throw().WithHResult(-2147024809)
+ .Because($"\n{exceptionType} on {baseType}\n was called with a whitespace path");
}
#region Helpers
diff --git a/Tests/Testably.Abstractions.AccessControl.Tests/FileAclExtensionsTests.cs b/Tests/Testably.Abstractions.AccessControl.Tests/FileAclExtensionsTests.cs
index 4e0908327..74b448e53 100644
--- a/Tests/Testably.Abstractions.AccessControl.Tests/FileAclExtensionsTests.cs
+++ b/Tests/Testably.Abstractions.AccessControl.Tests/FileAclExtensionsTests.cs
@@ -1,6 +1,7 @@
using System.IO;
using System.Security.AccessControl;
using Testably.Abstractions.AccessControl.Tests.TestHelpers;
+using Skip = Xunit.Skip;
namespace Testably.Abstractions.AccessControl.Tests;
@@ -10,23 +11,23 @@ public abstract partial class FileAclExtensionsTests
where TFileSystem : IFileSystem
{
[SkippableFact]
- public void GetAccessControl_MissingFile_ShouldThrowFileNotFoundException()
+ public async Task GetAccessControl_MissingFile_ShouldThrowFileNotFoundException()
{
Skip.IfNot(Test.RunsOnWindows);
- Exception? exception = Record.Exception(() =>
+ void Act()
{
#pragma warning disable CA1416
_ = FileSystem.File.GetAccessControl("foo");
#pragma warning restore CA1416
- });
+ }
- exception.Should().BeOfType()
- .Which.HResult.Should().Be(-2147024894);
+ await That(Act).Should().Throw()
+ .WithHResult(-2147024894);
}
[SkippableFact]
- public void GetAccessControl_ShouldBeInitializedWithNotNullValue()
+ public async Task GetAccessControl_ShouldBeInitializedWithNotNullValue()
{
Skip.IfNot(Test.RunsOnWindows);
@@ -34,13 +35,13 @@ public void GetAccessControl_ShouldBeInitializedWithNotNullValue()
#pragma warning disable CA1416
FileSecurity result = FileSystem.File.GetAccessControl("foo");
- #pragma warning restore CA1416
- result.Should().NotBeNull();
+ await That(result).Should().NotBeNull();
+ #pragma warning restore CA1416
}
[SkippableFact]
- public void GetAccessControl_ShouldReturnSetResult()
+ public async Task GetAccessControl_ShouldReturnSetResult()
{
Skip.IfNot(Test.RunsOnWindows);
Skip.If(FileSystem is RealFileSystem);
@@ -54,30 +55,30 @@ public void GetAccessControl_ShouldReturnSetResult()
FileSecurity result =
FileSystem.File.GetAccessControl("foo");
- #pragma warning restore CA1416
- result.Should().Be(originalResult);
+ await That(result).Should().Be(originalResult);
+ #pragma warning restore CA1416
}
[SkippableFact]
- public void
+ public async Task
GetAccessControl_WithAccessControlSections_MissingFile_ShouldThrowFileNotFoundException()
{
Skip.IfNot(Test.RunsOnWindows);
- Exception? exception = Record.Exception(() =>
+ void Act()
{
#pragma warning disable CA1416
_ = FileSystem.File.GetAccessControl("foo", AccessControlSections.None);
#pragma warning restore CA1416
- });
+ }
- exception.Should().BeOfType()
- .Which.HResult.Should().Be(-2147024894);
+ await That(Act).Should().Throw()
+ .WithHResult(-2147024894);
}
[SkippableFact]
- public void GetAccessControl_WithAccessControlSections_ShouldBeInitializedWithNotNullValue()
+ public async Task GetAccessControl_WithAccessControlSections_ShouldBeInitializedWithNotNullValue()
{
Skip.IfNot(Test.RunsOnWindows);
SkipIfLongRunningTestsShouldBeSkipped();
@@ -86,13 +87,13 @@ public void GetAccessControl_WithAccessControlSections_ShouldBeInitializedWithNo
#pragma warning disable CA1416
FileSecurity result = FileSystem.File.GetAccessControl("foo", AccessControlSections.None);
- #pragma warning restore CA1416
- result.Should().NotBeNull();
+ await That(result).Should().NotBeNull();
+ #pragma warning restore CA1416
}
[SkippableFact]
- public void GetAccessControl_WithAccessControlSections_ShouldReturnSetResult()
+ public async Task GetAccessControl_WithAccessControlSections_ShouldReturnSetResult()
{
Skip.IfNot(Test.RunsOnWindows);
Skip.If(FileSystem is RealFileSystem);
@@ -107,13 +108,13 @@ public void GetAccessControl_WithAccessControlSections_ShouldReturnSetResult()
FileSecurity result =
FileSystem.File.GetAccessControl("foo", AccessControlSections.None);
- #pragma warning restore CA1416
- result.Should().Be(originalResult);
+ await That(result).Should().Be(originalResult);
+ #pragma warning restore CA1416
}
[SkippableFact]
- public void SetAccessControl_ShouldChangeAccessControl()
+ public async Task SetAccessControl_ShouldChangeAccessControl()
{
Skip.IfNot(Test.RunsOnWindows);
@@ -126,7 +127,7 @@ public void SetAccessControl_ShouldChangeAccessControl()
FileSystem.File.GetAccessControl("foo", AccessControlSections.Access);
#pragma warning restore CA1416
- currentAccessControl.HasSameAccessRightsAs(originalAccessControl)
+ await That(currentAccessControl.HasSameAccessRightsAs(originalAccessControl))
.Should().BeTrue();
}
}
diff --git a/Tests/Testably.Abstractions.AccessControl.Tests/FileInfoAclExtensionsTests.cs b/Tests/Testably.Abstractions.AccessControl.Tests/FileInfoAclExtensionsTests.cs
index c5f285b48..fee514bf9 100644
--- a/Tests/Testably.Abstractions.AccessControl.Tests/FileInfoAclExtensionsTests.cs
+++ b/Tests/Testably.Abstractions.AccessControl.Tests/FileInfoAclExtensionsTests.cs
@@ -1,6 +1,7 @@
using System.IO;
using System.Security.AccessControl;
using Testably.Abstractions.AccessControl.Tests.TestHelpers;
+using Skip = Xunit.Skip;
namespace Testably.Abstractions.AccessControl.Tests;
@@ -10,24 +11,24 @@ public abstract partial class FileInfoAclExtensionsTests
where TFileSystem : IFileSystem
{
[SkippableFact]
- public void GetAccessControl_MissingFile_ShouldThrowFileNotFoundException()
+ public async Task GetAccessControl_MissingFile_ShouldThrowFileNotFoundException()
{
Skip.IfNot(Test.RunsOnWindows);
IFileInfo sut = FileSystem.FileInfo.New("foo");
- Exception? exception = Record.Exception(() =>
+ void Act()
{
#pragma warning disable CA1416
_ = sut.GetAccessControl();
#pragma warning restore CA1416
- });
+ }
- exception.Should().BeOfType()
- .Which.HResult.Should().Be(-2147024894);
+ await That(Act).Should().Throw()
+ .WithHResult(-2147024894);
}
[SkippableFact]
- public void GetAccessControl_ShouldBeInitializedWithNotNullValue()
+ public async Task GetAccessControl_ShouldBeInitializedWithNotNullValue()
{
Skip.IfNot(Test.RunsOnWindows);
@@ -36,13 +37,13 @@ public void GetAccessControl_ShouldBeInitializedWithNotNullValue()
#pragma warning disable CA1416
FileSecurity result = fileInfo.GetAccessControl();
- #pragma warning restore CA1416
- result.Should().NotBeNull();
+ await That(result).Should().NotBeNull();
+ #pragma warning restore CA1416
}
[SkippableFact]
- public void GetAccessControl_ShouldReturnSetResult()
+ public async Task GetAccessControl_ShouldReturnSetResult()
{
Skip.IfNot(Test.RunsOnWindows);
Skip.If(FileSystem is RealFileSystem);
@@ -57,31 +58,31 @@ public void GetAccessControl_ShouldReturnSetResult()
FileSecurity result =
FileSystem.FileInfo.New("foo").GetAccessControl();
- #pragma warning restore CA1416
- result.Should().Be(originalResult);
+ await That(result).Should().Be(originalResult);
+ #pragma warning restore CA1416
}
[SkippableFact]
- public void
+ public async Task
GetAccessControl_WithAccessControlSections_MissingFile_ShouldThrowFileNotFoundException()
{
Skip.IfNot(Test.RunsOnWindows);
IFileInfo sut = FileSystem.FileInfo.New("foo");
- Exception? exception = Record.Exception(() =>
+ void Act()
{
#pragma warning disable CA1416
_ = sut.GetAccessControl(AccessControlSections.None);
#pragma warning restore CA1416
- });
+ }
- exception.Should().BeOfType()
- .Which.HResult.Should().Be(-2147024894);
+ await That(Act).Should().Throw()
+ .WithHResult(-2147024894);
}
[SkippableFact]
- public void GetAccessControl_WithAccessControlSections_ShouldBeInitializedWithNotNullValue()
+ public async Task GetAccessControl_WithAccessControlSections_ShouldBeInitializedWithNotNullValue()
{
Skip.IfNot(Test.RunsOnWindows);
SkipIfLongRunningTestsShouldBeSkipped();
@@ -91,13 +92,13 @@ public void GetAccessControl_WithAccessControlSections_ShouldBeInitializedWithNo
#pragma warning disable CA1416
FileSecurity result = fileInfo.GetAccessControl(AccessControlSections.None);
- #pragma warning restore CA1416
- result.Should().NotBeNull();
+ await That(result).Should().NotBeNull();
+ #pragma warning restore CA1416
}
[SkippableFact]
- public void GetAccessControl_WithAccessControlSections_ShouldReturnSetResult()
+ public async Task GetAccessControl_WithAccessControlSections_ShouldReturnSetResult()
{
Skip.IfNot(Test.RunsOnWindows);
Skip.If(FileSystem is RealFileSystem);
@@ -112,13 +113,13 @@ public void GetAccessControl_WithAccessControlSections_ShouldReturnSetResult()
FileSecurity result =
FileSystem.FileInfo.New("foo").GetAccessControl(AccessControlSections.None);
- #pragma warning restore CA1416
- result.Should().Be(originalResult);
+ await That(result).Should().Be(originalResult);
+ #pragma warning restore CA1416
}
[SkippableFact]
- public void SetAccessControl_ShouldChangeAccessControl()
+ public async Task SetAccessControl_ShouldChangeAccessControl()
{
Skip.IfNot(Test.RunsOnWindows);
@@ -132,7 +133,7 @@ public void SetAccessControl_ShouldChangeAccessControl()
.GetAccessControl(AccessControlSections.Access);
#pragma warning restore CA1416
- currentAccessControl.HasSameAccessRightsAs(originalAccessControl)
+ await That(currentAccessControl.HasSameAccessRightsAs(originalAccessControl))
.Should().BeTrue();
}
}
diff --git a/Tests/Testably.Abstractions.AccessControl.Tests/FileStreamAclExtensionsTests.cs b/Tests/Testably.Abstractions.AccessControl.Tests/FileStreamAclExtensionsTests.cs
index d4600e48e..88302c9f7 100644
--- a/Tests/Testably.Abstractions.AccessControl.Tests/FileStreamAclExtensionsTests.cs
+++ b/Tests/Testably.Abstractions.AccessControl.Tests/FileStreamAclExtensionsTests.cs
@@ -1,5 +1,6 @@
using System.Security.AccessControl;
using Testably.Abstractions.AccessControl.Tests.TestHelpers;
+using Skip = Xunit.Skip;
namespace Testably.Abstractions.AccessControl.Tests;
@@ -9,7 +10,7 @@ public abstract partial class FileStreamAclExtensionsTests
where TFileSystem : IFileSystem
{
[SkippableFact]
- public void GetAccessControl_ShouldBeInitializedWithNotNullValue()
+ public async Task GetAccessControl_ShouldBeInitializedWithNotNullValue()
{
Skip.IfNot(Test.RunsOnWindows);
@@ -17,13 +18,13 @@ public void GetAccessControl_ShouldBeInitializedWithNotNullValue()
#pragma warning disable CA1416
FileSecurity result = fileStream.GetAccessControl();
- #pragma warning restore CA1416
- result.Should().NotBeNull();
+ await That(result).Should().NotBeNull();
+ #pragma warning restore CA1416
}
[SkippableFact]
- public void SetAccessControl_ShouldChangeAccessControl()
+ public async Task SetAccessControl_ShouldChangeAccessControl()
{
Skip.IfNot(Test.RunsOnWindows);
@@ -35,7 +36,7 @@ public void SetAccessControl_ShouldChangeAccessControl()
FileSecurity currentAccessControl = fileStream.GetAccessControl();
#pragma warning restore CA1416
- currentAccessControl.HasSameAccessRightsAs(originalAccessControl)
+ await That(currentAccessControl.HasSameAccessRightsAs(originalAccessControl))
.Should().BeTrue();
}
}
diff --git a/Tests/Testably.Abstractions.AccessControl.Tests/Internal/AccessControlHelperTests.cs b/Tests/Testably.Abstractions.AccessControl.Tests/Internal/AccessControlHelperTests.cs
index d7003e2d4..adca9e15a 100644
--- a/Tests/Testably.Abstractions.AccessControl.Tests/Internal/AccessControlHelperTests.cs
+++ b/Tests/Testably.Abstractions.AccessControl.Tests/Internal/AccessControlHelperTests.cs
@@ -7,110 +7,107 @@ public sealed class AccessControlHelperTests
{
[Theory]
[AutoDomainData]
- public void GetExtensibilityOrThrow_CustomDirectoryInfo_ShouldThrowNotSupportedException(IDirectoryInfo sut)
+ public async Task GetExtensibilityOrThrow_CustomDirectoryInfo_ShouldThrowNotSupportedException(
+ IDirectoryInfo sut)
{
- Exception? exception = Record.Exception(() =>
+ void Act()
{
sut.GetExtensibilityOrThrow();
- });
+ }
- exception.Should().BeOfType()
- .Which.Message.Should()
- .Contain(nameof(IFileSystemExtensibility)).And
- .Contain(sut.GetType().Name);
+ await That(Act).Should().Throw()
+ .WithMessage($"*{sut.GetType().Name}*{nameof(IFileSystemExtensibility)}*").AsWildcard();
}
[Theory]
[AutoDomainData]
- public void GetExtensibilityOrThrow_CustomFileInfo_ShouldThrowNotSupportedException(IFileInfo sut)
+ public async Task GetExtensibilityOrThrow_CustomFileInfo_ShouldThrowNotSupportedException(
+ IFileInfo sut)
{
- Exception? exception = Record.Exception(() =>
+ void Act()
{
sut.GetExtensibilityOrThrow();
- });
+ }
- exception.Should().BeOfType()
- .Which.Message.Should()
- .Contain(nameof(IFileSystemExtensibility)).And
- .Contain(sut.GetType().Name);
+ await That(Act).Should().Throw()
+ .WithMessage($"*{sut.GetType().Name}*{nameof(IFileSystemExtensibility)}*").AsWildcard();
}
[Fact]
- public void GetExtensibilityOrThrow_CustomFileSystemStream_ShouldThrowNotSupportedException()
+ public async Task
+ GetExtensibilityOrThrow_CustomFileSystemStream_ShouldThrowNotSupportedException()
{
FileSystemStream sut = new CustomFileSystemStream();
- Exception? exception = Record.Exception(() =>
+ void Act()
{
sut.GetExtensibilityOrThrow();
- });
+ }
- exception.Should().BeOfType()
- .Which.Message.Should()
- .Contain(nameof(IFileSystemExtensibility)).And
- .Contain(sut.GetType().Name);
+ await That(Act).Should().Throw()
+ .WithMessage($"*{sut.GetType().Name}*{nameof(IFileSystemExtensibility)}*").AsWildcard();
}
[Fact]
- public void ThrowIfMissing_ExistingDirectoryInfo_ShouldNotThrow()
+ public async Task ThrowIfMissing_ExistingDirectoryInfo_ShouldNotThrow()
{
MockFileSystem fileSystem = new();
IDirectoryInfo sut = fileSystem.DirectoryInfo.New("foo");
fileSystem.Directory.CreateDirectory("foo");
- Exception? exception = Record.Exception(() =>
+ void Act()
{
sut.ThrowIfMissing();
- });
+ }
- exception.Should().BeNull();
+ await That(Act).Should().NotThrow();
}
[Fact]
- public void ThrowIfMissing_ExistingFileInfo_ShouldNotThrow()
+ public async Task ThrowIfMissing_ExistingFileInfo_ShouldNotThrow()
{
MockFileSystem fileSystem = new();
IFileInfo sut = fileSystem.FileInfo.New("foo");
fileSystem.File.WriteAllText("foo", "some content");
- Exception? exception = Record.Exception(() =>
+ void Act()
{
sut.ThrowIfMissing();
- });
+ }
- exception.Should().BeNull();
+ await That(Act).Should().NotThrow();
}
[Fact]
- public void ThrowIfMissing_MissingDirectoryInfo_ShouldThrowDirectoryNotFoundException()
+ public async Task ThrowIfMissing_MissingDirectoryInfo_ShouldThrowDirectoryNotFoundException()
{
MockFileSystem fileSystem = new();
IDirectoryInfo sut = fileSystem.DirectoryInfo.New("foo");
- Exception? exception = Record.Exception(() =>
+ void Act()
{
sut.ThrowIfMissing();
- });
+ }
- exception.Should().BeOfType()
- .Which.HResult.Should().Be(-2147024893);
- exception!.Message.Should().Contain($"'{sut.FullName}'");
+ await That(Act).Should().Throw()
+ .WithHResult(-2147024893).And
+ .WithMessage($"*'{sut.FullName}'*").AsWildcard();
}
[Fact]
- public void ThrowIfMissing_MissingFileInfo_ShouldThrowFileNotFoundException()
+ public async Task ThrowIfMissing_MissingFileInfo_ShouldThrowFileNotFoundException()
{
MockFileSystem fileSystem = new();
IFileInfo sut = fileSystem.FileInfo.New("foo");
- Exception? exception = Record.Exception(() =>
+ void Act()
{
sut.ThrowIfMissing();
- });
+ }
- exception.Should().BeOfType()
- .Which.HResult.Should().Be(-2147024894);
- exception!.Message.Should().Contain($"'{sut.FullName}'");
+ await That(Act).Should().Throw()
+ .WithHResult(-2147024894).And
+ .WithMessage($"*'{sut.FullName}'*").AsWildcard();
}
private sealed class CustomFileSystemStream() : FileSystemStream(Null, ".", false);
diff --git a/Tests/Testably.Abstractions.AccessControl.Tests/TestHelpers/Usings.cs b/Tests/Testably.Abstractions.AccessControl.Tests/TestHelpers/Usings.cs
index fde8d98e7..09bda3676 100644
--- a/Tests/Testably.Abstractions.AccessControl.Tests/TestHelpers/Usings.cs
+++ b/Tests/Testably.Abstractions.AccessControl.Tests/TestHelpers/Usings.cs
@@ -1,7 +1,9 @@
-global using FluentAssertions;
-global using System;
+global using System;
+global using System.Threading.Tasks;
global using System.IO.Abstractions;
global using Testably.Abstractions.TestHelpers;
// ReSharper disable once RedundantUsingDirective.Global
global using Testably.Abstractions.Testing;
global using Xunit;
+global using aweXpect;
+global using static aweXpect.Expect;
diff --git a/Tests/Testably.Abstractions.Compression.Tests/Testably.Abstractions.Compression.Tests.csproj b/Tests/Testably.Abstractions.Compression.Tests/Testably.Abstractions.Compression.Tests.csproj
index 2fcc4e1be..354a76635 100644
--- a/Tests/Testably.Abstractions.Compression.Tests/Testably.Abstractions.Compression.Tests.csproj
+++ b/Tests/Testably.Abstractions.Compression.Tests/Testably.Abstractions.Compression.Tests.csproj
@@ -13,6 +13,7 @@
+
diff --git a/Tests/Testably.Abstractions.Parity.Tests/ParityTests.cs b/Tests/Testably.Abstractions.Parity.Tests/ParityTests.cs
index d7a0980f6..31929ec8b 100644
--- a/Tests/Testably.Abstractions.Parity.Tests/ParityTests.cs
+++ b/Tests/Testably.Abstractions.Parity.Tests/ParityTests.cs
@@ -2,6 +2,7 @@
using System.IO;
using System.IO.Compression;
using System.Threading;
+using System.Threading.Tasks;
using Testably.Abstractions.RandomSystem;
using Testably.Abstractions.TimeSystem;
using Xunit.Abstractions;
@@ -20,73 +21,73 @@ public abstract class ParityTests(
#endregion
[Fact]
- public void IDirectory_EnsureParityWith_Directory()
+ public async Task IDirectory_EnsureParityWith_Directory()
{
List parityErrors = Parity.Directory
.GetErrorsToStaticType(
typeof(Directory),
testOutputHelper);
- parityErrors.Should().BeEmpty();
+ await That(parityErrors).Should().BeEmpty();
}
[Fact]
- public void IDirectoryInfoAndIDirectoryInfoFactory_EnsureParityWith_DirectoryInfo()
+ public async Task IDirectoryInfoAndIDirectoryInfoFactory_EnsureParityWith_DirectoryInfo()
{
List parityErrors = Parity.DirectoryInfo
.GetErrorsToInstanceType(
typeof(DirectoryInfo),
testOutputHelper);
- parityErrors.Should().BeEmpty();
+ await That(parityErrors).Should().BeEmpty();
}
[Fact]
- public void IDriveInfoAndIDriveInfoFactory_EnsureParityWith_DriveInfo()
+ public async Task IDriveInfoAndIDriveInfoFactory_EnsureParityWith_DriveInfo()
{
List parityErrors = Parity.Drive
.GetErrorsToInstanceType(
typeof(DriveInfo),
testOutputHelper);
- parityErrors.Should().BeEmpty();
+ await That(parityErrors).Should().BeEmpty();
}
[Fact]
- public void IFile_EnsureParityWith_File()
+ public async Task IFile_EnsureParityWith_File()
{
List parityErrors = Parity.File
.GetErrorsToStaticType(
typeof(File),
testOutputHelper);
- parityErrors.Should().BeEmpty();
+ await That(parityErrors).Should().BeEmpty();
}
[Fact]
- public void IFileInfoAndIFileInfoFactory_EnsureParityWith_FileInfo()
+ public async Task IFileInfoAndIFileInfoFactory_EnsureParityWith_FileInfo()
{
List parityErrors = Parity.FileInfo
.GetErrorsToInstanceType(
typeof(FileInfo),
testOutputHelper);
- parityErrors.Should().BeEmpty();
+ await That(parityErrors).Should().BeEmpty();
}
[Fact]
- public void IFileSystemInfo_EnsureParityWith_FileSystemInfo()
+ public async Task IFileSystemInfo_EnsureParityWith_FileSystemInfo()
{
List parityErrors = Parity.FileSystemInfo
.GetErrorsToInstanceType(
typeof(FileSystemInfo),
testOutputHelper);
- parityErrors.Should().BeEmpty();
+ await That(parityErrors).Should().BeEmpty();
}
[Fact]
- public void
+ public async Task
IFileSystemWatcherAndIFileSystemWatcherFactory_EnsureParityWith_FileSystemWatcher()
{
List parityErrors = Parity.FileSystemWatcher
@@ -94,44 +95,44 @@ public void
typeof(FileSystemWatcher),
testOutputHelper);
- parityErrors.Should().BeEmpty();
+ await That(parityErrors).Should().BeEmpty();
}
[Fact]
- public void IGuid_EnsureParityWith_Guid()
+ public async Task IGuid_EnsureParityWith_Guid()
{
List parityErrors = Parity.Guid
.GetErrorsToStaticType(
typeof(Guid),
testOutputHelper);
- parityErrors.Should().BeEmpty();
+ await That(parityErrors).Should().BeEmpty();
}
[Fact]
- public void IPath_EnsureParityWith_Path()
+ public async Task IPath_EnsureParityWith_Path()
{
List parityErrors = Parity.Path
.GetErrorsToStaticType(
typeof(Path),
testOutputHelper);
- parityErrors.Should().BeEmpty();
+ await That(parityErrors).Should().BeEmpty();
}
[Fact]
- public void IRandomAndIRandomFactory_EnsureParityWith_Random()
+ public async Task IRandomAndIRandomFactory_EnsureParityWith_Random()
{
List parityErrors = Parity.Random
.GetErrorsToInstanceType(
typeof(Random),
testOutputHelper);
- parityErrors.Should().BeEmpty();
+ await That(parityErrors).Should().BeEmpty();
}
[Fact]
- public void
+ public async Task
ITimerAndITimerFactory_EnsureParityWith_Timer()
{
List parityErrors = Parity.Timer
@@ -139,61 +140,61 @@ public void
typeof(Timer),
testOutputHelper);
- parityErrors.Should().BeEmpty();
+ await That(parityErrors).Should().BeEmpty();
}
[Fact]
- public void IZipArchive_EnsureParityWith_ZipArchive()
+ public async Task IZipArchive_EnsureParityWith_ZipArchive()
{
List parityErrors = Parity.ZipArchive
.GetErrorsToInstanceType(
typeof(ZipArchive),
testOutputHelper);
- parityErrors.Should().BeEmpty();
+ await That(parityErrors).Should().BeEmpty();
}
[Fact]
- public void IZipArchive_EnsureParityWith_ZipFileExtensions()
+ public async Task IZipArchive_EnsureParityWith_ZipFileExtensions()
{
List parityErrors = Parity.ZipArchive
.GetErrorsToExtensionMethods(
typeof(ZipFileExtensions),
testOutputHelper);
- parityErrors.Should().BeEmpty();
+ await That(parityErrors).Should().BeEmpty();
}
[Fact]
- public void IZipArchiveEntry_EnsureParityWith_ZipArchiveEntry()
+ public async Task IZipArchiveEntry_EnsureParityWith_ZipArchiveEntry()
{
List parityErrors = Parity.ZipArchiveEntry
.GetErrorsToInstanceType(
typeof(ZipArchiveEntry),
testOutputHelper);
- parityErrors.Should().BeEmpty();
+ await That(parityErrors).Should().BeEmpty();
}
[Fact]
- public void IZipArchiveEntry_EnsureParityWith_ZipFileExtensions()
+ public async Task IZipArchiveEntry_EnsureParityWith_ZipFileExtensions()
{
List parityErrors = Parity.ZipArchiveEntry
.GetErrorsToExtensionMethods(
typeof(ZipFileExtensions),
testOutputHelper);
- parityErrors.Should().BeEmpty();
+ await That(parityErrors).Should().BeEmpty();
}
[Fact]
- public void IZipFile_EnsureParityWith_ZipFile()
+ public async Task IZipFile_EnsureParityWith_ZipFile()
{
List parityErrors = Parity.ZipFile
.GetErrorsToStaticType(
typeof(ZipFile),
testOutputHelper);
- parityErrors.Should().BeEmpty();
+ await That(parityErrors).Should().BeEmpty();
}
}
diff --git a/Tests/Testably.Abstractions.Parity.Tests/TestHelpers/Usings.cs b/Tests/Testably.Abstractions.Parity.Tests/TestHelpers/Usings.cs
index 6008ebd08..d94e613d6 100644
--- a/Tests/Testably.Abstractions.Parity.Tests/TestHelpers/Usings.cs
+++ b/Tests/Testably.Abstractions.Parity.Tests/TestHelpers/Usings.cs
@@ -1,4 +1,5 @@
-global using FluentAssertions;
-global using System;
+global using System;
global using System.IO.Abstractions;
global using Xunit;
+global using aweXpect;
+global using static aweXpect.Expect;
diff --git a/Tests/Testably.Abstractions.Testing.Tests/Testably.Abstractions.Testing.Tests.csproj b/Tests/Testably.Abstractions.Testing.Tests/Testably.Abstractions.Testing.Tests.csproj
index 2f4a934c6..d8ec3c937 100644
--- a/Tests/Testably.Abstractions.Testing.Tests/Testably.Abstractions.Testing.Tests.csproj
+++ b/Tests/Testably.Abstractions.Testing.Tests/Testably.Abstractions.Testing.Tests.csproj
@@ -22,6 +22,7 @@
+
diff --git a/Tests/Testably.Abstractions.Tests/Testably.Abstractions.Tests.csproj b/Tests/Testably.Abstractions.Tests/Testably.Abstractions.Tests.csproj
index e23bf8b43..543822ead 100644
--- a/Tests/Testably.Abstractions.Tests/Testably.Abstractions.Tests.csproj
+++ b/Tests/Testably.Abstractions.Tests/Testably.Abstractions.Tests.csproj
@@ -12,6 +12,7 @@
+