diff --git a/Directory.Build.props b/Directory.Build.props index 1c63103cd..cfad8118f 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -6,7 +6,7 @@ https://github.com/Testably/Testably.Abstractions.git git - + $(MSBuildThisFileDirectory)/strongname.snk True diff --git a/Directory.Packages.props b/Directory.Packages.props index 1b78ec787..7270caa0b 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -5,18 +5,20 @@ - + + + @@ -31,20 +33,19 @@ + + - - + - - - - + + + + - - - + diff --git a/Pipeline/Build.ApiChecks.cs b/Pipeline/Build.ApiChecks.cs index 79535423a..ee5411de6 100644 --- a/Pipeline/Build.ApiChecks.cs +++ b/Pipeline/Build.ApiChecks.cs @@ -25,14 +25,13 @@ partial class Build }; DotNetTest(s => s - .SetConfiguration(Configuration) - .SetProcessEnvironmentVariable("DOTNET_CLI_UI_LANGUAGE", "en-US") - .SetResultsDirectory(TestResultsDirectory) - .CombineWith( - projects, - (settings, project) => settings - .SetProjectFile(project) - .AddLoggers($"trx;LogFileName={project.Name}.trx")), - completeOnFailure: true); + .SetConfiguration(Configuration) + .SetProcessEnvironmentVariable("DOTNET_CLI_UI_LANGUAGE", "en-US") + .SetResultsDirectory(TestResultsDirectory) + .CombineWith( + projects, + (settings, project) => settings + .AddProcessAdditionalArguments( + $"--project \"{project.Path}\" -- --report-trx"))); }); } diff --git a/Pipeline/Build.CodeCoverage.cs b/Pipeline/Build.CodeCoverage.cs index 03956d850..44e6cb016 100644 --- a/Pipeline/Build.CodeCoverage.cs +++ b/Pipeline/Build.CodeCoverage.cs @@ -18,7 +18,7 @@ partial class Build .SetProcessToolPath(NuGetToolPathResolver.GetPackageExecutable("ReportGenerator", "ReportGenerator.dll", framework: "net8.0")) .SetTargetDirectory(TestResultsDirectory / "reports") - .AddReports(TestResultsDirectory / "**/coverage.cobertura.xml") + .AddReports(TestResultsDirectory / "**/*.cobertura.xml") .AddReportTypes(ReportTypes.OpenCover) .AddFileFilters("-*.g.cs") .SetAssemblyFilters("+Testably*")); diff --git a/Pipeline/Build.MutationTests.cs b/Pipeline/Build.MutationTests.cs index 4e5b64a60..841693445 100644 --- a/Pipeline/Build.MutationTests.cs +++ b/Pipeline/Build.MutationTests.cs @@ -142,7 +142,7 @@ await gitHubClient.Issue.Comment.Update("Testably", "Testably.Abstractions", {{string.Join(",\n\t\t\t", project.Value.Select(PathForJson))}} ], "project": {{PathForJson(project.Key)}}, - "target-framework": "net8.0", + "target-framework": "net10.0", "since": { "target": "main", "enabled": {{(GitVersion?.BranchName != "main").ToString().ToLowerInvariant()}}, @@ -259,7 +259,7 @@ await gitHubClient.Issue.Comment.Update("Testably", "Testably.Abstractions", {{string.Join(",\n\t\t\t", project.Value.Select(PathForJson))}} ], "project": {{PathForJson(project.Key)}}, - "target-framework": "net8.0", + "target-framework": "net10.0", "since": { "target": "main", "enabled": {{(GitVersion?.BranchName != "main").ToString().ToLowerInvariant()}}, @@ -280,8 +280,8 @@ await gitHubClient.Issue.Comment.Update("Testably", "Testably.Abstractions", Log.Debug($"Created '{configFile}':{Environment.NewLine}{configText}"); string arguments = IsServerBuild - ? $"-f \"{configFile}\" -O \"{StrykerOutputDirectory}\" -r \"Markdown\" -r \"Dashboard\" -r \"cleartext\"" - : $"-f \"{configFile}\" -O \"{StrykerOutputDirectory}\" -r \"Markdown\" -r \"cleartext\""; + ? $"-f \"{configFile}\" -O \"{StrykerOutputDirectory}\" -r \"Markdown\" -r \"Dashboard\" -r \"cleartext\" --test-runner mtp" + : $"-f \"{configFile}\" -O \"{StrykerOutputDirectory}\" -r \"Markdown\" -r \"cleartext\" --test-runner mtp"; string executable = EnvironmentInfo.IsWin ? "dotnet-stryker.exe" : "dotnet-stryker"; IProcess process = ProcessTasks.StartProcess( diff --git a/Pipeline/Build.UnitTest.cs b/Pipeline/Build.UnitTest.cs index 0b3629be5..37eb7388f 100644 --- a/Pipeline/Build.UnitTest.cs +++ b/Pipeline/Build.UnitTest.cs @@ -32,18 +32,16 @@ partial class Build DotNetTest(s => s .SetConfiguration(Configuration) .SetProcessEnvironmentVariable("DOTNET_CLI_UI_LANGUAGE", "en-US") - .SetDataCollector("XPlat Code Coverage") .SetResultsDirectory(TestResultsDirectory) .CombineWith( UnitTestProjects, (settings, project) => settings - .SetProjectFile(project) .CombineWith( project.GetTargetFrameworks()?.Except(excludedFrameworks), (frameworkSettings, framework) => frameworkSettings .SetFramework(framework) - .AddLoggers( - $"trx;LogFileName={project.Name}_{framework}.trx") + .AddProcessAdditionalArguments( + $"--project \"{project.Path}\" -- --report-trx --coverage --coverage-output-format cobertura ") ) ), completeOnFailure: true ); diff --git a/README.md b/README.md index 78bc065d1..5a420fa3e 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ private string GetFileContent() Then you test your class with the mocked types in `Testably.Abstractions.Testing`: ```csharp -[Fact] +[Test] public void StoreData_ShouldWriteValidFile() { IFileSystem fileSystem = new MockFileSystem(); diff --git a/Testably.Abstractions.sln.DotSettings b/Testably.Abstractions.sln.DotSettings index f3da3e4a5..f133f7c18 100644 --- a/Testably.Abstractions.sln.DotSettings +++ b/Testably.Abstractions.sln.DotSettings @@ -459,6 +459,9 @@ True True True + True + False + False True True DisabledByUser @@ -475,4 +478,4 @@ True True True - \ No newline at end of file + diff --git a/Testably.Abstractions.slnx b/Testably.Abstractions.slnx index 3ff19b181..92d58e5c0 100644 --- a/Testably.Abstractions.slnx +++ b/Testably.Abstractions.slnx @@ -22,10 +22,6 @@ - - - - @@ -69,9 +65,6 @@ - - - diff --git a/Tests/Api/Directory.Build.props b/Tests/Api/Directory.Build.props deleted file mode 100644 index 2495c306c..000000000 --- a/Tests/Api/Directory.Build.props +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - net10.0 - - - - latest - disable - enable - false - 701;1702;CA1845 - - - - annotations - - - - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - diff --git a/Tests/Api/Testably.Abstractions.Api.Tests/ApiAcceptance.cs b/Tests/Api/Testably.Abstractions.Api.Tests/ApiAcceptance.cs index 0369b6be6..18391c15f 100644 --- a/Tests/Api/Testably.Abstractions.Api.Tests/ApiAcceptance.cs +++ b/Tests/Api/Testably.Abstractions.Api.Tests/ApiAcceptance.cs @@ -1,5 +1,7 @@ -using NUnit.Framework; +using aweXpect; +using TUnit; using System; +using System.Threading.Tasks; namespace Testably.Abstractions.Api.Tests; @@ -8,9 +10,9 @@ public sealed class ApiAcceptance /// /// Execute this test to update the expected public API to the current API surface. /// - [TestCase] + [Test] [Explicit] - public void AcceptApiChanges() + public async Task AcceptApiChanges() { string[] assemblyNames = [ @@ -30,6 +32,6 @@ public void AcceptApiChanges() } } - Assert.That(assemblyNames, Is.Not.Empty); + await Expect.That(assemblyNames).IsNotEmpty(); } } diff --git a/Tests/Api/Testably.Abstractions.Api.Tests/ApiApprovalTests.cs b/Tests/Api/Testably.Abstractions.Api.Tests/ApiApprovalTests.cs index 12f3ef46a..b517d09a8 100644 --- a/Tests/Api/Testably.Abstractions.Api.Tests/ApiApprovalTests.cs +++ b/Tests/Api/Testably.Abstractions.Api.Tests/ApiApprovalTests.cs @@ -1,5 +1,6 @@ -using NUnit.Framework; -using System.Collections; +using aweXpect; +using System.Collections.Generic; +using System.Threading.Tasks; namespace Testably.Abstractions.Api.Tests; @@ -10,65 +11,54 @@ namespace Testably.Abstractions.Api.Tests; /// public sealed class ApiApprovalTests { - [TestCaseSource(typeof(TargetFrameworksTheoryData))] - public void VerifyPublicApiForTestablyAbstractions(string framework) + public static IEnumerable TargetFrameworks() + => Helper.GetTargetFrameworks(); + + [Test] + [MethodDataSource(nameof(TargetFrameworks))] + public async Task VerifyPublicApiForTestablyAbstractions(string framework) { const string assemblyName = "Testably.Abstractions"; string publicApi = Helper.CreatePublicApi(framework, assemblyName); string expectedApi = Helper.GetExpectedApi(framework, assemblyName); - Assert.That(publicApi, Is.EqualTo(expectedApi)); + await Expect.That(publicApi).IsEqualTo(expectedApi); } - [TestCaseSource(typeof(TargetFrameworksTheoryData))] - public void VerifyPublicApiForTestablyAbstractionsAccessControl(string framework) + [Test] + [MethodDataSource(nameof(TargetFrameworks))] + public async Task VerifyPublicApiForTestablyAbstractionsAccessControl(string framework) { const string assemblyName = "Testably.Abstractions.AccessControl"; string publicApi = Helper.CreatePublicApi(framework, assemblyName); string expectedApi = Helper.GetExpectedApi(framework, assemblyName); - Assert.That(publicApi, Is.EqualTo(expectedApi)); + await Expect.That(publicApi).IsEqualTo(expectedApi); } - [TestCaseSource(typeof(TargetFrameworksTheoryData))] - public void VerifyPublicApiForTestablyAbstractionsCompression(string framework) + [Test] + [MethodDataSource(nameof(TargetFrameworks))] + public async Task VerifyPublicApiForTestablyAbstractionsCompression(string framework) { const string assemblyName = "Testably.Abstractions.Compression"; string publicApi = Helper.CreatePublicApi(framework, assemblyName); string expectedApi = Helper.GetExpectedApi(framework, assemblyName); - Assert.That(publicApi, Is.EqualTo(expectedApi)); + await Expect.That(publicApi).IsEqualTo(expectedApi); } - [TestCaseSource(typeof(TargetFrameworksTheoryData))] - public void VerifyPublicApiForTestablyAbstractionsTesting(string framework) + [Test] + [MethodDataSource(nameof(TargetFrameworks))] + public async Task VerifyPublicApiForTestablyAbstractionsTesting(string framework) { const string assemblyName = "Testably.Abstractions.Testing"; string publicApi = Helper.CreatePublicApi(framework, assemblyName); string expectedApi = Helper.GetExpectedApi(framework, assemblyName); - Assert.That(publicApi, Is.EqualTo(expectedApi)); - } - - private sealed class TargetFrameworksTheoryData : IEnumerable - { - #region IEnumerable Members - - public IEnumerator GetEnumerator() - { - foreach (string targetFramework in Helper.GetTargetFrameworks()) - { - yield return new object[] - { - targetFramework - }; - } - } - - #endregion + await Expect.That(publicApi).IsEqualTo(expectedApi); } } diff --git a/Tests/Api/Testably.Abstractions.Api.Tests/Helper.cs b/Tests/Api/Testably.Abstractions.Api.Tests/Helper.cs index 206ec8c6f..d31419963 100644 --- a/Tests/Api/Testably.Abstractions.Api.Tests/Helper.cs +++ b/Tests/Api/Testably.Abstractions.Api.Tests/Helper.cs @@ -2,10 +2,10 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using System.Reflection; using System.Runtime.CompilerServices; using System.Xml.Linq; using System.Xml.XPath; +using Assembly = System.Reflection.Assembly; namespace Testably.Abstractions.Api.Tests; diff --git a/Tests/Api/Testably.Abstractions.Api.Tests/Testably.Abstractions.Api.Tests.csproj b/Tests/Api/Testably.Abstractions.Api.Tests/Testably.Abstractions.Api.Tests.csproj index 5f8c31b05..e411216d2 100644 --- a/Tests/Api/Testably.Abstractions.Api.Tests/Testably.Abstractions.Api.Tests.csproj +++ b/Tests/Api/Testably.Abstractions.Api.Tests/Testably.Abstractions.Api.Tests.csproj @@ -1,7 +1,12 @@  + + + net10.0 + + diff --git a/Tests/Api/Testably.Abstractions.Core.Api.Tests/ApiAcceptance.cs b/Tests/Api/Testably.Abstractions.Core.Api.Tests/ApiAcceptance.cs index 746e2913f..0b9119901 100644 --- a/Tests/Api/Testably.Abstractions.Core.Api.Tests/ApiAcceptance.cs +++ b/Tests/Api/Testably.Abstractions.Core.Api.Tests/ApiAcceptance.cs @@ -1,5 +1,6 @@ -using NUnit.Framework; +using aweXpect; using System; +using System.Threading.Tasks; namespace Testably.Abstractions.Core.Api.Tests; @@ -8,9 +9,9 @@ public sealed class ApiAcceptance /// /// Execute this test to update the expected public API to the current API surface. /// - [TestCase] + [Test] [Explicit] - public void AcceptApiChanges() + public async Task AcceptApiChanges() { string[] assemblyNames = [ @@ -28,6 +29,6 @@ public void AcceptApiChanges() } } - Assert.That(assemblyNames, Is.Not.Empty); + await Expect.That(assemblyNames).IsNotEmpty(); } } diff --git a/Tests/Api/Testably.Abstractions.Core.Api.Tests/ApiApprovalTests.cs b/Tests/Api/Testably.Abstractions.Core.Api.Tests/ApiApprovalTests.cs index 42290dcfa..c2ad8514d 100644 --- a/Tests/Api/Testably.Abstractions.Core.Api.Tests/ApiApprovalTests.cs +++ b/Tests/Api/Testably.Abstractions.Core.Api.Tests/ApiApprovalTests.cs @@ -1,5 +1,6 @@ -using NUnit.Framework; -using System.Collections; +using aweXpect; +using System.Collections.Generic; +using System.Threading.Tasks; namespace Testably.Abstractions.Core.Api.Tests; @@ -10,43 +11,30 @@ namespace Testably.Abstractions.Core.Api.Tests; /// public sealed class ApiApprovalTests { - [TestCaseSource(typeof(TargetFrameworksTheoryData))] - public void VerifyPublicApiForTestablyAbstractionsFileSystemInterface(string framework) + public static IEnumerable TargetFrameworks() + => Helper.GetTargetFrameworks(); + + [Test] + [MethodDataSource(nameof(TargetFrameworks))] + public async Task VerifyPublicApiForTestablyAbstractionsFileSystemInterface(string framework) { const string assemblyName = "Testably.Abstractions.FileSystem.Interface"; string publicApi = Helper.CreatePublicApi(framework, assemblyName); string expectedApi = Helper.GetExpectedApi(framework, assemblyName); - Assert.That(publicApi, Is.EqualTo(expectedApi)); + await Expect.That(publicApi).IsEqualTo(expectedApi); } - [TestCaseSource(typeof(TargetFrameworksTheoryData))] - public void VerifyPublicApiForTestablyAbstractionsInterface(string framework) + [Test] + [MethodDataSource(nameof(TargetFrameworks))] + public async Task VerifyPublicApiForTestablyAbstractionsInterface(string framework) { const string assemblyName = "Testably.Abstractions.Interface"; string publicApi = Helper.CreatePublicApi(framework, assemblyName); string expectedApi = Helper.GetExpectedApi(framework, assemblyName); - Assert.That(publicApi, Is.EqualTo(expectedApi)); - } - - private sealed class TargetFrameworksTheoryData : IEnumerable - { - #region IEnumerable Members - - public IEnumerator GetEnumerator() - { - foreach (string targetFramework in Helper.GetTargetFrameworks()) - { - yield return new object[] - { - targetFramework - }; - } - } - - #endregion + await Expect.That(publicApi).IsEqualTo(expectedApi); } } diff --git a/Tests/Api/Testably.Abstractions.Core.Api.Tests/Helper.cs b/Tests/Api/Testably.Abstractions.Core.Api.Tests/Helper.cs index 5356f63c1..2448c5afd 100644 --- a/Tests/Api/Testably.Abstractions.Core.Api.Tests/Helper.cs +++ b/Tests/Api/Testably.Abstractions.Core.Api.Tests/Helper.cs @@ -2,10 +2,10 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using System.Reflection; using System.Runtime.CompilerServices; using System.Xml.Linq; using System.Xml.XPath; +using Assembly = System.Reflection.Assembly; namespace Testably.Abstractions.Core.Api.Tests; diff --git a/Tests/Api/Testably.Abstractions.Core.Api.Tests/Testably.Abstractions.Core.Api.Tests.csproj b/Tests/Api/Testably.Abstractions.Core.Api.Tests/Testably.Abstractions.Core.Api.Tests.csproj index 871d4ade9..4787892b4 100644 --- a/Tests/Api/Testably.Abstractions.Core.Api.Tests/Testably.Abstractions.Core.Api.Tests.csproj +++ b/Tests/Api/Testably.Abstractions.Core.Api.Tests/Testably.Abstractions.Core.Api.Tests.csproj @@ -1,7 +1,12 @@  + + net10.0 + + + diff --git a/Tests/Directory.Build.props b/Tests/Directory.Build.props index d327bf774..2cea7909d 100644 --- a/Tests/Directory.Build.props +++ b/Tests/Directory.Build.props @@ -1,26 +1,23 @@ - + Condition="Exists('$(MSBuildThisFileDirectory)/../Directory.Build.props')"/> + - + net8.0;net9.0;net10.0;net48 net8.0;net9.0;net10.0 net48 - - net10.0 - - latest disable enable false Exe - $(NoWarn);701;1702;CA1845;MA0003;MA0004;MA0018;MA0020;MA0042;MA0076;xUnit1044;xUnit1045;NU1603 + $(NoWarn);701;1702;CA1845;MA0003;MA0004;MA0018;MA0020;MA0038;MA0042;MA0076;xUnit1045;NU1603;NU1608 + false @@ -28,23 +25,18 @@ - - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + all + runtime; build; native; contentfiles; analyzers - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - + + diff --git a/Tests/Helpers/Testably.Abstractions.TestHelpers/AssertionHelpers.cs b/Tests/Helpers/Testably.Abstractions.TestHelpers/AssertionHelpers.cs index 066b47314..4594495fe 100644 --- a/Tests/Helpers/Testably.Abstractions.TestHelpers/AssertionHelpers.cs +++ b/Tests/Helpers/Testably.Abstractions.TestHelpers/AssertionHelpers.cs @@ -1,12 +1,13 @@ -using aweXpect.Core; +#if NET8_0_OR_GREATER +using System.Diagnostics.CodeAnalysis; +#endif +using aweXpect.Core; using aweXpect.Core.Constraints; using aweXpect.Core.Sources; using aweXpect.Delegates; using aweXpect.Formatting; using System; -using System.Diagnostics.CodeAnalysis; using System.IO; -using System.Linq; using System.Text; using static aweXpect.Delegates.ThatDelegate; @@ -15,16 +16,20 @@ namespace Testably.Abstractions.TestHelpers; public static class AssertionHelpers { /// - /// Verifies that the throws either a or - /// a with their corresponding HResult values. + /// Verifies that the throws either a or + /// a with their corresponding HResult values. /// - public static ThatDelegateThrows ThrowsAFileOrDirectoryNotFoundException(this ThatDelegate @delegate) + public static ThatDelegateThrows ThrowsAFileOrDirectoryNotFoundException( + this ThatDelegate @delegate) { - var throwOptions = new ThatDelegate.ThrowsOption(); + ThrowsOption? throwOptions = new(); return new ThatDelegateThrows( - @delegate.ExpectationBuilder.AddConstraint((it, grammars) => new DelegateIsNotNullWithinTimeoutConstraint(it, grammars, throwOptions)) + @delegate.ExpectationBuilder.AddConstraint((it, grammars) + => new DelegateIsNotNullWithinTimeoutConstraint(it, grammars, throwOptions)) .ForWhich(d => d.Exception) - .AddConstraint((it, grammars) => new ThrowsAFileOrDirectoryNotFoundExceptionConstraint(it, grammars, throwOptions)) + .AddConstraint((it, grammars) + => new ThrowsAFileOrDirectoryNotFoundExceptionConstraint(it, grammars, + throwOptions)) .And(" "), throwOptions); } @@ -37,6 +42,14 @@ private sealed class DelegateIsNotNullWithinTimeoutConstraint( { private DelegateValue? _actual; + #region IValueConstraint Members + + public override void AppendExpectation(StringBuilder stringBuilder, + string? indentation = null) + { + // Do nothing + } + public ConstraintResult IsMetBy(DelegateValue value) { _actual = value; @@ -47,7 +60,7 @@ public ConstraintResult IsMetBy(DelegateValue value) } if (options.ExecutionTimeOptions is not null && - !options.ExecutionTimeOptions.IsWithinLimit(value.Duration)) + !options.ExecutionTimeOptions.IsWithinLimit(value.Duration)) { Outcome = Outcome.Failure; return this; @@ -57,10 +70,7 @@ public ConstraintResult IsMetBy(DelegateValue value) return this; } - public override void AppendExpectation(StringBuilder stringBuilder, string? indentation = null) - { - // Do nothing - } + #endregion public override void AppendResult(StringBuilder stringBuilder, string? indentation = null) { @@ -75,25 +85,54 @@ public override void AppendResult(StringBuilder stringBuilder, string? indentati } } - public override bool TryGetValue([NotNullWhen(true)] out TValue? value) where TValue : default + public override ConstraintResult Negate() + => this; + +#if NET8_0_OR_GREATER + public override bool TryGetValue([NotNullWhen(true)] out TValue? value) + where TValue : default +#else + #pragma warning disable CS8765 + public override bool TryGetValue(out TValue? value) where TValue : default + #pragma warning restore CS8765 +#endif { value = default; return false; } - - public override ConstraintResult Negate() - => this; } private sealed class ThrowsAFileOrDirectoryNotFoundExceptionConstraint( string it, ExpectationGrammars grammars, - ThatDelegate.ThrowsOption throwOptions) + ThrowsOption throwOptions) : ConstraintResult(grammars), IValueConstraint { private Exception? _actual; + #region IValueConstraint Members + + public override void AppendExpectation(StringBuilder stringBuilder, + string? indentation = null) + { + if (!throwOptions.DoCheckThrow) + { + stringBuilder.Append("does not throw any exception"); + } + else + { + stringBuilder.Append( + "throws a FileNotFoundException or a DirectoryNotFoundException with correct HResult"); + } + + if (throwOptions.ExecutionTimeOptions is not null) + { + stringBuilder.Append(' '); + throwOptions.ExecutionTimeOptions.AppendTo(stringBuilder, "in "); + } + } + /// public ConstraintResult IsMetBy(Exception? value) { @@ -111,8 +150,10 @@ public ConstraintResult IsMetBy(Exception? value) FurtherProcessingStrategy = FurtherProcessingStrategy.IgnoreResult; } - if (value is FileNotFoundException fileNotFoundException && fileNotFoundException.HResult == -2147024894 || - value is DirectoryNotFoundException directoryNotFoundException && directoryNotFoundException.HResult == -2147024893) + if ((value is FileNotFoundException fileNotFoundException && + fileNotFoundException.HResult == -2147024894) || + (value is DirectoryNotFoundException directoryNotFoundException && + directoryNotFoundException.HResult == -2147024893)) { Outcome = Outcome.Success; return this; @@ -122,23 +163,7 @@ public ConstraintResult IsMetBy(Exception? value) return this; } - public override void AppendExpectation(StringBuilder stringBuilder, string? indentation = null) - { - if (!throwOptions.DoCheckThrow) - { - stringBuilder.Append("does not throw any exception"); - } - else - { - stringBuilder.Append("throws a FileNotFoundException or a DirectoryNotFoundException with correct HResult"); - } - - if (throwOptions.ExecutionTimeOptions is not null) - { - stringBuilder.Append(' '); - throwOptions.ExecutionTimeOptions.AppendTo(stringBuilder, "in "); - } - } + #endregion public override void AppendResult(StringBuilder stringBuilder, string? indentation = null) { @@ -153,7 +178,20 @@ public override void AppendResult(StringBuilder stringBuilder, string? indentati } } - public override bool TryGetValue([NotNullWhen(true)] out TValue? value) where TValue : default + public override ConstraintResult Negate() + { + throwOptions.DoCheckThrow = !throwOptions.DoCheckThrow; + return this; + } + +#if NET8_0_OR_GREATER + public override bool TryGetValue([NotNullWhen(true)] out TValue? value) + where TValue : default +#else + #pragma warning disable CS8765 + public override bool TryGetValue(out TValue? value) where TValue : default + #pragma warning restore CS8765 +#endif { if (_actual is TValue typedValue) { @@ -165,12 +203,6 @@ public override void AppendResult(StringBuilder stringBuilder, string? indentati return typeof(TValue).IsAssignableFrom(typeof(DirectoryNotFoundException)); } - public override ConstraintResult Negate() - { - throwOptions.DoCheckThrow = !throwOptions.DoCheckThrow; - return this; - } - private static string FormatForMessage(Exception exception) { string message = PrependAOrAn(Format.Formatter.Format(exception.GetType())); @@ -181,7 +213,6 @@ private static string FormatForMessage(Exception exception) return message; - [return: NotNullIfNotNull(nameof(value))] static string? Indent(string? value, string? indentation = " ", bool indentFirstLine = true) { @@ -196,13 +227,17 @@ private static string FormatForMessage(Exception exception) } return (indentFirstLine ? indentation : "") - + value.Replace("\n", $"\n{indentation}"); + + value.Replace("\n", $"\n{indentation}"); } static string PrependAOrAn(string value) { char[] vocals = ['a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U',]; +#if NET8_0_OR_GREATER if (value.Length > 0 && vocals.Contains(value[0])) +#else + if (value.Length > 0 && vocals.Contains($"{value[0]}", StringComparison.Ordinal)) +#endif { return $"an {value}"; } diff --git a/Tests/Helpers/Testably.Abstractions.TestHelpers/AutoArguments.cs b/Tests/Helpers/Testably.Abstractions.TestHelpers/AutoArguments.cs new file mode 100644 index 000000000..421a1ecb7 --- /dev/null +++ b/Tests/Helpers/Testably.Abstractions.TestHelpers/AutoArguments.cs @@ -0,0 +1,55 @@ +using AutoFixture; +using AutoFixture.Kernel; +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Testably.Abstractions.TestHelpers; + +/// +/// Provides a data source for a data theory, with the data coming from inline +/// values combined with auto-generated data specimens generated by AutoFixture. +/// +public class AutoArgumentsAttribute : UntypedDataSourceGeneratorAttribute +{ + /// + /// Gets the fixture factory. + /// + private readonly Func _fixtureFactory; + + /// + /// Gets the data values to pass to the theory. + /// + private readonly object?[] _values; + + /// + /// Initializes a new instance of the class. + /// + public AutoArgumentsAttribute(params object?[] values) + : this(() => new Fixture(), values) + { + } + + /// + /// Initializes a new instance of the class. + /// + protected AutoArgumentsAttribute(Func fixtureFactory, params object?[]? values) + { + _fixtureFactory = fixtureFactory ?? throw new ArgumentNullException(nameof(fixtureFactory)); + _values = values ?? [null,]; + } + + /// + protected override IEnumerable> GenerateDataSources( + DataGeneratorMetadata dataGeneratorMetadata) + { + if (dataGeneratorMetadata.TestInformation is not null) + { + IFixture fixture = _fixtureFactory(); + yield return () + => _values.Concat(dataGeneratorMetadata.TestInformation.Parameters + .Skip(_values.Length) + .Select(x => fixture.Create(x.Type, new SpecimenContext(fixture)))).ToArray(); + } + } +} diff --git a/Tests/Helpers/Testably.Abstractions.TestHelpers/AutoDomainDataAttribute.cs b/Tests/Helpers/Testably.Abstractions.TestHelpers/AutoDomainDataAttribute.cs deleted file mode 100644 index 6eb9036df..000000000 --- a/Tests/Helpers/Testably.Abstractions.TestHelpers/AutoDomainDataAttribute.cs +++ /dev/null @@ -1,122 +0,0 @@ -using AutoFixture; -using AutoFixture.AutoNSubstitute; -using AutoFixture.Xunit3; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; - -namespace Testably.Abstractions.TestHelpers; - -/// -/// Extension of that uses applies domain-specific customizations. -/// -public class AutoDomainDataAttribute : AutoDataAttribute -{ - /// - /// Adds an additional that is applied for only this test. - /// - public Type? CustomizeWith - { - get; - set - { - field = value; - _fixtureFactory.CustomizeWith(value); - } - } - - private readonly DomainFixtureFactory _fixtureFactory; - - /// - /// Extension of that uses applies domain-specific customizations. - /// - public AutoDomainDataAttribute() : this(new DomainFixtureFactory()) - { - } - - private AutoDomainDataAttribute(DomainFixtureFactory fixtureFactory) - : base(fixtureFactory.GetFixtureFactory) - { - _fixtureFactory = fixtureFactory; - } - - private sealed class DomainFixtureFactory - { - private static Lazy _domainCustomisation { get; } = new(Initialize); - private ICustomization? _customizeWith; - - public void CustomizeWith(Type? type) - { - Type customizationInterface = typeof(ICustomization); - if (type != null && - customizationInterface.IsAssignableFrom(type)) - { - try - { - _customizeWith = (ICustomization?)Activator.CreateInstance(type); - } - catch (Exception ex) - { - throw new InvalidOperationException( - $"Could not instantiate customization with '{type.Name}'!", ex); - } - } - } - - public Fixture GetFixtureFactory() - { - Fixture fixture = new(); - fixture.Customize(new AutoNSubstituteCustomization()); - foreach (ICustomization domainCustomization in _domainCustomisation.Value) - { - domainCustomization.Customize(fixture); - } - - if (_customizeWith != null) - { - fixture.Customize(_customizeWith); - } - - return fixture; - } - - private static ICustomization[] Initialize() - { - List domainCustomizations = new(); - Type autoDataCustomizationInterface = typeof(IAutoDataCustomization); - foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies()) - { - try - { - foreach (Type type in assembly.GetTypes() - .Where(x => x.IsClass && - autoDataCustomizationInterface.IsAssignableFrom(x))) - { - try - { - IAutoDataCustomization? domainCustomization = - (IAutoDataCustomization?)Activator.CreateInstance(type); - if (domainCustomization != null) - { - domainCustomizations.Add(domainCustomization); - } - } - catch (Exception ex) - { - throw new InvalidOperationException( - $"Could not instantiate auto data customization '{type.Name}'!", - ex); - } - } - } - catch (ReflectionTypeLoadException) - { - // Ignore assemblies that can't be loaded - } - } - - return domainCustomizations.ToArray(); - } - } -} diff --git a/Tests/Helpers/Testably.Abstractions.TestHelpers/FileSystemTestBase.cs b/Tests/Helpers/Testably.Abstractions.TestHelpers/FileSystemTestBase.cs new file mode 100644 index 000000000..0281cfd20 --- /dev/null +++ b/Tests/Helpers/Testably.Abstractions.TestHelpers/FileSystemTestBase.cs @@ -0,0 +1,118 @@ +using System; +using System.IO.Abstractions; +using System.Threading; +using Testably.Abstractions.Testing.Initializer; + +namespace Testably.Abstractions.TestHelpers; + +[Retry(1)] +public abstract class FileSystemTestBase : IDisposable +{ + /// + /// The delay in milliseconds when wanting to ensure a timeout in the test. + /// + public const int EnsureTimeout = 500; + + /// + /// The delay in milliseconds when expecting a success in the test. + /// + public const int ExpectSuccess = 30000; + + /// + /// The delay in milliseconds when expecting a timeout in the test. + /// + public const int ExpectTimeout = 30; + + /// + /// The base path of the , which is used for all file system operations in the test. + /// + /// + /// It will be set to a random temporary path for each test, which is automatically cleaned up after the test + /// execution. You can use it to create files and directories for testing. It is guaranteed that the base path is empty + /// at the beginning of the test, so you can safely create files and directories without worrying about conflicts with + /// existing files or directories. + /// + public string BasePath { get; private set; } + + /// + /// A cancellation token that can be used to cancel the test execution when it takes too long. + /// + public CancellationToken CancellationToken { get; } + + /// + /// The file system to test. + /// + public IFileSystem FileSystem { get; } + + /// + /// The test environment used when simulating other operating systems. + /// + public Test Test { get; } + + /// + /// The time system associdated with the . + /// + public ITimeSystem TimeSystem { get; } + + private readonly IDirectoryCleaner _directoryCleaner; + + protected FileSystemTestBase(FileSystemTestData testData) + { + (FileSystem, TimeSystem) = testData.GetAbstractions(); + _directoryCleaner = testData.GetDirectoryCleaner(FileSystem); + BasePath = _directoryCleaner.BasePath; + Test = testData.GetTest(); + CancellationToken = TestContext.Current!.Execution.CancellationToken; + } + + #region IDisposable Members + + /// + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + #endregion + + /// + /// Specifies, if brittle tests should be skipped on the real file system. + /// + /// + /// (optional) A condition that must be for the test to be skipped on the + /// real file system. + /// + public static void SkipIfBrittleTestsShouldBeSkipped(bool condition = true) + { +#if DEBUG + Skip.If(Settings.BrittleTests == Settings.TestSettingStatus.AlwaysDisabled, + $"Brittle tests are {Settings.BrittleTests}. You can enable them by setting the corresponding settings in Testably.Abstractions.TestHelpers.Settings."); +#else + Skip.If(Settings.BrittleTests != Settings.TestSettingStatus.AlwaysEnabled, + $"Brittle tests are {Settings.BrittleTests}. You can enable them by setting the corresponding settings in Testably.Abstractions.TestHelpers.Settings."); +#endif + } + + /// + /// Specifies, if long-running tests should be skipped on the real file system. + /// + public static void SkipIfLongRunningTestsShouldBeSkipped() + { +#if DEBUG + Skip.If(Settings.LongRunningTests == Settings.TestSettingStatus.AlwaysDisabled, + $"Long-running tests are {Settings.LongRunningTests}. You can enable them by setting the corresponding settings in Testably.Abstractions.TestHelpers.Settings."); +#else + Skip.If(Settings.LongRunningTests != Settings.TestSettingStatus.AlwaysEnabled, + $"Long-running tests are {Settings.LongRunningTests}. You can enable them by setting the corresponding settings in Testably.Abstractions.TestHelpers.Settings."); +#endif + } + + protected virtual void Dispose(bool disposing) + { + if (disposing) + { + _directoryCleaner.Dispose(); + } + } +} diff --git a/Tests/Helpers/Testably.Abstractions.TestHelpers/FileSystemTestData.cs b/Tests/Helpers/Testably.Abstractions.TestHelpers/FileSystemTestData.cs new file mode 100644 index 000000000..056769f02 --- /dev/null +++ b/Tests/Helpers/Testably.Abstractions.TestHelpers/FileSystemTestData.cs @@ -0,0 +1,107 @@ +using System; +using System.IO.Abstractions; +using Testably.Abstractions.Testing; +using Testably.Abstractions.Testing.Initializer; +#if !NETFRAMEWORK +using System.Runtime.InteropServices; +#endif + +namespace Testably.Abstractions.TestHelpers; + +public abstract class FileSystemTestData +{ + private readonly string _testCase; + + protected FileSystemTestData(string testCase) + { + _testCase = testCase; + } + + public abstract (IFileSystem fileSystem, ITimeSystem) GetAbstractions(); + public abstract IDirectoryCleaner GetDirectoryCleaner(IFileSystem fileSystem); + public abstract Test GetTest(); + + /// + public override string ToString() + => _testCase; + + public class Mocked : FileSystemTestData + { +#if !NETFRAMEWORK + private readonly OSPlatform? _osPlatform; + private readonly SimulationMode? _simulationMode; +#endif + + public Mocked(string testCase) : base(testCase) + { + } + +#if !NETFRAMEWORK + public Mocked(SimulationMode? simulationMode, OSPlatform? osPlatform, string testCase) : + base(testCase) + { + _simulationMode = simulationMode; + _osPlatform = osPlatform; + } +#endif + + /// + public override (IFileSystem fileSystem, ITimeSystem) GetAbstractions() + { +#if NETFRAMEWORK + MockFileSystem fileSystem = new(); +#else + MockFileSystem fileSystem = _simulationMode is null + ? new MockFileSystem() + : new MockFileSystem(o => o.SimulatingOperatingSystem(_simulationMode.Value)); +#endif + ITimeSystem timeSystem = fileSystem.TimeSystem; + return (fileSystem, timeSystem); + } + + /// + public override IDirectoryCleaner GetDirectoryCleaner(IFileSystem fileSystem) + { + return fileSystem.SetCurrentDirectoryToEmptyTemporaryDirectory(); + } + +#if !NETFRAMEWORK + /// + public override Test GetTest() + => _osPlatform is null ? new Test() : new Test(_osPlatform.Value); +#else + /// + public override Test GetTest() + => new(); +#endif + } + + public class Real : FileSystemTestData + { + private readonly DataGeneratorMetadata _dataGeneratorMetadata; + + public Real(DataGeneratorMetadata dataGeneratorMetadata, + string testCase = "RealFileSystem") : base(testCase) + { + _dataGeneratorMetadata = dataGeneratorMetadata; + } + + /// + public override (IFileSystem fileSystem, ITimeSystem) GetAbstractions() + { + RealFileSystem fileSystem = new(); + RealTimeSystem timeSystem = new(); + return (fileSystem, timeSystem); + } + + /// + public override IDirectoryCleaner GetDirectoryCleaner(IFileSystem fileSystem) + => fileSystem.SetCurrentDirectoryToEmptyTemporaryDirectory( + $"{_dataGeneratorMetadata.TestInformation?.Class.Name}{fileSystem.Path.DirectorySeparatorChar}{_dataGeneratorMetadata.TestInformation?.Name ?? _dataGeneratorMetadata.TestSessionId}-", + Console.WriteLine); + + /// + public override Test GetTest() + => new(); + } +} diff --git a/Tests/Helpers/Testably.Abstractions.TestHelpers/FileSystemTestsAttribute.cs b/Tests/Helpers/Testably.Abstractions.TestHelpers/FileSystemTestsAttribute.cs new file mode 100644 index 000000000..c6e7b7dfa --- /dev/null +++ b/Tests/Helpers/Testably.Abstractions.TestHelpers/FileSystemTestsAttribute.cs @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Threading.Tasks; +using TUnit.Core.Interfaces; +#if !NETFRAMEWORK +using Testably.Abstractions.Testing; +#endif + +namespace Testably.Abstractions.TestHelpers; + +[AttributeUsage(AttributeTargets.Class)] +public class FileSystemTestsAttribute : TypedDataSourceAttribute, + ITestDiscoveryEventReceiver +{ +#if NET8_0_OR_GREATER + private static readonly ValueTask _completedTask = ValueTask.CompletedTask; +#else + private static readonly ValueTask _completedTask = new(Task.CompletedTask); +#endif + + #region ITestDiscoveryEventReceiver Members + + /// + public int Order { get; } = 0; + + /// + public ValueTask OnTestDiscovered(DiscoveredTestContext context) + { + if (context.TestContext.Metadata.TestDetails.TestClassArguments.Length > 0 && + context.TestContext.Metadata.TestDetails.TestClassArguments[0] is FileSystemTestData + .Real) + { + context.AddParallelConstraint(new NotInParallelConstraint(["RealFileSystem"])); + } + + return _completedTask; + } + + #endregion + + public override async IAsyncEnumerable>> GetTypedDataRowsAsync( + DataGeneratorMetadata dataGeneratorMetadata) + { + await Task.CompletedTask; + yield return () => Task.FromResult( + new FileSystemTestData.Mocked("MockFileSystem")); + +#if !NETFRAMEWORK + yield return () => Task.FromResult( + new FileSystemTestData.Mocked(SimulationMode.Linux, OSPlatform.Linux, + "LinuxFileSystem")); + + yield return () => Task.FromResult( + new FileSystemTestData.Mocked(SimulationMode.MacOS, OSPlatform.OSX, + "MacFileSystem")); + + yield return () => Task.FromResult( + new FileSystemTestData.Mocked(SimulationMode.Windows, OSPlatform.Windows, + "WindowsFileSystem")); +#endif + +#if DEBUG + if (Settings.RealFileSystemTests == Settings.TestSettingStatus.AlwaysEnabled) +#else + if (Settings.RealFileSystemTests != Settings.TestSettingStatus.AlwaysDisabled) +#endif + { + yield return () => Task.FromResult( + new FileSystemTestData.Real(dataGeneratorMetadata)); + } + } +} diff --git a/Tests/Helpers/Testably.Abstractions.TestHelpers/IAutoDataCustomization.cs b/Tests/Helpers/Testably.Abstractions.TestHelpers/IAutoDataCustomization.cs deleted file mode 100644 index 72dacba9c..000000000 --- a/Tests/Helpers/Testably.Abstractions.TestHelpers/IAutoDataCustomization.cs +++ /dev/null @@ -1,10 +0,0 @@ -using AutoFixture; - -namespace Testably.Abstractions.TestHelpers; - -/// -/// Marks customizations of that should always be applied when using the . -/// -public interface IAutoDataCustomization : ICustomization -{ -} diff --git a/Tests/Helpers/Testably.Abstractions.TestHelpers/RandomSystemTestBase.cs b/Tests/Helpers/Testably.Abstractions.TestHelpers/RandomSystemTestBase.cs new file mode 100644 index 000000000..a50fcea6a --- /dev/null +++ b/Tests/Helpers/Testably.Abstractions.TestHelpers/RandomSystemTestBase.cs @@ -0,0 +1,23 @@ +using System.Threading; + +namespace Testably.Abstractions.TestHelpers; + +[Retry(1)] +public abstract class RandomSystemTestBase +{ + /// + /// A cancellation token that can be used to cancel the test execution when it takes too long. + /// + public CancellationToken CancellationToken { get; } + + /// + /// The random system to test. + /// + public IRandomSystem RandomSystem { get; } + + protected RandomSystemTestBase(RandomSystemTestData testData) + { + RandomSystem = testData.RandomSystem; + CancellationToken = TestContext.Current!.Execution.CancellationToken; + } +} diff --git a/Tests/Helpers/Testably.Abstractions.TestHelpers/RandomSystemTestData.cs b/Tests/Helpers/Testably.Abstractions.TestHelpers/RandomSystemTestData.cs new file mode 100644 index 000000000..bb806e871 --- /dev/null +++ b/Tests/Helpers/Testably.Abstractions.TestHelpers/RandomSystemTestData.cs @@ -0,0 +1,13 @@ +namespace Testably.Abstractions.TestHelpers; + +public class RandomSystemTestData(IRandomSystem randomSystem) +{ + /// + /// The random system to test. + /// + public IRandomSystem RandomSystem { get; } = randomSystem; + + /// + public override string ToString() + => RandomSystem.GetType().Name; +} diff --git a/Tests/Helpers/Testably.Abstractions.TestHelpers/RandomSystemTestsAttribute.cs b/Tests/Helpers/Testably.Abstractions.TestHelpers/RandomSystemTestsAttribute.cs new file mode 100644 index 000000000..fbcaacb88 --- /dev/null +++ b/Tests/Helpers/Testably.Abstractions.TestHelpers/RandomSystemTestsAttribute.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Testably.Abstractions.Testing; + +namespace Testably.Abstractions.TestHelpers; + +[AttributeUsage(AttributeTargets.Class)] +public class RandomSystemTestsAttribute : TypedDataSourceAttribute +{ + public override async IAsyncEnumerable>> GetTypedDataRowsAsync( + DataGeneratorMetadata dataGeneratorMetadata) + { + await Task.CompletedTask; + yield return () => Task.FromResult( + new RandomSystemTestData(new MockRandomSystem())); + yield return () => Task.FromResult( + new RandomSystemTestData(new RealRandomSystem())); + } +} diff --git a/Tests/Helpers/Testably.Abstractions.TestHelpers/Record.cs b/Tests/Helpers/Testably.Abstractions.TestHelpers/Record.cs new file mode 100644 index 000000000..eaa702ed8 --- /dev/null +++ b/Tests/Helpers/Testably.Abstractions.TestHelpers/Record.cs @@ -0,0 +1,33 @@ +using System; +using System.Threading.Tasks; + +namespace Testably.Abstractions.TestHelpers; + +public static class Record +{ + public static Exception? Exception(Action action) + { + try + { + action(); + return null; + } + catch (Exception exception) + { + return exception; + } + } + + public static async Task ExceptionAsync(Func action) + { + try + { + await action(); + return null; + } + catch (Exception exception) + { + return exception; + } + } +} diff --git a/Tests/Helpers/Testably.Abstractions.TestHelpers/Settings/TestEnvironment.cs b/Tests/Helpers/Testably.Abstractions.TestHelpers/Settings.cs similarity index 55% rename from Tests/Helpers/Testably.Abstractions.TestHelpers/Settings/TestEnvironment.cs rename to Tests/Helpers/Testably.Abstractions.TestHelpers/Settings.cs index 634d6e28d..afff0d756 100644 --- a/Tests/Helpers/Testably.Abstractions.TestHelpers/Settings/TestEnvironment.cs +++ b/Tests/Helpers/Testably.Abstractions.TestHelpers/Settings.cs @@ -1,25 +1,43 @@ -namespace Testably.Abstractions.TestHelpers.Settings; +namespace Testably.Abstractions.TestHelpers; -public class TestEnvironment +public static class Settings { /// /// Affects some tests, that are brittle on the real file system. /// /// Per default, they are . - public TestSettingStatus BrittleTests { get; set; } + public static TestSettingStatus BrittleTests { get; set; } = TestSettingStatus.AlwaysDisabled; /// /// Affects some tests, that take a long time to run against the real file system (e.g. timeout). /// /// Per default, they are . - public TestSettingStatus LongRunningTests { get; set; } + public static TestSettingStatus LongRunningTests { get; set; } = TestSettingStatus.DisabledInDebugMode; /// /// Affects all tests against the real file system. /// /// Per default, they are . - public TestSettingStatus RealFileSystemTests { get; set; } + public static TestSettingStatus RealFileSystemTests { get; set; } = TestSettingStatus.DisabledInDebugMode; + + public enum TestSettingStatus + { + /// + /// The tests are always enabled. + /// + AlwaysEnabled, + + /// + /// The tests are only disabled in DEBUG mode. + /// + DisabledInDebugMode, + + /// + /// The tests are always disabled. + /// + AlwaysDisabled, + } } diff --git a/Tests/Helpers/Testably.Abstractions.TestHelpers/Settings/TestSettingStatus.cs b/Tests/Helpers/Testably.Abstractions.TestHelpers/Settings/TestSettingStatus.cs deleted file mode 100644 index 448f20dfd..000000000 --- a/Tests/Helpers/Testably.Abstractions.TestHelpers/Settings/TestSettingStatus.cs +++ /dev/null @@ -1,19 +0,0 @@ -namespace Testably.Abstractions.TestHelpers.Settings; - -public enum TestSettingStatus -{ - /// - /// The tests are always enabled. - /// - AlwaysEnabled, - - /// - /// The tests are only disabled in DEBUG mode. - /// - DisabledInDebugMode, - - /// - /// The tests are always disabled. - /// - AlwaysDisabled, -} diff --git a/Tests/Helpers/Testably.Abstractions.TestHelpers/Settings/TestSettingsFixture.cs b/Tests/Helpers/Testably.Abstractions.TestHelpers/Settings/TestSettingsFixture.cs deleted file mode 100644 index b4b0540f0..000000000 --- a/Tests/Helpers/Testably.Abstractions.TestHelpers/Settings/TestSettingsFixture.cs +++ /dev/null @@ -1,47 +0,0 @@ -using Newtonsoft.Json; -using System; -using System.IO; - -namespace Testably.Abstractions.TestHelpers.Settings; - -// ReSharper disable once UnusedMember.Global -public class TestSettingsFixture -{ - public TestSettingStatus BrittleTests { get; } - public TestSettingStatus LongRunningTests { get; } - public TestSettingStatus RealFileSystemTests { get; } - - public TestSettingsFixture() - { - TestEnvironment environment = LoadTestEnvironment(); - - RealFileSystemTests = environment.RealFileSystemTests; - LongRunningTests = environment.LongRunningTests; - BrittleTests = environment.BrittleTests; - } - - private static TestEnvironment LoadTestEnvironment() - { - try - { - string path = Path.GetFullPath( - Path.Combine("..", "..", "..", "..", "test.settings.json")); - if (File.Exists(path)) - { - string content = File.ReadAllText(path); - TestEnvironment? testEnvironment = - JsonConvert.DeserializeObject(content); - if (testEnvironment != null) - { - return testEnvironment; - } - } - } - catch (Exception) - { - // Ignore all exceptions while reading the test.settings.json file and use the default settings as fallback. - } - - return new TestEnvironment(); - } -} diff --git a/Tests/Helpers/Testably.Abstractions.TestHelpers/Skip.cs b/Tests/Helpers/Testably.Abstractions.TestHelpers/Skip.cs index 120093b6c..7ebc09128 100644 --- a/Tests/Helpers/Testably.Abstractions.TestHelpers/Skip.cs +++ b/Tests/Helpers/Testably.Abstractions.TestHelpers/Skip.cs @@ -1,53 +1,20 @@ using System.Runtime.CompilerServices; -namespace Testably.Abstractions.TestHelpers -{ +namespace Testably.Abstractions.TestHelpers; - public static class Skip +public static class Skip +{ + public static void If(bool condition, + [CallerArgumentExpression("condition")] + string reason = "") { - public static void IfNot(bool condition, - [CallerArgumentExpression("condition")] string reason = "") - { - aweXpect.Skip.Unless(condition, reason); - } - - public static void If(bool condition, - [CallerArgumentExpression("condition")] string reason = "") - { - aweXpect.Skip.When(condition, reason); - } + TUnit.Core.Skip.When(condition, reason); } -} - -#if !NET6_0_OR_GREATER -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -// ReSharper disable once CheckNamespace -namespace System.Runtime.CompilerServices -{ - /// - /// Indicates that a parameter captures the expression passed for another parameter as a string. - /// - [AttributeUsage(AttributeTargets.Parameter)] - [System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] - internal sealed class CallerArgumentExpressionAttribute : Attribute + public static void IfNot(bool condition, + [CallerArgumentExpression("condition")] + string reason = "") { - /// - /// Initializes a new instance of the class. - /// - /// The name of the parameter whose expression should be captured as a string. - public CallerArgumentExpressionAttribute(string parameterName) - { - ParameterName = parameterName; - } - - /// - /// Gets the name of the parameter whose expression should be captured as a string. - /// - public string ParameterName { get; } + TUnit.Core.Skip.Unless(condition, reason); } } - -#endif diff --git a/Tests/Helpers/Testably.Abstractions.TestHelpers/Testably.Abstractions.TestHelpers.csproj b/Tests/Helpers/Testably.Abstractions.TestHelpers/Testably.Abstractions.TestHelpers.csproj index 5b12efed4..31a77762b 100644 --- a/Tests/Helpers/Testably.Abstractions.TestHelpers/Testably.Abstractions.TestHelpers.csproj +++ b/Tests/Helpers/Testably.Abstractions.TestHelpers/Testably.Abstractions.TestHelpers.csproj @@ -7,20 +7,14 @@ - - + + + + - - - - - - - - - + diff --git a/Tests/Helpers/Testably.Abstractions.TestHelpers/TimeSystemTestBase.cs b/Tests/Helpers/Testably.Abstractions.TestHelpers/TimeSystemTestBase.cs new file mode 100644 index 000000000..46a72cbc4 --- /dev/null +++ b/Tests/Helpers/Testably.Abstractions.TestHelpers/TimeSystemTestBase.cs @@ -0,0 +1,67 @@ +using System; +using System.Threading; + +namespace Testably.Abstractions.TestHelpers; + +[Retry(1)] +public abstract class TimeSystemTestBase +{ + /// + /// The delay in milliseconds when wanting to ensure a timeout in the test. + /// + public const int EnsureTimeout = 500; + + /// + /// The delay in milliseconds when expecting a success in the test. + /// + public const int ExpectSuccess = 30000; + + /// + /// The delay in milliseconds when expecting a timeout in the test. + /// + public const int ExpectTimeout = 30; + + /// + /// The UTC time when the time system was created. + /// + public DateTime BeforeTime { get; set; } + + /// + /// A cancellation token that can be used to cancel the test execution when it takes too long. + /// + public CancellationToken CancellationToken { get; } + + /// + /// The time system to test. + /// + public ITimeSystem TimeSystem { get; } + + protected TimeSystemTestBase(TimeSystemTestData testData) + { + BeforeTime = testData.Now; + TimeSystem = testData.TimeSystem; + CancellationToken = TestContext.Current!.Execution.CancellationToken; + } + + /// + /// Specifies, if brittle tests should be skipped on the real time system. + /// + /// + /// (optional) A condition that must be for the test to be skipped on the + /// real time system. + /// + public void SkipIfBrittleTestsShouldBeSkipped(bool condition = true) + { + if (TimeSystem is RealTimeSystem) + { +#if DEBUG + aweXpect.Skip.When( + condition && Settings.BrittleTests == Settings.TestSettingStatus.AlwaysDisabled, + $"Brittle tests are {Settings.BrittleTests}. You can enable them by executing the corresponding tests in Testably.Abstractions.TestSettings.BrittleTests."); +#else + aweXpect.Skip.When(condition && Settings.BrittleTests != Settings.TestSettingStatus.AlwaysEnabled, + $"Brittle tests are {Settings.BrittleTests}. You can enable them by executing the corresponding tests in Testably.Abstractions.TestSettings.BrittleTests."); +#endif + } + } +} diff --git a/Tests/Helpers/Testably.Abstractions.TestHelpers/TimeSystemTestData.cs b/Tests/Helpers/Testably.Abstractions.TestHelpers/TimeSystemTestData.cs new file mode 100644 index 000000000..943c81fc3 --- /dev/null +++ b/Tests/Helpers/Testably.Abstractions.TestHelpers/TimeSystemTestData.cs @@ -0,0 +1,20 @@ +using System; + +namespace Testably.Abstractions.TestHelpers; + +public class TimeSystemTestData(DateTime now, ITimeSystem timeSystem) +{ + /// + /// The current date and time when creating the time system. + /// + public DateTime Now { get; } = now; + + /// + /// The time system to test. + /// + public ITimeSystem TimeSystem { get; } = timeSystem; + + /// + public override string ToString() + => TimeSystem.GetType().Name; +} diff --git a/Tests/Helpers/Testably.Abstractions.TestHelpers/TimeSystemTestsAttribute.cs b/Tests/Helpers/Testably.Abstractions.TestHelpers/TimeSystemTestsAttribute.cs new file mode 100644 index 000000000..71a45e3b4 --- /dev/null +++ b/Tests/Helpers/Testably.Abstractions.TestHelpers/TimeSystemTestsAttribute.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Testably.Abstractions.Testing; +using TimeProvider = Testably.Abstractions.Testing.TimeProvider; + +namespace Testably.Abstractions.TestHelpers; + +[AttributeUsage(AttributeTargets.Class)] +public class TimeSystemTestsAttribute : TypedDataSourceAttribute +{ + public override async IAsyncEnumerable>> GetTypedDataRowsAsync( + DataGeneratorMetadata dataGeneratorMetadata) + { + await Task.CompletedTask; + yield return () => + { + DateTime now = DateTime.UtcNow; + return Task.FromResult( + new TimeSystemTestData(now, new MockTimeSystem(TimeProvider.Use(now)))); + }; + yield return () => Task.FromResult( + new TimeSystemTestData(DateTime.UtcNow, new RealTimeSystem())); + } +} diff --git a/Tests/Helpers/Testably.Abstractions.Tests.SourceGenerator/ClassModel.cs b/Tests/Helpers/Testably.Abstractions.Tests.SourceGenerator/ClassModel.cs deleted file mode 100644 index 2a40f6aa0..000000000 --- a/Tests/Helpers/Testably.Abstractions.Tests.SourceGenerator/ClassModel.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace Testably.Abstractions.Tests.SourceGenerator; - -internal readonly record struct ClassModel -{ - public string Name { get; } - public string Namespace { get; } - public ClassModelType Type { get; } - - internal ClassModel(ClassModelType type, string @namespace, string name) - { - Type = type; - Namespace = @namespace; - Name = name; - } -} diff --git a/Tests/Helpers/Testably.Abstractions.Tests.SourceGenerator/ClassModelType.cs b/Tests/Helpers/Testably.Abstractions.Tests.SourceGenerator/ClassModelType.cs deleted file mode 100644 index b2a1ac56c..000000000 --- a/Tests/Helpers/Testably.Abstractions.Tests.SourceGenerator/ClassModelType.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Testably.Abstractions.Tests.SourceGenerator; - -internal enum ClassModelType -{ - FileSystem, - RandomSystem, - TimeSystem, -} diff --git a/Tests/Helpers/Testably.Abstractions.Tests.SourceGenerator/Generator.cs b/Tests/Helpers/Testably.Abstractions.Tests.SourceGenerator/Generator.cs deleted file mode 100644 index 0d645cc42..000000000 --- a/Tests/Helpers/Testably.Abstractions.Tests.SourceGenerator/Generator.cs +++ /dev/null @@ -1,186 +0,0 @@ -using Microsoft.CodeAnalysis; -using Microsoft.CodeAnalysis.CSharp.Syntax; -using Microsoft.CodeAnalysis.Text; -using System; -using System.Collections.Generic; -using System.Text; - -namespace Testably.Abstractions.Tests.SourceGenerator; - -/// -/// This generator creates concrete classes in `Testably.Abstractions.Tests` for abstract partial classes, so that the -/// defined tests run against a real and a mocked system. This works for:
-/// - `IFileSystem`
-/// - `IRandomSystem`
-/// - `ITimeSystem` -///
-[Generator] -public sealed class Generator : IIncrementalGenerator -{ - #region IIncrementalGenerator Members - - /// - public void Initialize(IncrementalGeneratorInitializationContext context) - { - // Add the marker attribute to the compilation - context.RegisterPostInitializationOutput(ctx => ctx.AddSource( - "MarkerAttributes.g.cs", - SourceText.From(SourceGenerationHelper.GenerateMarkerAttributes(), Encoding.UTF8))); - - // Add the marker attribute to the compilation - context.RegisterPostInitializationOutput(ctx => ctx.AddSource( - "CollectionFixtures.g.cs", - SourceText.From(SourceGenerationHelper.GenerateCollectionFixtures(), Encoding.UTF8))); - - // Do a simple filter for enums - IncrementalValuesProvider classesToGenerate = context.SyntaxProvider - .CreateSyntaxProvider( - predicate: static (s, _) - => IsSyntaxTargetForGeneration(s), // select enums with attributes - transform: static (ctx, _) - => GetSemanticTargetForGeneration( - ctx)) // select enums with the [EnumExtensions] attribute and extract details - .Where(static m => m is not null); // Filter out errors that we don't care about - - context.RegisterSourceOutput(classesToGenerate, - static (context, source) => Execute(source, context)); - } - - #endregion - - private static string CreateFileName(ClassModel model) - { - string? prefix = model.Namespace + "."; - string[] exclusions = - [ - "Testably.Abstractions.Tests.", - "Testably.Abstractions.", - ]; - foreach (string? exclusion in exclusions) - { - if (prefix.StartsWith(exclusion, StringComparison.Ordinal)) - { - prefix = prefix.Substring(exclusion.Length); - } - } - - return $"{prefix}{model.Name}.g.cs"; - } - - private static void Execute(ClassModel? model, SourceProductionContext context) - { - if (model is not null) - { - string? fileName = CreateFileName(model.Value); - // generate the source code and add it to the output - string result = SourceGenerationHelper.GenerateTestClasses(model.Value); - // Create a separate partial class file for each test class - context.AddSource(fileName, SourceText.From(result, Encoding.UTF8)); - } - } - - private static ClassModel? GetClassModelToGenerate(ClassModelType type, - SemanticModel semanticModel, ClassDeclarationSyntax classDeclarationSyntax) - { - // Get the semantic representation of the enum syntax - if (semanticModel.GetDeclaredSymbol(classDeclarationSyntax) is not INamedTypeSymbol - classSymbol) - { - // something went wrong - return null; - } - - return new ClassModel(type, GetNamespace(classDeclarationSyntax), classSymbol.Name); - } - - /// - /// Determine the namespace the class/enum/struct is declared in, if any - /// - private static string GetNamespace(BaseTypeDeclarationSyntax syntax) - { - // If we don't have a namespace at all we'll return an empty string - // This accounts for the "default namespace" case - string @namespace = string.Empty; - - // Get the containing syntax node for the type declaration - // (could be a nested type, for example) - SyntaxNode? potentialNamespaceParent = syntax.Parent; - - // Keep moving "out" of nested classes etc until we get to a namespace - // or until we run out of parents - while (potentialNamespaceParent != null && - potentialNamespaceParent is not NamespaceDeclarationSyntax - && potentialNamespaceParent is not FileScopedNamespaceDeclarationSyntax) - { - potentialNamespaceParent = potentialNamespaceParent.Parent; - } - - // Build up the final namespace by looping until we no longer have a namespace declaration - if (potentialNamespaceParent is BaseNamespaceDeclarationSyntax namespaceParent) - { - // We have a namespace. Use that as the type - @namespace = namespaceParent.Name.ToString(); - - // Keep moving "out" of the namespace declarations until we - // run out of nested namespace declarations - while (true) - { - if (namespaceParent.Parent is not NamespaceDeclarationSyntax parent) - { - break; - } - - // Add the outer namespace as a prefix to the final namespace - @namespace = $"{namespaceParent.Name}.{@namespace}"; - namespaceParent = parent; - } - } - - // return the final namespace - return @namespace; - } - - private static ClassModel? GetSemanticTargetForGeneration(GeneratorSyntaxContext context) - { - // we know the node is a ClassDeclarationSyntax thanks to IsSyntaxTargetForGeneration - ClassDeclarationSyntax? classDeclarationSyntax = (ClassDeclarationSyntax)context.Node; - - // loop through all the attributes on the method - foreach (AttributeListSyntax attributeListSyntax in classDeclarationSyntax.AttributeLists) - { - foreach (AttributeSyntax attributeSyntax in attributeListSyntax.Attributes) - { - if (context.SemanticModel.GetSymbolInfo(attributeSyntax).Symbol is not IMethodSymbol - attributeSymbol) - { - // weird, we couldn't get the symbol, ignore it - continue; - } - - INamedTypeSymbol attributeContainingTypeSymbol = attributeSymbol.ContainingType; - string fullName = attributeContainingTypeSymbol.ToDisplayString(); - - return fullName switch - { - "Testably.Abstractions.TestHelpers.FileSystemTestsAttribute" => - GetClassModelToGenerate(ClassModelType.FileSystem, - context.SemanticModel, classDeclarationSyntax), - "Testably.Abstractions.TestHelpers.TimeSystemTestsAttribute" => - GetClassModelToGenerate(ClassModelType.TimeSystem, - context.SemanticModel, classDeclarationSyntax), - "Testably.Abstractions.TestHelpers.RandomSystemTestsAttribute" => - GetClassModelToGenerate(ClassModelType.RandomSystem, - context.SemanticModel, classDeclarationSyntax), - _ => null, - }; - } - } - - return null; - } - - private static bool IsSyntaxTargetForGeneration(SyntaxNode syntaxNode) - { - return syntaxNode is ClassDeclarationSyntax { AttributeLists.Count: > 0 }; - } -} diff --git a/Tests/Helpers/Testably.Abstractions.Tests.SourceGenerator/Properties/launchSettings.json b/Tests/Helpers/Testably.Abstractions.Tests.SourceGenerator/Properties/launchSettings.json deleted file mode 100644 index f23ad2ca7..000000000 --- a/Tests/Helpers/Testably.Abstractions.Tests.SourceGenerator/Properties/launchSettings.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "$schema": "http://json.schemastore.org/launchsettings.json", - "profiles": { - "Generators": { - "commandName": "DebugRoslynComponent", - "targetProject": "../../Testably.Abstractions.Tests/Testably.Abstractions.Tests.csproj" - } - } -} diff --git a/Tests/Helpers/Testably.Abstractions.Tests.SourceGenerator/SourceGenerationHelper.FileSystem.cs b/Tests/Helpers/Testably.Abstractions.Tests.SourceGenerator/SourceGenerationHelper.FileSystem.cs deleted file mode 100644 index 7b3cacd04..000000000 --- a/Tests/Helpers/Testably.Abstractions.Tests.SourceGenerator/SourceGenerationHelper.FileSystem.cs +++ /dev/null @@ -1,296 +0,0 @@ -using System; -using System.Text; - -namespace Testably.Abstractions.Tests.SourceGenerator; - -#pragma warning disable MA0051 -#pragma warning disable MA0028 -internal static partial class SourceGenerationHelper -{ - public static string GenerateFileSystemTestClasses(ClassModel model) - { - StringBuilder? sb = GetSourceBuilder(); - sb.AppendLine($$""" - using System.Runtime.InteropServices; - using Testably.Abstractions.Testing.Initializer; - using Testably.Abstractions.TestHelpers; - using Testably.Abstractions.TestHelpers.Settings; - - namespace {{model.Namespace}} - { - public abstract partial class {{model.Name}} - { - /// - /// The delay in milliseconds when wanting to ensure a timeout in the test. - /// - public const int EnsureTimeout = 500; - - /// - /// The delay in milliseconds when expecting a success in the test. - /// - public const int ExpectSuccess = 30000; - - /// - /// The delay in milliseconds when expecting a timeout in the test. - /// - public const int ExpectTimeout = 30; - - public abstract string BasePath { get; } - public IFileSystem FileSystem { get; } - public Test Test { get; } - public ITimeSystem TimeSystem { get; } - - protected {{model.Name}}(Test test, IFileSystem fileSystem, ITimeSystem timeSystem) - { - Test = test; - FileSystem = fileSystem; - TimeSystem = timeSystem; - } - - /// - /// Specifies, if brittle tests should be skipped on the real file system. - /// - /// - /// (optional) A condition that must be for the test to be skipped on the - /// real file system. - /// - public abstract void SkipIfBrittleTestsShouldBeSkipped(bool condition = true); - - /// - /// Specifies, if long-running tests should be skipped on the real file system. - /// - public abstract void SkipIfLongRunningTestsShouldBeSkipped(); - - - // ReSharper disable once UnusedMember.Global - public sealed class MockFileSystemTests : {{model.Name}}, IDisposable - { - /// - public override string BasePath => _directoryCleaner.BasePath; - - private readonly IDirectoryCleaner _directoryCleaner; - - public MockFileSystemTests() : this(new MockFileSystem()) - { - } - - private MockFileSystemTests(MockFileSystem mockFileSystem) : base( - new Test(), - mockFileSystem, - mockFileSystem.TimeSystem) - { - _directoryCleaner = FileSystem - .SetCurrentDirectoryToEmptyTemporaryDirectory(); - } - - /// - public void Dispose() - => _directoryCleaner.Dispose(); - - /// - public override void SkipIfBrittleTestsShouldBeSkipped(bool condition = true) - { - // Brittle tests are never skipped against the mock file system! - } - - /// - public override void SkipIfLongRunningTestsShouldBeSkipped() - { - // Long-running tests are never skipped against the mock file system! - } - } - // ReSharper disable once UnusedMember.Global - [Collection("RealFileSystemTests")] - public sealed class RealFileSystemTests : {{model.Name}}, IDisposable - { - /// - public override string BasePath => _directoryCleaner.BasePath; - - private readonly IDirectoryCleaner _directoryCleaner; - private readonly TestSettingsFixture _fixture; - - public RealFileSystemTests(ITestOutputHelper testOutputHelper, TestSettingsFixture fixture) - : base(new Test(), new RealFileSystem(), new RealTimeSystem()) - { - #if DEBUG - if (fixture.RealFileSystemTests != TestSettingStatus.AlwaysEnabled) - { - aweXpect.Skip.Test($"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) - { - aweXpect.Skip.Test($"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; - _directoryCleaner = FileSystem - .SetCurrentDirectoryToEmptyTemporaryDirectory($"{{model.Namespace}}{FileSystem.Path.DirectorySeparatorChar}{{model.Name}}-", testOutputHelper.WriteLine); - } - - /// - public void Dispose() - => _directoryCleaner.Dispose(); - - #if DEBUG - /// - public override void SkipIfBrittleTestsShouldBeSkipped(bool condition = true) - => aweXpect.Skip.When(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) - => aweXpect.Skip.When(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() - => aweXpect.Skip.When(_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() - => aweXpect.Skip.When(_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 - } - """); - if (IncludeSimulatedTests(model)) - { - sb.AppendLine($$""" - - #if !NETFRAMEWORK - // ReSharper disable once UnusedMember.Global - public sealed class LinuxFileSystemTests : {{model.Name}}, IDisposable - { - /// - public override string BasePath => _directoryCleaner.BasePath; - - private readonly IDirectoryCleaner _directoryCleaner; - - public LinuxFileSystemTests() : this(new MockFileSystem(o => - o.SimulatingOperatingSystem(SimulationMode.Linux))) - { - } - - private LinuxFileSystemTests(MockFileSystem mockFileSystem) : base( - new Test(OSPlatform.Linux), - mockFileSystem, - mockFileSystem.TimeSystem) - { - _directoryCleaner = FileSystem - .SetCurrentDirectoryToEmptyTemporaryDirectory(); - } - - /// - public void Dispose() - => _directoryCleaner.Dispose(); - - /// - public override void SkipIfBrittleTestsShouldBeSkipped(bool condition = true) - { - // Brittle tests are never skipped against the mock file system! - } - /// - public override void SkipIfLongRunningTestsShouldBeSkipped() - { - // Long-running tests are never skipped against the mock file system! - } - } - #endif - - #if !NETFRAMEWORK - // ReSharper disable once UnusedMember.Global - public sealed class MacFileSystemTests : {{model.Name}}, IDisposable - { - /// - public override string BasePath => _directoryCleaner.BasePath; - - private readonly IDirectoryCleaner _directoryCleaner; - - public MacFileSystemTests() : this(new MockFileSystem(o => - o.SimulatingOperatingSystem(SimulationMode.MacOS))) - { - } - private MacFileSystemTests(MockFileSystem mockFileSystem) : base( - new Test(OSPlatform.OSX), - mockFileSystem, - mockFileSystem.TimeSystem) - { - _directoryCleaner = FileSystem - .SetCurrentDirectoryToEmptyTemporaryDirectory(); - } - - /// - public void Dispose() - => _directoryCleaner.Dispose(); - - /// - public override void SkipIfBrittleTestsShouldBeSkipped(bool condition = true) - { - // Brittle tests are never skipped against the mock file system! - } - /// - public override void SkipIfLongRunningTestsShouldBeSkipped() - { - // Long-running tests are never skipped against the mock file system! - } - } - #endif - - #if !NETFRAMEWORK - // ReSharper disable once UnusedMember.Global - public sealed class WindowsFileSystemTests : {{model.Name}}, IDisposable - { - /// - public override string BasePath => _directoryCleaner.BasePath; - - private readonly IDirectoryCleaner _directoryCleaner; - - public WindowsFileSystemTests() : this(new MockFileSystem(o => - o.SimulatingOperatingSystem(SimulationMode.Windows))) - { - } - private WindowsFileSystemTests(MockFileSystem mockFileSystem) : base( - new Test(OSPlatform.Windows), - mockFileSystem, - mockFileSystem.TimeSystem) - { - _directoryCleaner = FileSystem - .SetCurrentDirectoryToEmptyTemporaryDirectory(); - } - - /// - public void Dispose() - => _directoryCleaner.Dispose(); - - /// - public override void SkipIfBrittleTestsShouldBeSkipped(bool condition = true) - { - // Brittle tests are never skipped against the mock file system! - } - /// - public override void SkipIfLongRunningTestsShouldBeSkipped() - { - // Long-running tests are never skipped against the mock file system! - } - } - #endif - """); - } - - sb.AppendLine(""" - } - } - """); - return sb.ToString(); - - static bool IncludeSimulatedTests(ClassModel model) - => !model.Namespace.Equals( - "Testably.Abstractions.AccessControl.Tests", StringComparison.Ordinal); - } -} -#pragma warning restore MA0028 -#pragma warning restore MA0051 diff --git a/Tests/Helpers/Testably.Abstractions.Tests.SourceGenerator/SourceGenerationHelper.RandomSystem.cs b/Tests/Helpers/Testably.Abstractions.Tests.SourceGenerator/SourceGenerationHelper.RandomSystem.cs deleted file mode 100644 index 81715fb6e..000000000 --- a/Tests/Helpers/Testably.Abstractions.Tests.SourceGenerator/SourceGenerationHelper.RandomSystem.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System.Text; - -namespace Testably.Abstractions.Tests.SourceGenerator; - -#pragma warning disable MA0051 -#pragma warning disable MA0028 -internal static partial class SourceGenerationHelper -{ - public static string GenerateRandomSystemTestClasses(ClassModel model) - { - StringBuilder? sb = GetSourceBuilder(); - sb.AppendLine($$""" - using Testably.Abstractions.TestHelpers; - - namespace {{model.Namespace}} - { - public abstract partial class {{model.Name}} - { - public IRandomSystem RandomSystem { get; } - - protected {{model.Name}}(IRandomSystem randomSystem) - { - RandomSystem = randomSystem; - } - - // ReSharper disable once UnusedMember.Global - public sealed class MockRandomSystemTests : {{model.Name}} - { - public MockRandomSystemTests() : base(new MockRandomSystem()) - { - } - } - - // ReSharper disable once UnusedMember.Global - public sealed class RealRandomSystemTests : {{model.Name}} - { - public RealRandomSystemTests() : base(new RealRandomSystem()) - { - } - } - } - } - """); - - return sb.ToString(); - } -} -#pragma warning restore MA0028 -#pragma warning restore MA0051 diff --git a/Tests/Helpers/Testably.Abstractions.Tests.SourceGenerator/SourceGenerationHelper.TimeSystem.cs b/Tests/Helpers/Testably.Abstractions.Tests.SourceGenerator/SourceGenerationHelper.TimeSystem.cs deleted file mode 100644 index e86efcdb2..000000000 --- a/Tests/Helpers/Testably.Abstractions.Tests.SourceGenerator/SourceGenerationHelper.TimeSystem.cs +++ /dev/null @@ -1,96 +0,0 @@ -using System.Text; - -namespace Testably.Abstractions.Tests.SourceGenerator; - -#pragma warning disable MA0051 -#pragma warning disable MA0028 -internal static partial class SourceGenerationHelper -{ - public static string GenerateTimeSystemTestClasses(ClassModel model) - { - StringBuilder? sb = GetSourceBuilder(); - sb.AppendLine($$""" - using Testably.Abstractions.TestHelpers; - using Testably.Abstractions.TestHelpers.Settings; - - namespace {{model.Namespace}} - { - public abstract partial class {{model.Name}} - { - /// - /// The delay in milliseconds when wanting to ensure a timeout in the test. - /// - public const int EnsureTimeout = 500; - - /// - /// The delay in milliseconds when expecting a success in the test. - /// - public const int ExpectSuccess = 30000; - - /// - /// The delay in milliseconds when expecting a timeout in the test. - /// - public const int ExpectTimeout = 30; - - public ITimeSystem TimeSystem { get; } - - protected {{model.Name}}(ITimeSystem timeSystem) - { - TimeSystem = timeSystem; - } - - /// - /// Specifies, if brittle tests should be skipped on the real time system. - /// - /// - /// (optional) A condition that must be for the test to be skipped on the - /// real time system. - /// - public abstract void SkipIfBrittleTestsShouldBeSkipped(bool condition = true); - - // ReSharper disable once UnusedMember.Global - public sealed class MockTimeSystemTests : {{model.Name}} - { - public MockTimeSystemTests() : base(new MockTimeSystem(Testing.TimeProvider.Now())) - { - } - - /// - public override void SkipIfBrittleTestsShouldBeSkipped(bool condition = true) - { - // Brittle tests are never skipped against the mock time system! - } - } - - // ReSharper disable once UnusedMember.Global - [Collection("RealTimeSystemTests")] - public sealed class RealTimeSystemTests : {{model.Name}} - { - private readonly TestSettingsFixture _fixture; - - public RealTimeSystemTests(TestSettingsFixture fixture) : base(new RealTimeSystem()) - { - _fixture = fixture; - } - - #if DEBUG - /// - public override void SkipIfBrittleTestsShouldBeSkipped(bool condition = true) - => aweXpect.Skip.When(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) - => aweXpect.Skip.When(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 - } - } - } - """); - - return sb.ToString(); - } -} -#pragma warning restore MA0028 -#pragma warning restore MA0051 diff --git a/Tests/Helpers/Testably.Abstractions.Tests.SourceGenerator/SourceGenerationHelper.cs b/Tests/Helpers/Testably.Abstractions.Tests.SourceGenerator/SourceGenerationHelper.cs deleted file mode 100644 index eb6fc9e9d..000000000 --- a/Tests/Helpers/Testably.Abstractions.Tests.SourceGenerator/SourceGenerationHelper.cs +++ /dev/null @@ -1,99 +0,0 @@ -using System; -using System.Text; - -namespace Testably.Abstractions.Tests.SourceGenerator; - -#pragma warning disable MA0051 -internal static partial class SourceGenerationHelper -{ - public static string GenerateCollectionFixtures() - { - StringBuilder? sb = GetSourceBuilder(); - sb.Append(""" - using Xunit; - - namespace Testably.Abstractions.TestHelpers.Settings; - - [CollectionDefinition("RealFileSystemTests")] - public class FileSystemTestSettingsFixture : ICollectionFixture - { - // This class has no code, and is never created. Its purpose is simply - // to be the place to apply [CollectionDefinition] and all the - // ICollectionFixture<> interfaces. - } - - [CollectionDefinition("RealTimeSystemTests")] - public class TimeSystemTestSettingsFixture : ICollectionFixture - { - // This class has no code, and is never created. Its purpose is simply - // to be the place to apply [CollectionDefinition] and all the - // ICollectionFixture<> interfaces. - } - """); - return sb.ToString(); - } - public static string GenerateMarkerAttributes() - { - StringBuilder? sb = GetSourceBuilder(); - sb.Append(""" - namespace Testably.Abstractions.TestHelpers - { - /// - /// Marks a class to contain tests for the that runs against mock and real implementations. - /// - /// - /// The class must be abstract and partial and will get an `IFileSystem FileSystem` property injected - /// - [System.AttributeUsage(System.AttributeTargets.Class)] - public class FileSystemTestsAttribute : System.Attribute - { - } - - /// - /// Marks a class to contain tests for the that runs against mock and real implementations. - /// - /// - /// The class must be abstract and partial and will get an `ITimeSystem TimeSystem` property injected - /// - [System.AttributeUsage(System.AttributeTargets.Class)] - public class TimeSystemTestsAttribute : System.Attribute - { - } - - /// - /// Marks a class to contain tests for the that runs against mock and real implementations. - /// - /// - /// The class must be abstract and partial and will get an `IRandomSystem RandomSystem` property injected - /// - [System.AttributeUsage(System.AttributeTargets.Class)] - public class RandomSystemTestsAttribute : System.Attribute - { - } - } - """); - return sb.ToString(); - } - - public static string GenerateTestClasses(ClassModel model) - => model.Type switch - { - ClassModelType.FileSystem => GenerateFileSystemTestClasses(model), - ClassModelType.TimeSystem => GenerateTimeSystemTestClasses(model), - ClassModelType.RandomSystem => GenerateRandomSystemTestClasses(model), - _ => throw new NotSupportedException(), - }; - - private static StringBuilder GetSourceBuilder() - => new( - @"//------------------------------------------------------------------------------ -// -// This code was generated by ""Testably.Abstractions.Tests.SourceGenerator"". -// -// Changes to this file may cause incorrect behavior -// and will be lost if the code is regenerated. -// -//------------------------------------------------------------------------------ -"); -} -#pragma warning restore MA0051 diff --git a/Tests/Helpers/Testably.Abstractions.Tests.SourceGenerator/Testably.Abstractions.Tests.SourceGenerator.csproj b/Tests/Helpers/Testably.Abstractions.Tests.SourceGenerator/Testably.Abstractions.Tests.SourceGenerator.csproj deleted file mode 100644 index 5bcbb041a..000000000 --- a/Tests/Helpers/Testably.Abstractions.Tests.SourceGenerator/Testably.Abstractions.Tests.SourceGenerator.csproj +++ /dev/null @@ -1,36 +0,0 @@ - - - - netstandard2.0 - false - latest - Library - true - - - - - - - - - - - - - false - - - - - - - - - - - - - - - diff --git a/Tests/Settings/Directory.Build.props b/Tests/Settings/Directory.Build.props deleted file mode 100644 index 5d1cdaeed..000000000 --- a/Tests/Settings/Directory.Build.props +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - net8.0 - - - - latest - disable - enable - false - 701;1702;CA1845 - - - - annotations - - - - - - - - - runtime; build; native; contentfiles; analyzers; buildtransitive - all - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - diff --git a/Tests/Settings/Testably.Abstractions.TestSettings/BrittleTests.cs b/Tests/Settings/Testably.Abstractions.TestSettings/BrittleTests.cs deleted file mode 100644 index bdb4def4e..000000000 --- a/Tests/Settings/Testably.Abstractions.TestSettings/BrittleTests.cs +++ /dev/null @@ -1,78 +0,0 @@ -using NUnit.Framework; -using Testably.Abstractions.TestHelpers.Settings; - -namespace Testably.Abstractions.TestSettings; - -public sealed class BrittleTests -{ - /// - /// Some tests are brittle on the real file system. - /// - /// Always disable these tests! - /// - [TestCase] - [Explicit] - public void DisableAlways() - { - _ = Helper.ChangeTestSettings(s => - s.BrittleTests = TestSettingStatus.AlwaysDisabled); - - Assert.Pass("Brittle tests are always disabled."); - } - - /// - /// Some tests are brittle on the real file system. - /// - /// Disable these tests in DEBUG mode! - /// - [TestCase] - [Explicit] - public void DisableInDebugMode() - { - TestEnvironment result = Helper.ChangeTestSettings(s => - s.BrittleTests = TestSettingStatus.DisabledInDebugMode); - - if (result.RealFileSystemTests == TestSettingStatus.AlwaysDisabled) - { - Assert.Warn(""" - Brittle tests are disabled in DEBUG mode. - But the tests against the real file system are always disabled. - """); - } - else - { - Assert.Pass("Brittle tests are disabled in DEBUG mode."); - } - } - - /// - /// Some tests are brittle on the real file system. - /// - /// Always enable these tests! - /// - [TestCase] - [Explicit] - public void EnableAlways() - { - TestEnvironment result = Helper.ChangeTestSettings(s => - s.BrittleTests = TestSettingStatus.AlwaysEnabled); - - if (result.RealFileSystemTests != TestSettingStatus.AlwaysEnabled) - { - Assert.Warn(""" - Brittle tests are always enabled. - But the tests against the real file system are not always enabled. - """); - } - else - { - Assert.Pass("Brittle tests are always enabled."); - } - } - - [TestCase] - public void TestDummy_SoThatExplicitTestsAreIgnored() - { - Assert.Pass(); - } -} diff --git a/Tests/Settings/Testably.Abstractions.TestSettings/Helper.cs b/Tests/Settings/Testably.Abstractions.TestSettings/Helper.cs deleted file mode 100644 index 086f91030..000000000 --- a/Tests/Settings/Testably.Abstractions.TestSettings/Helper.cs +++ /dev/null @@ -1,61 +0,0 @@ -using System; -using System.IO; -using System.Text.Json; -using System.Text.Json.Serialization; -using Testably.Abstractions.TestHelpers.Settings; - -namespace Testably.Abstractions.TestSettings; - -internal static class Helper -{ - private static readonly JsonSerializerOptions ReadJsonSerializerOptions; - private static readonly JsonSerializerOptions WriteJsonSerializerOptions; - - static Helper() - { - ReadJsonSerializerOptions = new JsonSerializerOptions(); - ReadJsonSerializerOptions.Converters.Add(new JsonStringEnumConverter()); - WriteJsonSerializerOptions = new JsonSerializerOptions - { - WriteIndented = true, - Converters = - { - new JsonStringEnumConverter() - } - }; - } - - public static TestEnvironment ChangeTestSettings( - Action change) - { - TestEnvironment environment = ReadTestSettings(); - change(environment); - WriteTestSettings(environment); - return environment; - } - - private static string GetTestSettingsPath() => - Path.GetFullPath(Path.Combine("..", "..", "..", "..", "..", "test.settings.json")); - - private static TestEnvironment ReadTestSettings() - { - try - { - string path = GetTestSettingsPath(); - string content = File.ReadAllText(path); - return JsonSerializer.Deserialize(content, ReadJsonSerializerOptions) - ?? throw new NotSupportedException("The file has an invalid syntax!"); - } - catch (Exception) - { - return new TestEnvironment(); - } - } - - private static void WriteTestSettings(TestEnvironment environment) - { - string content = JsonSerializer.Serialize(environment, WriteJsonSerializerOptions); - string path = GetTestSettingsPath(); - File.WriteAllText(path, content); - } -} diff --git a/Tests/Settings/Testably.Abstractions.TestSettings/LongRunningTests.cs b/Tests/Settings/Testably.Abstractions.TestSettings/LongRunningTests.cs deleted file mode 100644 index ce71af71e..000000000 --- a/Tests/Settings/Testably.Abstractions.TestSettings/LongRunningTests.cs +++ /dev/null @@ -1,78 +0,0 @@ -using NUnit.Framework; -using Testably.Abstractions.TestHelpers.Settings; - -namespace Testably.Abstractions.TestSettings; - -public sealed class LongRunningTests -{ - /// - /// Some tests take a long time to run against the real file system (e.g. timeout). - /// - /// Always disable these tests! - /// - [TestCase] - [Explicit] - public void DisableAlways() - { - _ = Helper.ChangeTestSettings(s => - s.LongRunningTests = TestSettingStatus.AlwaysDisabled); - - Assert.Pass("Long-running tests are always disabled."); - } - - /// - /// Some tests take a long time to run against the real file system (e.g. timeout). - /// - /// Disable these tests in DEBUG mode! - /// - [TestCase] - [Explicit] - public void DisableInDebugMode() - { - TestEnvironment result = Helper.ChangeTestSettings(s => - s.LongRunningTests = TestSettingStatus.DisabledInDebugMode); - - if (result.RealFileSystemTests == TestSettingStatus.AlwaysDisabled) - { - Assert.Warn(""" - Long-running tests are disabled in DEBUG mode. - But the tests against the real file system are always disabled. - """); - } - else - { - Assert.Pass("Long-running tests are disabled in DEBUG mode."); - } - } - - /// - /// Some tests take a long time to run against the real file system (e.g. timeout). - /// - /// Always enable these tests! - /// - [TestCase] - [Explicit] - public void EnableAlways() - { - TestEnvironment result = Helper.ChangeTestSettings(s => - s.LongRunningTests = TestSettingStatus.AlwaysEnabled); - - if (result.RealFileSystemTests != TestSettingStatus.AlwaysEnabled) - { - Assert.Warn(""" - Long-running tests are always enabled. - But the tests against the real file system are not always enabled. - """); - } - else - { - Assert.Pass("Long-running tests are always enabled."); - } - } - - [TestCase] - public void TestDummy_SoThatExplicitTestsAreIgnored() - { - Assert.Pass(); - } -} diff --git a/Tests/Settings/Testably.Abstractions.TestSettings/RealFileSystemTests.cs b/Tests/Settings/Testably.Abstractions.TestSettings/RealFileSystemTests.cs deleted file mode 100644 index 86f049117..000000000 --- a/Tests/Settings/Testably.Abstractions.TestSettings/RealFileSystemTests.cs +++ /dev/null @@ -1,58 +0,0 @@ -using NUnit.Framework; -using Testably.Abstractions.TestHelpers.Settings; - -namespace Testably.Abstractions.TestSettings; - -public sealed class RealFileSystemTests -{ - /// - /// All tests against the real file system. - /// - /// Always disable these tests! - /// - [TestCase] - [Explicit] - public void DisableAlways() - { - _ = Helper.ChangeTestSettings(s => - s.RealFileSystemTests = TestSettingStatus.AlwaysDisabled); - - Assert.Pass("Tests against the real file system are always disabled."); - } - - /// - /// All tests against the real file system. - /// - /// Disable these tests in DEBUG mode! - /// - [TestCase] - [Explicit] - public void DisableInDebugMode() - { - _ = Helper.ChangeTestSettings(s => - s.RealFileSystemTests = TestSettingStatus.DisabledInDebugMode); - - Assert.Pass("Tests against the real file system are disabled in DEBUG mode."); - } - - /// - /// All tests against the real file system. - /// - /// Always enable these tests! - /// - [TestCase] - [Explicit] - public void EnableAlways() - { - _ = Helper.ChangeTestSettings(s => - s.RealFileSystemTests = TestSettingStatus.AlwaysEnabled); - - Assert.Pass("Tests against the real file system are always enabled."); - } - - [TestCase] - public void TestDummy_SoThatExplicitTestsAreIgnored() - { - Assert.Pass(); - } -} diff --git a/Tests/Settings/Testably.Abstractions.TestSettings/Testably.Abstractions.TestSettings.csproj b/Tests/Settings/Testably.Abstractions.TestSettings/Testably.Abstractions.TestSettings.csproj deleted file mode 100644 index 56ccba3e5..000000000 --- a/Tests/Settings/Testably.Abstractions.TestSettings/Testably.Abstractions.TestSettings.csproj +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/Tests/Testably.Abstractions.AccessControl.Tests/AccessControlHelperTests.cs b/Tests/Testably.Abstractions.AccessControl.Tests/AccessControlHelperTests.cs index 356ad83b4..0e839d64e 100644 --- a/Tests/Testably.Abstractions.AccessControl.Tests/AccessControlHelperTests.cs +++ b/Tests/Testably.Abstractions.AccessControl.Tests/AccessControlHelperTests.cs @@ -3,9 +3,9 @@ namespace Testably.Abstractions.AccessControl.Tests; [FileSystemTests] -public partial class AccessControlHelperTests +public class AccessControlHelperTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Fact] + [Test] public async Task GetExtensibilityOrThrow_DirectoryInfo_ShouldNotThrow() { IDirectoryInfo sut = FileSystem.DirectoryInfo.New("foo"); @@ -13,7 +13,7 @@ public async Task GetExtensibilityOrThrow_DirectoryInfo_ShouldNotThrow() await That(() => sut.GetExtensibilityOrThrow()).DoesNotThrow(); } - [Fact] + [Test] public async Task GetExtensibilityOrThrow_FileInfo_ShouldNotThrow() { IFileInfo sut = FileSystem.FileInfo.New("foo"); @@ -21,7 +21,7 @@ public async Task GetExtensibilityOrThrow_FileInfo_ShouldNotThrow() await That(() => sut.GetExtensibilityOrThrow()).DoesNotThrow(); } - [Fact] + [Test] public async Task GetExtensibilityOrThrow_FileSystemStream_ShouldNotThrow() { FileSystemStream sut = FileSystem.FileStream.New("foo", FileMode.Create); diff --git a/Tests/Testably.Abstractions.AccessControl.Tests/DirectoryAclExtensionsTests.cs b/Tests/Testably.Abstractions.AccessControl.Tests/DirectoryAclExtensionsTests.cs index b026efcd5..757e76428 100644 --- a/Tests/Testably.Abstractions.AccessControl.Tests/DirectoryAclExtensionsTests.cs +++ b/Tests/Testably.Abstractions.AccessControl.Tests/DirectoryAclExtensionsTests.cs @@ -1,17 +1,16 @@ +using System.Runtime.InteropServices; using System.Security.AccessControl; using Testably.Abstractions.AccessControl.Tests.TestHelpers; using Skip = Testably.Abstractions.TestHelpers.Skip; namespace Testably.Abstractions.AccessControl.Tests; -[FileSystemTests] -public partial class DirectoryAclExtensionsTests +[WindowsOnlyFileSystemTests] +public class DirectoryAclExtensionsTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Fact] + [Test] public async Task CreateDirectory_NullDirectorySecurity_ShouldThrowArgumentNullException() { - Skip.IfNot(Test.RunsOnWindows); - #pragma warning disable CA1416 void Act() => FileSystem.Directory.CreateDirectory("foo", null!); @@ -21,13 +20,11 @@ await That(Act).Throws() .WithParamName("directorySecurity"); } - [Theory] - [InlineData("bar")] - [InlineData("bar\\foo")] + [Test] + [Arguments("bar")] + [Arguments("bar\\foo")] public async Task CreateDirectory_ShouldChangeAccessControl(string path) { - Skip.IfNot(Test.RunsOnWindows); - #pragma warning disable CA1416 DirectorySecurity directorySecurity = FileSystem.CreateDirectorySecurity(); @@ -39,11 +36,9 @@ public async Task CreateDirectory_ShouldChangeAccessControl(string path) await That(FileSystem.Directory.Exists(path)).IsTrue(); } - [Fact] + [Test] public async Task GetAccessControl_ShouldBeInitializedWithNotNullValue() { - Skip.IfNot(Test.RunsOnWindows); - FileSystem.Directory.CreateDirectory("foo"); #pragma warning disable CA1416 @@ -54,10 +49,9 @@ public async Task GetAccessControl_ShouldBeInitializedWithNotNullValue() #pragma warning restore CA1416 } - [Fact] + [Test] public async Task GetAccessControl_ShouldReturnSetResult() { - Skip.IfNot(Test.RunsOnWindows); Skip.If(FileSystem is RealFileSystem); FileSystem.Directory.CreateDirectory("foo"); @@ -75,10 +69,9 @@ public async Task GetAccessControl_ShouldReturnSetResult() #pragma warning restore CA1416 } - [Fact] + [Test] public async Task GetAccessControl_WithAccessControlSections_ShouldBeInitializedWithNotNullValue() { - Skip.IfNot(Test.RunsOnWindows); SkipIfLongRunningTestsShouldBeSkipped(); FileSystem.Directory.CreateDirectory("foo"); @@ -91,10 +84,9 @@ public async Task GetAccessControl_WithAccessControlSections_ShouldBeInitialized #pragma warning restore CA1416 } - [Fact] + [Test] public async Task GetAccessControl_WithAccessControlSections_ShouldReturnSetResult() { - Skip.IfNot(Test.RunsOnWindows); Skip.If(FileSystem is RealFileSystem); FileSystem.Directory.CreateDirectory("foo"); @@ -112,11 +104,9 @@ public async Task GetAccessControl_WithAccessControlSections_ShouldReturnSetResu #pragma warning restore CA1416 } - [Fact] + [Test] public async Task SetAccessControl_ShouldChangeAccessControl() { - Skip.IfNot(Test.RunsOnWindows); - FileSystem.Directory.CreateDirectory("foo"); #pragma warning disable CA1416 DirectorySecurity originalAccessControl = FileSystem.CreateDirectorySecurity(); @@ -131,14 +121,13 @@ await That(currentAccessControl.HasSameAccessRightsAs(originalAccessControl)) .IsTrue(); } - [Fact] + [Test] public async Task SetAccessControl_ShouldNotUpdateTimes() { - Skip.IfNot(Test.RunsOnWindows); SkipIfLongRunningTestsShouldBeSkipped(); FileSystem.File.WriteAllText("foo.txt", "abc"); - await TimeSystem.Task.Delay(3000, TestContext.Current.CancellationToken); + await TimeSystem.Task.Delay(3000, CancellationToken); DateTime previousCreationTimeUtc = FileSystem.File.GetCreationTimeUtc("foo.txt"); DateTime previousLastAccessTimeUtc = FileSystem.File.GetLastAccessTimeUtc("foo.txt"); DateTime previousLastWriteTimeUtc = FileSystem.File.GetLastWriteTimeUtc("foo.txt"); diff --git a/Tests/Testably.Abstractions.AccessControl.Tests/DirectoryInfoAclExtensionsTests.cs b/Tests/Testably.Abstractions.AccessControl.Tests/DirectoryInfoAclExtensionsTests.cs index 4e3b31ad2..516983f81 100644 --- a/Tests/Testably.Abstractions.AccessControl.Tests/DirectoryInfoAclExtensionsTests.cs +++ b/Tests/Testably.Abstractions.AccessControl.Tests/DirectoryInfoAclExtensionsTests.cs @@ -1,19 +1,16 @@ -using AutoFixture.Xunit3; -using System.IO; +using System.IO; using System.Security.AccessControl; using Testably.Abstractions.AccessControl.Tests.TestHelpers; using Skip = Testably.Abstractions.TestHelpers.Skip; namespace Testably.Abstractions.AccessControl.Tests; -[FileSystemTests] -public partial class DirectoryInfoAclExtensionsTests +[WindowsOnlyFileSystemTests] +public class DirectoryInfoAclExtensionsTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Fact] + [Test] public async Task Create_NullDirectorySecurity_ShouldThrowArgumentNullException() { - Skip.IfNot(Test.RunsOnWindows); - FileSystem.Directory.CreateDirectory("foo"); #pragma warning disable CA1416 @@ -24,13 +21,11 @@ await That(Act).Throws() .WithParamName("directorySecurity"); } - [Theory] - [InlineData("foo")] - [InlineData("foo\\bar")] + [Test] + [Arguments("foo")] + [Arguments("foo\\bar")] public async Task Create_ShouldChangeAccessControl(string path) { - Skip.IfNot(Test.RunsOnWindows); - #pragma warning disable CA1416 DirectorySecurity directorySecurity = FileSystem.CreateDirectorySecurity(); @@ -42,10 +37,9 @@ public async Task Create_ShouldChangeAccessControl(string path) await That(FileSystem.Directory.Exists(path)).IsTrue(); } - [Fact] + [Test] public async Task GetAccessControl_MissingDirectory_ShouldThrowDirectoryNotFoundException() { - Skip.IfNot(Test.RunsOnWindows); IDirectoryInfo sut = FileSystem.DirectoryInfo.New("foo"); #pragma warning disable CA1416 @@ -56,11 +50,9 @@ await That(Act).Throws() .WithHResult(-2147024893); } - [Fact] + [Test] public async Task GetAccessControl_ShouldBeInitializedWithNotNullValue() { - Skip.IfNot(Test.RunsOnWindows); - FileSystem.Directory.CreateDirectory("foo"); #pragma warning disable CA1416 @@ -71,10 +63,9 @@ public async Task GetAccessControl_ShouldBeInitializedWithNotNullValue() #pragma warning restore CA1416 } - [Fact] + [Test] public async Task GetAccessControl_ShouldReturnSetResult() { - Skip.IfNot(Test.RunsOnWindows); Skip.If(FileSystem is RealFileSystem); FileSystem.Directory.CreateDirectory("foo"); @@ -92,11 +83,10 @@ public async Task GetAccessControl_ShouldReturnSetResult() #pragma warning restore CA1416 } - [Fact] + [Test] public async Task GetAccessControl_WithAccessControlSections_MissingDirectory_ShouldThrowDirectoryNotFoundException() { - Skip.IfNot(Test.RunsOnWindows); IDirectoryInfo sut = FileSystem.DirectoryInfo.New("foo"); #pragma warning disable CA1416 @@ -107,11 +97,10 @@ await That(Act).Throws() .WithHResult(-2147024893); } - [Fact] + [Test] public async Task GetAccessControl_WithAccessControlSections_ShouldBeInitializedWithNotNullValue() { - Skip.IfNot(Test.RunsOnWindows); SkipIfLongRunningTestsShouldBeSkipped(); FileSystem.Directory.CreateDirectory("foo"); @@ -124,10 +113,9 @@ public async Task #pragma warning restore CA1416 } - [Fact] + [Test] public async Task GetAccessControl_WithAccessControlSections_ShouldReturnSetResult() { - Skip.IfNot(Test.RunsOnWindows); Skip.If(FileSystem is RealFileSystem); FileSystem.Directory.CreateDirectory("foo"); @@ -145,11 +133,9 @@ public async Task GetAccessControl_WithAccessControlSections_ShouldReturnSetResu #pragma warning restore CA1416 } - [Fact] + [Test] public async Task SetAccessControl_ShouldChangeAccessControl() { - Skip.IfNot(Test.RunsOnWindows); - FileSystem.Directory.CreateDirectory("foo"); #pragma warning disable CA1416 DirectorySecurity originalAccessControl = FileSystem.CreateDirectorySecurity(); @@ -164,15 +150,14 @@ await That(currentAccessControl.HasSameAccessRightsAs(originalAccessControl)) .IsTrue(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task SetAccessControl_ShouldNotUpdateTimes(string path) { - Skip.IfNot(Test.RunsOnWindows); SkipIfLongRunningTestsShouldBeSkipped(); FileSystem.Directory.CreateDirectory(path); - await TimeSystem.Task.Delay(3000, TestContext.Current.CancellationToken); + await TimeSystem.Task.Delay(3000, CancellationToken); DateTime previousCreationTimeUtc = FileSystem.File.GetCreationTimeUtc(path); DateTime previousLastAccessTimeUtc = FileSystem.File.GetLastAccessTimeUtc(path); DateTime previousLastWriteTimeUtc = FileSystem.File.GetLastWriteTimeUtc(path); diff --git a/Tests/Testably.Abstractions.AccessControl.Tests/ExceptionMissingFileTests.cs b/Tests/Testably.Abstractions.AccessControl.Tests/ExceptionMissingFileTests.cs index 7e76c61dc..802f5978e 100644 --- a/Tests/Testably.Abstractions.AccessControl.Tests/ExceptionMissingFileTests.cs +++ b/Tests/Testably.Abstractions.AccessControl.Tests/ExceptionMissingFileTests.cs @@ -6,17 +6,14 @@ namespace Testably.Abstractions.AccessControl.Tests; -[FileSystemTests] -public partial class ExceptionMissingFileTests +[WindowsOnlyFileSystemTests] +public class ExceptionMissingFileTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [MemberData(nameof(GetFileCallbacks), - (int)(BaseTypes.Directory | BaseTypes.DirectoryInfo))] + [Test] + [MethodDataSource(nameof(GetDirectoryCallbacks))] public async Task DirectoryOperations_WhenDirectoryIsMissing_ShouldThrowDirectoryNotFoundException( Action callback, BaseTypes baseType, MethodType exceptionType) { - Skip.IfNot(Test.RunsOnWindows); - string path = FileSystem.Path.Combine("missing-directory", "file.txt"); Exception? exception = Record.Exception(() => @@ -44,14 +41,11 @@ await That(exception).IsNull() } } - [Theory] - [MemberData(nameof(GetFileCallbacks), - (int)(BaseTypes.Directory | BaseTypes.DirectoryInfo))] + [Test] + [MethodDataSource(nameof(GetDirectoryCallbacks))] public async Task DirectoryOperations_WhenFileIsMissing_ShouldThrowFileNotFoundException( Action callback, BaseTypes baseType, MethodType exceptionType) { - Skip.IfNot(Test.RunsOnWindows); - string path = "missing-file.txt"; Exception? exception = Record.Exception(() => @@ -79,14 +73,11 @@ await That(exception).IsNull() } } - [Theory] - [MemberData(nameof(GetFileCallbacks), - (int)(BaseTypes.File | BaseTypes.FileInfo | BaseTypes.FileStream))] + [Test] + [MethodDataSource(nameof(GetFileCallbacks))] public async Task FileOperations_WhenDirectoryIsMissing_ShouldThrowDirectoryNotFoundException( Action callback, BaseTypes baseType, MethodType exceptionType) { - Skip.IfNot(Test.RunsOnWindows); - string path = FileSystem.Path.Combine("missing-directory", "file.txt"); Exception? exception = Record.Exception(() => @@ -115,14 +106,11 @@ await That(exception).IsNull() } } - [Theory] - [MemberData(nameof(GetFileCallbacks), - (int)(BaseTypes.File | BaseTypes.FileInfo | BaseTypes.FileStream))] + [Test] + [MethodDataSource(nameof(GetFileCallbacks))] public async Task FileOperations_WhenFileIsMissing_ShouldThrowFileNotFoundException( Action callback, BaseTypes baseType, MethodType exceptionType) { - Skip.IfNot(Test.RunsOnWindows); - string path = "missing-file.txt"; Exception? exception = Record.Exception(() => @@ -152,21 +140,21 @@ await That(exception).IsNull() #region Helpers - #pragma warning disable MA0018 // Do not declare static members on generic types - public static TheoryData, BaseTypes, MethodType> GetFileCallbacks( + public static IEnumerable<(Action, BaseTypes, MethodType)> + GetFileCallbacks() + => GetCallbacks((int)(BaseTypes.File | BaseTypes.FileInfo | BaseTypes.FileStream)); + public static IEnumerable<(Action, BaseTypes, MethodType)> GetDirectoryCallbacks() + => GetCallbacks((int)(BaseTypes.Directory | BaseTypes.DirectoryInfo)); + private static IEnumerable<(Action, BaseTypes, MethodType)> GetCallbacks( int baseType) { - TheoryData, BaseTypes, MethodType> theoryData = new(); foreach ((BaseTypes BaseType, MethodType MethodType, Action Callback) item in GetFileCallbackTestParameters() .Where(item => (item.BaseType & (BaseTypes)baseType) > 0)) { - theoryData.Add(item.Callback, item.BaseType, item.MethodType); + yield return (item.Callback, item.BaseType, item.MethodType); } - - return theoryData; } - #pragma warning restore MA0018 // Do not declare static members on generic types private static IEnumerable<( diff --git a/Tests/Testably.Abstractions.AccessControl.Tests/ExceptionTests.cs b/Tests/Testably.Abstractions.AccessControl.Tests/ExceptionTests.cs index 76919efba..c6f4e5e58 100644 --- a/Tests/Testably.Abstractions.AccessControl.Tests/ExceptionTests.cs +++ b/Tests/Testably.Abstractions.AccessControl.Tests/ExceptionTests.cs @@ -1,42 +1,71 @@ using System.Collections.Generic; -using System.Linq; using System.Security.AccessControl; +using Testably.Abstractions.AccessControl.Tests.TestHelpers; using Skip = Testably.Abstractions.TestHelpers.Skip; namespace Testably.Abstractions.AccessControl.Tests; -[FileSystemTests] -public partial class ExceptionTests +[WindowsOnlyFileSystemTests] +public class ExceptionTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [MemberData(nameof(GetFileCallbacks), - (int)BaseTypes.All)] + #pragma warning disable MA0062 + [Flags] + public enum BaseTypes + { + Directory = 1, + DirectoryInfo = 2, + File = 4, + FileInfo = 8, + FileStream = 16, + None = 0, + All = ~None, + } + #pragma warning restore MA0062 + + public enum MethodType + { + Create, + GetAccessControl, + SetAccessControl, + } + + #pragma warning disable MA0018 // Do not declare static members on generic types + public static IEnumerable<(Action, BaseTypes, MethodType)> + GetFileCallbacks() + { + foreach ((BaseTypes BaseType, MethodType MethodType, Action Callback) + item in GetFileCallbackTestParameters()) + { + yield return (item.Callback, item.BaseType, item.MethodType); + } + } + #pragma warning restore MA0018 // Do not declare static members on generic types + [Test] + [MethodDataSource(nameof(GetFileCallbacks))] public async Task Operations_WhenPathIsEmpty_ShouldThrowArgumentException( Action callback, BaseTypes baseType, MethodType exceptionType) { - Skip.IfNot(Test.RunsOnWindows || exceptionType == MethodType.GetAccessControl); + Skip.IfNot(exceptionType == MethodType.GetAccessControl); await That(() => callback.Invoke(FileSystem, "")) .Throws().WithHResult(-2147024809) .Because($"\n{exceptionType} on {baseType}\n was called with an empty path"); } - [Theory] - [MemberData(nameof(GetFileCallbacks), - (int)BaseTypes.All)] + [Test] + [MethodDataSource(nameof(GetFileCallbacks))] public async Task Operations_WhenPathIsNull_ShouldThrowArgumentNullException( Action callback, BaseTypes baseType, MethodType exceptionType) { - Skip.IfNot(Test.RunsOnWindows || exceptionType == MethodType.GetAccessControl); + Skip.IfNot(exceptionType == MethodType.GetAccessControl); await That(() => callback.Invoke(FileSystem, null!)) .Throws() .Because($"\n{exceptionType} on {baseType}\n was called with a null path"); } - [Theory] - [MemberData(nameof(GetFileCallbacks), - (int)BaseTypes.All)] + [Test] + [MethodDataSource(nameof(GetFileCallbacks))] public async Task Operations_WhenPathIsWhiteSpace_ShouldThrowArgumentException( Action callback, BaseTypes baseType, MethodType exceptionType) { @@ -47,24 +76,6 @@ await That(() => callback.Invoke(FileSystem, " ")) .Because($"\n{exceptionType} on {baseType}\n was called with a whitespace path"); } - #region Helpers - - #pragma warning disable MA0018 // Do not declare static members on generic types - public static TheoryData, BaseTypes, MethodType> GetFileCallbacks( - int baseType) - { - TheoryData, BaseTypes, MethodType> theoryData = new(); - foreach ((BaseTypes BaseType, MethodType MethodType, Action Callback) - item in GetFileCallbackTestParameters() - .Where(item => (item.BaseType & (BaseTypes)baseType) > 0)) - { - theoryData.Add(item.Callback, item.BaseType, item.MethodType); - } - - return theoryData; - } - #pragma warning restore MA0018 // Do not declare static members on generic types - private static IEnumerable<( BaseTypes BaseType, @@ -128,27 +139,4 @@ Action Callback => fileSystem.FileInfo.New(path).SetAccessControl(new FileSecurity())); #pragma warning restore CA1416 } - - #endregion - - #pragma warning disable MA0062 - [Flags] - public enum BaseTypes - { - Directory = 1, - DirectoryInfo = 2, - File = 4, - FileInfo = 8, - FileStream = 16, - None = 0, - All = ~None, - } - #pragma warning restore MA0062 - - public enum MethodType - { - Create, - GetAccessControl, - SetAccessControl, - } } diff --git a/Tests/Testably.Abstractions.AccessControl.Tests/FileAclExtensionsTests.cs b/Tests/Testably.Abstractions.AccessControl.Tests/FileAclExtensionsTests.cs index 9678e411e..c66bf3b52 100644 --- a/Tests/Testably.Abstractions.AccessControl.Tests/FileAclExtensionsTests.cs +++ b/Tests/Testably.Abstractions.AccessControl.Tests/FileAclExtensionsTests.cs @@ -5,14 +5,12 @@ namespace Testably.Abstractions.AccessControl.Tests; -[FileSystemTests] -public partial class FileAclExtensionsTests +[WindowsOnlyFileSystemTests] +public class FileAclExtensionsTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Fact] + [Test] public async Task GetAccessControl_MissingFile_ShouldThrowFileNotFoundException() { - Skip.IfNot(Test.RunsOnWindows); - void Act() { #pragma warning disable CA1416 @@ -24,11 +22,9 @@ await That(Act).Throws() .WithHResult(-2147024894); } - [Fact] + [Test] public async Task GetAccessControl_ShouldBeInitializedWithNotNullValue() { - Skip.IfNot(Test.RunsOnWindows); - FileSystem.File.WriteAllText("foo", null); #pragma warning disable CA1416 @@ -38,10 +34,9 @@ public async Task GetAccessControl_ShouldBeInitializedWithNotNullValue() #pragma warning restore CA1416 } - [Fact] + [Test] public async Task GetAccessControl_ShouldReturnSetResult() { - Skip.IfNot(Test.RunsOnWindows); Skip.If(FileSystem is RealFileSystem); FileSystem.File.WriteAllText("foo", null); @@ -58,12 +53,10 @@ public async Task GetAccessControl_ShouldReturnSetResult() #pragma warning restore CA1416 } - [Fact] + [Test] public async Task GetAccessControl_WithAccessControlSections_MissingFile_ShouldThrowFileNotFoundException() { - Skip.IfNot(Test.RunsOnWindows); - void Act() { #pragma warning disable CA1416 @@ -75,10 +68,9 @@ await That(Act).Throws() .WithHResult(-2147024894); } - [Fact] + [Test] public async Task GetAccessControl_WithAccessControlSections_ShouldBeInitializedWithNotNullValue() { - Skip.IfNot(Test.RunsOnWindows); SkipIfLongRunningTestsShouldBeSkipped(); FileSystem.File.WriteAllText("foo", null); @@ -90,10 +82,9 @@ public async Task GetAccessControl_WithAccessControlSections_ShouldBeInitialized #pragma warning restore CA1416 } - [Fact] + [Test] public async Task GetAccessControl_WithAccessControlSections_ShouldReturnSetResult() { - Skip.IfNot(Test.RunsOnWindows); Skip.If(FileSystem is RealFileSystem); FileSystem.File.WriteAllText("foo", null); @@ -111,11 +102,9 @@ public async Task GetAccessControl_WithAccessControlSections_ShouldReturnSetResu #pragma warning restore CA1416 } - [Fact] + [Test] public async Task SetAccessControl_ShouldChangeAccessControl() { - Skip.IfNot(Test.RunsOnWindows); - FileSystem.File.WriteAllText("foo", null); #pragma warning disable CA1416 FileSecurity originalAccessControl = FileSystem.CreateFileSecurity(); diff --git a/Tests/Testably.Abstractions.AccessControl.Tests/FileInfoAclExtensionsTests.cs b/Tests/Testably.Abstractions.AccessControl.Tests/FileInfoAclExtensionsTests.cs index 1ec17f01d..7c496db1c 100644 --- a/Tests/Testably.Abstractions.AccessControl.Tests/FileInfoAclExtensionsTests.cs +++ b/Tests/Testably.Abstractions.AccessControl.Tests/FileInfoAclExtensionsTests.cs @@ -5,13 +5,12 @@ namespace Testably.Abstractions.AccessControl.Tests; -[FileSystemTests] -public partial class FileInfoAclExtensionsTests +[WindowsOnlyFileSystemTests] +public class FileInfoAclExtensionsTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Fact] + [Test] public async Task GetAccessControl_MissingFile_ShouldThrowFileNotFoundException() { - Skip.IfNot(Test.RunsOnWindows); IFileInfo sut = FileSystem.FileInfo.New("foo"); void Act() @@ -25,11 +24,9 @@ await That(Act).Throws() .WithHResult(-2147024894); } - [Fact] + [Test] public async Task GetAccessControl_ShouldBeInitializedWithNotNullValue() { - Skip.IfNot(Test.RunsOnWindows); - FileSystem.File.WriteAllText("foo", null); IFileInfo fileInfo = FileSystem.FileInfo.New("foo"); @@ -40,10 +37,9 @@ public async Task GetAccessControl_ShouldBeInitializedWithNotNullValue() #pragma warning restore CA1416 } - [Fact] + [Test] public async Task GetAccessControl_ShouldReturnSetResult() { - Skip.IfNot(Test.RunsOnWindows); Skip.If(FileSystem is RealFileSystem); FileSystem.File.WriteAllText("foo", null); @@ -61,11 +57,10 @@ public async Task GetAccessControl_ShouldReturnSetResult() #pragma warning restore CA1416 } - [Fact] + [Test] public async Task GetAccessControl_WithAccessControlSections_MissingFile_ShouldThrowFileNotFoundException() { - Skip.IfNot(Test.RunsOnWindows); IFileInfo sut = FileSystem.FileInfo.New("foo"); void Act() @@ -79,10 +74,9 @@ await That(Act).Throws() .WithHResult(-2147024894); } - [Fact] + [Test] public async Task GetAccessControl_WithAccessControlSections_ShouldBeInitializedWithNotNullValue() { - Skip.IfNot(Test.RunsOnWindows); SkipIfLongRunningTestsShouldBeSkipped(); FileSystem.File.WriteAllText("foo", null); @@ -95,10 +89,9 @@ public async Task GetAccessControl_WithAccessControlSections_ShouldBeInitialized #pragma warning restore CA1416 } - [Fact] + [Test] public async Task GetAccessControl_WithAccessControlSections_ShouldReturnSetResult() { - Skip.IfNot(Test.RunsOnWindows); Skip.If(FileSystem is RealFileSystem); FileSystem.File.WriteAllText("foo", null); @@ -116,11 +109,9 @@ public async Task GetAccessControl_WithAccessControlSections_ShouldReturnSetResu #pragma warning restore CA1416 } - [Fact] + [Test] public async Task SetAccessControl_ShouldChangeAccessControl() { - Skip.IfNot(Test.RunsOnWindows); - FileSystem.File.WriteAllText("foo", null); #pragma warning disable CA1416 FileSecurity originalAccessControl = FileSystem.CreateFileSecurity(); diff --git a/Tests/Testably.Abstractions.AccessControl.Tests/FileStreamAclExtensionsTests.cs b/Tests/Testably.Abstractions.AccessControl.Tests/FileStreamAclExtensionsTests.cs index ab3f931f7..7f629a939 100644 --- a/Tests/Testably.Abstractions.AccessControl.Tests/FileStreamAclExtensionsTests.cs +++ b/Tests/Testably.Abstractions.AccessControl.Tests/FileStreamAclExtensionsTests.cs @@ -4,14 +4,12 @@ namespace Testably.Abstractions.AccessControl.Tests; -[FileSystemTests] -public partial class FileStreamAclExtensionsTests +[WindowsOnlyFileSystemTests] +public class FileStreamAclExtensionsTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Fact] + [Test] public async Task GetAccessControl_ShouldBeInitializedWithNotNullValue() { - Skip.IfNot(Test.RunsOnWindows); - FileSystemStream fileStream = FileSystem.File.Create("foo"); #pragma warning disable CA1416 @@ -21,11 +19,9 @@ public async Task GetAccessControl_ShouldBeInitializedWithNotNullValue() #pragma warning restore CA1416 } - [Fact] + [Test] public async Task SetAccessControl_ShouldChangeAccessControl() { - Skip.IfNot(Test.RunsOnWindows); - FileSystemStream fileStream = FileSystem.File.Create("foo"); #pragma warning disable CA1416 FileSecurity originalAccessControl = FileSystem.CreateFileSecurity(); diff --git a/Tests/Testably.Abstractions.AccessControl.Tests/Internal/AccessControlHelperTests.cs b/Tests/Testably.Abstractions.AccessControl.Tests/Internal/AccessControlHelperTests.cs index 2da50d046..e11221cce 100644 --- a/Tests/Testably.Abstractions.AccessControl.Tests/Internal/AccessControlHelperTests.cs +++ b/Tests/Testably.Abstractions.AccessControl.Tests/Internal/AccessControlHelperTests.cs @@ -1,15 +1,15 @@ -using System.IO; +using Mockolate; +using System.IO; using Testably.Abstractions.Helpers; namespace Testably.Abstractions.AccessControl.Tests.Internal; public sealed class AccessControlHelperTests { - [Theory] - [AutoDomainData] - public async Task GetExtensibilityOrThrow_CustomDirectoryInfo_ShouldThrowNotSupportedException( - IDirectoryInfo sut) + [Test] + public async Task GetExtensibilityOrThrow_CustomDirectoryInfo_ShouldThrowNotSupportedException() { + var sut = Mock.Create(); void Act() { sut.GetExtensibilityOrThrow(); @@ -19,11 +19,10 @@ await That(Act).Throws() .WithMessage($"*{sut.GetType().Name}*{nameof(IFileSystemExtensibility)}*").AsWildcard(); } - [Theory] - [AutoDomainData] - public async Task GetExtensibilityOrThrow_CustomFileInfo_ShouldThrowNotSupportedException( - IFileInfo sut) + [Test] + public async Task GetExtensibilityOrThrow_CustomFileInfo_ShouldThrowNotSupportedException() { + var sut = Mock.Create(); void Act() { sut.GetExtensibilityOrThrow(); @@ -33,7 +32,7 @@ await That(Act).Throws() .WithMessage($"*{sut.GetType().Name}*{nameof(IFileSystemExtensibility)}*").AsWildcard(); } - [Fact] + [Test] public async Task GetExtensibilityOrThrow_CustomFileSystemStream_ShouldThrowNotSupportedException() { @@ -48,7 +47,7 @@ await That(Act).Throws() .WithMessage($"*{sut.GetType().Name}*{nameof(IFileSystemExtensibility)}*").AsWildcard(); } - [Fact] + [Test] public async Task ThrowIfMissing_ExistingDirectoryInfo_ShouldNotThrow() { MockFileSystem fileSystem = new(); @@ -63,7 +62,7 @@ void Act() await That(Act).DoesNotThrow(); } - [Fact] + [Test] public async Task ThrowIfMissing_ExistingFileInfo_ShouldNotThrow() { MockFileSystem fileSystem = new(); @@ -78,7 +77,7 @@ void Act() await That(Act).DoesNotThrow(); } - [Fact] + [Test] public async Task ThrowIfMissing_MissingDirectoryInfo_ShouldThrowDirectoryNotFoundException() { MockFileSystem fileSystem = new(); @@ -94,7 +93,7 @@ await That(Act).Throws() .WithHResult(-2147024893); } - [Fact] + [Test] public async Task ThrowIfMissing_MissingFileInfo_ShouldThrowFileNotFoundException() { MockFileSystem fileSystem = new(); diff --git a/Tests/Testably.Abstractions.AccessControl.Tests/TestHelpers/Usings.cs b/Tests/Testably.Abstractions.AccessControl.Tests/TestHelpers/Usings.cs index 09bda3676..d4496bf17 100644 --- a/Tests/Testably.Abstractions.AccessControl.Tests/TestHelpers/Usings.cs +++ b/Tests/Testably.Abstractions.AccessControl.Tests/TestHelpers/Usings.cs @@ -4,6 +4,6 @@ global using Testably.Abstractions.TestHelpers; // ReSharper disable once RedundantUsingDirective.Global global using Testably.Abstractions.Testing; -global using Xunit; +global using TUnit; global using aweXpect; global using static aweXpect.Expect; diff --git a/Tests/Testably.Abstractions.AccessControl.Tests/TestHelpers/WindowsOnlyFileSystemTestsAttribute.cs b/Tests/Testably.Abstractions.AccessControl.Tests/TestHelpers/WindowsOnlyFileSystemTestsAttribute.cs new file mode 100644 index 000000000..25964f882 --- /dev/null +++ b/Tests/Testably.Abstractions.AccessControl.Tests/TestHelpers/WindowsOnlyFileSystemTestsAttribute.cs @@ -0,0 +1,23 @@ +using System.Collections.Generic; +using System.Runtime.InteropServices; + +namespace Testably.Abstractions.AccessControl.Tests.TestHelpers; + +[AttributeUsage(AttributeTargets.Class)] +public class WindowsOnlyFileSystemTestsAttribute : FileSystemTestsAttribute +{ + public override async IAsyncEnumerable>> GetTypedDataRowsAsync( + DataGeneratorMetadata dataGeneratorMetadata) + { + if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + yield break; + } + + await foreach (Func> baseDataRow in base.GetTypedDataRowsAsync( + dataGeneratorMetadata)) + { + yield return baseDataRow; + } + } +} diff --git a/Tests/Testably.Abstractions.AccessControl.Tests/Testably.Abstractions.AccessControl.Tests.csproj b/Tests/Testably.Abstractions.AccessControl.Tests/Testably.Abstractions.AccessControl.Tests.csproj index ab4215125..628ab49a0 100644 --- a/Tests/Testably.Abstractions.AccessControl.Tests/Testably.Abstractions.AccessControl.Tests.csproj +++ b/Tests/Testably.Abstractions.AccessControl.Tests/Testably.Abstractions.AccessControl.Tests.csproj @@ -8,18 +8,6 @@
- - - - - true - Generated - $(GeneratedFolder)\$(TargetFramework) - - - - - diff --git a/Tests/Testably.Abstractions.Compression.Tests/Internal/ExecuteTests.cs b/Tests/Testably.Abstractions.Compression.Tests/Internal/ExecuteTests.cs index a823dd0b0..34afd235a 100644 --- a/Tests/Testably.Abstractions.Compression.Tests/Internal/ExecuteTests.cs +++ b/Tests/Testably.Abstractions.Compression.Tests/Internal/ExecuteTests.cs @@ -4,7 +4,7 @@ namespace Testably.Abstractions.Compression.Tests.Internal; public sealed class ExecuteTests { - [Fact] + [Test] public async Task WhenRealFileSystem_MockFileSystem_WithActionCallback_ShouldExecuteOnMockFileSystem() { @@ -25,7 +25,7 @@ public async Task await That(onMockFileSystemExecuted).IsTrue(); } - [Fact] + [Test] public async Task WhenRealFileSystem_MockFileSystem_WithFuncCallback_ShouldExecuteOnMockFileSystem() { @@ -46,7 +46,7 @@ public async Task await That(onMockFileSystemExecuted).IsTrue(); } - [Fact] + [Test] public async Task WhenRealFileSystem_RealFileSystem_WithActionCallback_ShouldExecuteOnRealFileSystem() { @@ -67,7 +67,7 @@ public async Task await That(onMockFileSystemExecuted).IsFalse(); } - [Fact] + [Test] public async Task WhenRealFileSystem_RealFileSystem_WithFuncCallback_ShouldExecuteOnRealFileSystem() { @@ -88,7 +88,7 @@ public async Task await That(onMockFileSystemExecuted).IsFalse(); } - [Fact] + [Test] public async Task WhenRealFileSystemAsync_MockFileSystem_WithActionCallback_ShouldExecuteOnMockFileSystem() { @@ -110,7 +110,7 @@ await Execute.WhenRealFileSystemAsync(fileSystem, await That(onMockFileSystemExecuted).IsTrue(); } - [Fact] + [Test] public async Task WhenRealFileSystemAsync_MockFileSystem_WithFuncCallback_ShouldExecuteOnMockFileSystem() { @@ -132,7 +132,7 @@ await Execute.WhenRealFileSystemAsync(fileSystem, await That(onMockFileSystemExecuted).IsTrue(); } - [Fact] + [Test] public async Task WhenRealFileSystemAsync_RealFileSystem_WithActionCallback_ShouldExecuteOnRealFileSystem() { @@ -154,7 +154,7 @@ await Execute.WhenRealFileSystemAsync(fileSystem, await That(onMockFileSystemExecuted).IsFalse(); } - [Fact] + [Test] public async Task WhenRealFileSystemAsync_RealFileSystem_WithFuncCallback_ShouldExecuteOnRealFileSystem() { diff --git a/Tests/Testably.Abstractions.Compression.Tests/Internal/ZipUtilitiesTests.cs b/Tests/Testably.Abstractions.Compression.Tests/Internal/ZipUtilitiesTests.cs index d122dbc98..fb6afac90 100644 --- a/Tests/Testably.Abstractions.Compression.Tests/Internal/ZipUtilitiesTests.cs +++ b/Tests/Testably.Abstractions.Compression.Tests/Internal/ZipUtilitiesTests.cs @@ -6,8 +6,8 @@ namespace Testably.Abstractions.Compression.Tests.Internal; public sealed class ZipUtilitiesTests { - [Theory] - [AutoData] + [Test] + [Arguments(new byte[]{0x1, 0x2, 0x3})] public async Task ExtractRelativeToDirectory_FileWithTrailingSlash_ShouldThrowIOException( byte[] bytes) { @@ -25,7 +25,7 @@ await That(Act).Throws() .AsWildcard(); } - [Fact] + [Test] public async Task ExtractRelativeToDirectory_WithSubdirectory_ShouldCreateSubdirectory() { MockFileSystem fileSystem = new(); diff --git a/Tests/Testably.Abstractions.Compression.Tests/TestHelpers/Usings.cs b/Tests/Testably.Abstractions.Compression.Tests/TestHelpers/Usings.cs index 4de07faf6..53e1d42f0 100644 --- a/Tests/Testably.Abstractions.Compression.Tests/TestHelpers/Usings.cs +++ b/Tests/Testably.Abstractions.Compression.Tests/TestHelpers/Usings.cs @@ -1,10 +1,9 @@ -global using AutoFixture.Xunit3; -global using System; +global using System; global using System.Threading.Tasks; global using System.IO.Abstractions; global using Testably.Abstractions.TestHelpers; global using Testably.Abstractions.Testing; -global using Xunit; +global using TUnit; global using aweXpect; global using aweXpect.Testably; 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 f3c48c7f9..1e3249a8e 100644 --- a/Tests/Testably.Abstractions.Compression.Tests/Testably.Abstractions.Compression.Tests.csproj +++ b/Tests/Testably.Abstractions.Compression.Tests/Testably.Abstractions.Compression.Tests.csproj @@ -7,23 +7,11 @@
- - - - - - true - Generated - $(GeneratedFolder)\$(TargetFramework) - - - - diff --git a/Tests/Testably.Abstractions.Compression.Tests/ZipArchive/ExtensionTests.Async.cs b/Tests/Testably.Abstractions.Compression.Tests/ZipArchive/ExtensionTests.Async.cs index 35b79f2c1..386da80ce 100644 --- a/Tests/Testably.Abstractions.Compression.Tests/ZipArchive/ExtensionTests.Async.cs +++ b/Tests/Testably.Abstractions.Compression.Tests/ZipArchive/ExtensionTests.Async.cs @@ -8,10 +8,10 @@ namespace Testably.Abstractions.Compression.Tests.ZipArchive; public partial class ExtensionTests { - [Theory] - [InlineData("2000-01-01T12:14:15")] - [InlineData("1980-01-01T00:00:00")] - [InlineData("2107-12-31T23:59:59")] + [Test] + [Arguments("2000-01-01T12:14:15")] + [Arguments("1980-01-01T00:00:00")] + [Arguments("2107-12-31T23:59:59")] public async Task CreateEntryFromFileAsync_LastWriteTime_ShouldBeCopiedFromFile( string lastWriteTimeString) { @@ -30,17 +30,17 @@ public async Task CreateEntryFromFileAsync_LastWriteTime_ShouldBeCopiedFromFile( await That(archive.Entries).IsEmpty(); await archive.CreateEntryFromFileAsync("bar/foo.txt", "foo/bar.txt", - CompressionLevel.NoCompression, TestContext.Current.CancellationToken); + CompressionLevel.NoCompression, CancellationToken); IZipArchiveEntry entry = archive.Entries.Single(); await That(entry.LastWriteTime.DateTime).IsEqualTo(lastWriteTime); } - [Theory] - [InlineData("1930-06-21T14:15:16")] - [InlineData("1979-12-31T00:00:00")] - [InlineData("2108-01-01T00:00:00")] - [InlineData("2208-01-01T00:00:00")] + [Test] + [Arguments("1930-06-21T14:15:16")] + [Arguments("1979-12-31T00:00:00")] + [Arguments("2108-01-01T00:00:00")] + [Arguments("2208-01-01T00:00:00")] public async Task CreateEntryFromFileAsync_LastWriteTimeOutOfRange_ShouldBeFirstJanuary1980( string lastWriteTimeString) { @@ -61,13 +61,13 @@ public async Task CreateEntryFromFileAsync_LastWriteTimeOutOfRange_ShouldBeFirst await That(archive.Entries).IsEmpty(); await archive.CreateEntryFromFileAsync("bar/foo.txt", "foo/bar.txt", - CompressionLevel.NoCompression, TestContext.Current.CancellationToken); + CompressionLevel.NoCompression, CancellationToken); IZipArchiveEntry entry = archive.Entries.Single(); await That(entry.LastWriteTime.DateTime).IsEqualTo(expectedTime); } - [Fact] + [Test] public async Task CreateEntryFromFileAsync_NullEntryName_ShouldThrowArgumentNullException() { FileSystem.Initialize() @@ -83,13 +83,13 @@ public async Task CreateEntryFromFileAsync_NullEntryName_ShouldThrowArgumentNull await That(archive.Entries).IsEmpty(); Task Act() - => archive.CreateEntryFromFileAsync("bar/foo.txt", null!, TestContext.Current.CancellationToken); + => archive.CreateEntryFromFileAsync("bar/foo.txt", null!, CancellationToken); await That(Act).Throws() .WithParamName("entryName"); } - [Fact] + [Test] public async Task CreateEntryFromFileAsync_NullSourceFileName_ShouldThrowArgumentNullException() { FileSystem.Initialize() @@ -106,13 +106,13 @@ public async Task CreateEntryFromFileAsync_NullSourceFileName_ShouldThrowArgumen Task Act() => archive.CreateEntryFromFileAsync(null!, "foo/bar.txt", - CompressionLevel.NoCompression, TestContext.Current.CancellationToken); + CompressionLevel.NoCompression, CancellationToken); await That(Act).Throws() .WithParamName("sourceFileName"); } - [Fact] + [Test] public async Task CreateEntryFromFileAsync_ReadOnlyArchive_ShouldThrowNotSupportedException() { FileSystem.Initialize() @@ -128,12 +128,12 @@ public async Task CreateEntryFromFileAsync_ReadOnlyArchive_ShouldThrowNotSupport await That(archive.Entries).IsEmpty(); Task Act() - => archive.CreateEntryFromFileAsync("bar/foo.txt", "foo/bar.txt", TestContext.Current.CancellationToken); + => archive.CreateEntryFromFileAsync("bar/foo.txt", "foo/bar.txt", CancellationToken); await That(Act).Throws(); } - [Fact] + [Test] public async Task CreateEntryFromFileAsync_ShouldCreateEntryWithFileContent() { FileSystem.Initialize() @@ -149,7 +149,7 @@ public async Task CreateEntryFromFileAsync_ShouldCreateEntryWithFileContent() await That(archive.Entries).IsEmpty(); await archive.CreateEntryFromFileAsync("bar/foo.txt", "foo/bar.txt", - CompressionLevel.NoCompression, TestContext.Current.CancellationToken); + CompressionLevel.NoCompression, CancellationToken); IZipArchiveEntry entry = archive.Entries.Single(); await That(entry.FullName).IsEqualTo("foo/bar.txt"); @@ -158,8 +158,8 @@ await archive.CreateEntryFromFileAsync("bar/foo.txt", "foo/bar.txt", await That(FileSystem).HasFile("test.txt").WithContent("FooFooFoo"); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ExtractToDirectoryAsync_DestinationNull_ShouldThrowArgumentNullException( CompressionLevel compressionLevel) { @@ -174,15 +174,15 @@ async Task Act() using IZipArchive archive = FileSystem.ZipFile().Open("destination.zip", ZipArchiveMode.Read); - await archive.ExtractToDirectoryAsync(null!, TestContext.Current.CancellationToken); + await archive.ExtractToDirectoryAsync(null!, CancellationToken); } await That(Act).Throws() .WithParamName("destinationDirectoryName"); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ExtractToDirectoryAsync_DestinationNull_WithOverwrite_ShouldThrowArgumentNullException( CompressionLevel compressionLevel) @@ -198,13 +198,13 @@ async Task Act() using IZipArchive archive = FileSystem.ZipFile().Open("destination.zip", ZipArchiveMode.Read); - await archive.ExtractToDirectoryAsync(null!, true, TestContext.Current.CancellationToken); + await archive.ExtractToDirectoryAsync(null!, true, CancellationToken); } await That(Act).Throws(); } - [Fact] + [Test] public async Task ExtractToDirectoryAsync_ShouldExtractFilesAndDirectories() { FileSystem.Initialize() @@ -218,14 +218,14 @@ public async Task ExtractToDirectoryAsync_ShouldExtractFilesAndDirectories() using FileSystemStream stream = FileSystem.File.OpenRead("destination.zip"); IZipArchive archive = FileSystem.ZipArchive().New(stream, ZipArchiveMode.Read); - await archive.ExtractToDirectoryAsync("bar", TestContext.Current.CancellationToken); + await archive.ExtractToDirectoryAsync("bar", CancellationToken); await That(FileSystem).HasFile("bar/foo.txt").WithContent("FooFooFoo"); await That(FileSystem).HasDirectory("bar/bar"); await That(FileSystem).HasFile("bar/bar.txt"); } - [Fact] + [Test] public async Task ExtractToDirectoryAsync_WithoutOverwrite_ShouldThrowIOException() { FileSystem.Initialize() @@ -241,7 +241,7 @@ public async Task ExtractToDirectoryAsync_WithoutOverwrite_ShouldThrowIOExceptio async Task Act() { - await archive.ExtractToDirectoryAsync("bar", TestContext.Current.CancellationToken); + await archive.ExtractToDirectoryAsync("bar", CancellationToken); } await That(Act).Throws() @@ -250,7 +250,7 @@ await That(FileSystem).HasFile("bar/foo.txt") .WhoseContent(c => c.IsNotEqualTo("FooFooFoo")); } - [Fact] + [Test] public async Task ExtractToDirectoryAsync_WithOverwrite_ShouldOverwriteExistingFile() { FileSystem.Initialize() @@ -264,7 +264,7 @@ public async Task ExtractToDirectoryAsync_WithOverwrite_ShouldOverwriteExistingF using FileSystemStream stream = FileSystem.File.OpenRead("destination.zip"); IZipArchive archive = FileSystem.ZipArchive().New(stream, ZipArchiveMode.Read); - await archive.ExtractToDirectoryAsync("bar", true, TestContext.Current.CancellationToken); + await archive.ExtractToDirectoryAsync("bar", true, CancellationToken); await That(FileSystem).HasFile("bar/foo.txt") .WithContent("FooFooFoo"); diff --git a/Tests/Testably.Abstractions.Compression.Tests/ZipArchive/ExtensionTests.cs b/Tests/Testably.Abstractions.Compression.Tests/ZipArchive/ExtensionTests.cs index bf4d8dc18..40f2d70c0 100644 --- a/Tests/Testably.Abstractions.Compression.Tests/ZipArchive/ExtensionTests.cs +++ b/Tests/Testably.Abstractions.Compression.Tests/ZipArchive/ExtensionTests.cs @@ -6,12 +6,12 @@ namespace Testably.Abstractions.Compression.Tests.ZipArchive; [FileSystemTests] -public partial class ExtensionTests +public partial class ExtensionTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [InlineData("2000-01-01T12:14:15")] - [InlineData("1980-01-01T00:00:00")] - [InlineData("2107-12-31T23:59:59")] + [Test] + [Arguments("2000-01-01T12:14:15")] + [Arguments("1980-01-01T00:00:00")] + [Arguments("2107-12-31T23:59:59")] public async Task CreateEntryFromFile_LastWriteTime_ShouldBeCopiedFromFile( string lastWriteTimeString) { @@ -36,11 +36,11 @@ public async Task CreateEntryFromFile_LastWriteTime_ShouldBeCopiedFromFile( await That(entry.LastWriteTime.DateTime).IsEqualTo(lastWriteTime); } - [Theory] - [InlineData("1930-06-21T14:15:16")] - [InlineData("1979-12-31T00:00:00")] - [InlineData("2108-01-01T00:00:00")] - [InlineData("2208-01-01T00:00:00")] + [Test] + [Arguments("1930-06-21T14:15:16")] + [Arguments("1979-12-31T00:00:00")] + [Arguments("2108-01-01T00:00:00")] + [Arguments("2208-01-01T00:00:00")] public async Task CreateEntryFromFile_LastWriteTimeOutOfRange_ShouldBeFirstJanuary1980( string lastWriteTimeString) { @@ -67,7 +67,7 @@ public async Task CreateEntryFromFile_LastWriteTimeOutOfRange_ShouldBeFirstJanua await That(entry.LastWriteTime.DateTime).IsEqualTo(expectedTime); } - [Fact] + [Test] public async Task CreateEntryFromFile_NullEntryName_ShouldThrowArgumentNullException() { FileSystem.Initialize() @@ -89,7 +89,7 @@ await That(Act).Throws() .WithParamName("entryName"); } - [Fact] + [Test] public async Task CreateEntryFromFile_NullSourceFileName_ShouldThrowArgumentNullException() { FileSystem.Initialize() @@ -112,7 +112,7 @@ await That(Act).Throws() .WithParamName("sourceFileName"); } - [Fact] + [Test] public async Task CreateEntryFromFile_ReadOnlyArchive_ShouldThrowNotSupportedException() { FileSystem.Initialize() @@ -133,7 +133,7 @@ void Act() await That(Act).Throws(); } - [Fact] + [Test] public async Task CreateEntryFromFile_ShouldCreateEntryWithFileContent() { FileSystem.Initialize() @@ -158,8 +158,8 @@ public async Task CreateEntryFromFile_ShouldCreateEntryWithFileContent() await That(FileSystem).HasFile("test.txt").WithContent("FooFooFoo"); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ExtractToDirectory_DestinationNull_ShouldThrowArgumentNullException( CompressionLevel compressionLevel) { @@ -182,8 +182,8 @@ await That(Act).Throws() } #if FEATURE_COMPRESSION_ADVANCED - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ExtractToDirectory_DestinationNull_WithOverwrite_ShouldThrowArgumentNullException( CompressionLevel compressionLevel) @@ -206,7 +206,7 @@ void Act() } #endif - [Fact] + [Test] public async Task ExtractToDirectory_ShouldExtractFilesAndDirectories() { FileSystem.Initialize() @@ -227,7 +227,7 @@ public async Task ExtractToDirectory_ShouldExtractFilesAndDirectories() await That(FileSystem).HasFile("bar/bar.txt"); } - [Fact] + [Test] public async Task ExtractToDirectory_WithoutOverwrite_ShouldThrowIOException() { FileSystem.Initialize() @@ -253,7 +253,7 @@ await That(FileSystem).HasFile("bar/foo.txt") } #if FEATURE_COMPRESSION_ADVANCED - [Fact] + [Test] public async Task ExtractToDirectory_WithOverwrite_ShouldOverwriteExistingFile() { FileSystem.Initialize() diff --git a/Tests/Testably.Abstractions.Compression.Tests/ZipArchive/Tests.cs b/Tests/Testably.Abstractions.Compression.Tests/ZipArchive/Tests.cs index 282ce91e7..0d58fed64 100644 --- a/Tests/Testably.Abstractions.Compression.Tests/ZipArchive/Tests.cs +++ b/Tests/Testably.Abstractions.Compression.Tests/ZipArchive/Tests.cs @@ -5,10 +5,10 @@ namespace Testably.Abstractions.Compression.Tests.ZipArchive; [FileSystemTests] -public partial class Tests +public class Tests(FileSystemTestData testData) : FileSystemTestBase(testData) { #if FEATURE_FILESYSTEM_COMMENT_ENCRYPTED - [Fact] + [Test] public async Task Comment_ShouldBeInitializedEmpty() { FileSystem.Initialize() @@ -26,8 +26,8 @@ public async Task Comment_ShouldBeInitializedEmpty() } #endif #if FEATURE_FILESYSTEM_COMMENT_ENCRYPTED - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Comment_ShouldBeSettable(string comment) { FileSystem.Initialize() @@ -46,7 +46,7 @@ public async Task Comment_ShouldBeSettable(string comment) } #endif - [Fact] + [Test] public async Task Entries_CreateMode_ShouldThrowNotSupportedException() { using FileSystemStream stream = @@ -59,8 +59,8 @@ public async Task Entries_CreateMode_ShouldThrowNotSupportedException() await That(Act).Throws(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task FileSystem_ShouldBeSet( CompressionLevel compressionLevel) { @@ -76,7 +76,7 @@ public async Task FileSystem_ShouldBeSet( await That(archive.FileSystem).IsEqualTo(FileSystem); } - [Fact] + [Test] public async Task GetEntry_WhenNameIsNotFound_ShouldReturnNull() { FileSystem.Initialize() @@ -94,8 +94,8 @@ public async Task GetEntry_WhenNameIsNotFound_ShouldReturnNull() await That(archive.GetEntry("foo/foo.txt")).IsNotNull(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Mode_ShouldBeSetCorrectly(ZipArchiveMode mode) { FileSystem.Initialize() diff --git a/Tests/Testably.Abstractions.Compression.Tests/ZipArchiveEntry/ExtensionTests.Async.cs b/Tests/Testably.Abstractions.Compression.Tests/ZipArchiveEntry/ExtensionTests.Async.cs index 5318cacbb..5fdb0defa 100644 --- a/Tests/Testably.Abstractions.Compression.Tests/ZipArchiveEntry/ExtensionTests.Async.cs +++ b/Tests/Testably.Abstractions.Compression.Tests/ZipArchiveEntry/ExtensionTests.Async.cs @@ -8,7 +8,7 @@ namespace Testably.Abstractions.Compression.Tests.ZipArchiveEntry; public partial class ExtensionTests { - [Fact] + [Test] public async Task ExtractToFileAsync_AccessLengthOnWritableStream_ShouldThrowInvalidOperationException() { @@ -24,13 +24,13 @@ public async Task archive.CreateEntryFromFile("foo.txt", "foo/"); Task Act() - => archive.ExtractToDirectoryAsync("bar", TestContext.Current.CancellationToken); + => archive.ExtractToDirectoryAsync("bar", CancellationToken); await That(Act).Throws(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ExtractToFileAsync_DestinationNull_ShouldThrowArgumentNullException( CompressionLevel compressionLevel) { @@ -46,15 +46,15 @@ async Task Act() using IZipArchive archive = FileSystem.ZipFile().Open("destination.zip", ZipArchiveMode.Read); - await archive.Entries.Single().ExtractToFileAsync(null!, TestContext.Current.CancellationToken); + await archive.Entries.Single().ExtractToFileAsync(null!, CancellationToken); } await That(Act).Throws() .WithParamName("destinationFileName"); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ExtractToFileAsync_DestinationNull_WithOverwrite_ShouldThrowArgumentNullException( CompressionLevel compressionLevel) @@ -71,13 +71,13 @@ async Task Act() using IZipArchive archive = FileSystem.ZipFile().Open("destination.zip", ZipArchiveMode.Read); - await archive.Entries.Single().ExtractToFileAsync(null!, true, TestContext.Current.CancellationToken); + await archive.Entries.Single().ExtractToFileAsync(null!, true, CancellationToken); } await That(Act).Throws(); } - [Fact] + [Test] public async Task ExtractToFileAsync_IncorrectEntryType_ShouldThrowIOException() { FileSystem.Initialize() @@ -96,15 +96,15 @@ public async Task ExtractToFileAsync_IncorrectEntryType_ShouldThrowIOException() IZipArchive archive2 = FileSystem.ZipArchive().New(stream2, ZipArchiveMode.Read); Task Act() - => archive2.ExtractToDirectoryAsync("bar", TestContext.Current.CancellationToken); + => archive2.ExtractToDirectoryAsync("bar", CancellationToken); await That(Act).Throws(); } - [Theory] - [InlineData("2000-01-01T12:14:15")] - [InlineData("1980-01-01T00:00:00")] - [InlineData("2107-12-31T23:59:59")] + [Test] + [Arguments("2000-01-01T12:14:15")] + [Arguments("1980-01-01T00:00:00")] + [Arguments("2107-12-31T23:59:59")] public async Task ExtractToFileAsync_LastWriteTime_ShouldBeCopiedFromFile(string lastWriteTimeString) { DateTime lastWriteTime = DateTime.Parse(lastWriteTimeString, CultureInfo.InvariantCulture); @@ -124,14 +124,14 @@ public async Task ExtractToFileAsync_LastWriteTime_ShouldBeCopiedFromFile(string CompressionLevel.NoCompression); IZipArchiveEntry entry = archive.Entries.Single(); - await entry.ExtractToFileAsync("bar/bar.txt", true, TestContext.Current.CancellationToken); + await entry.ExtractToFileAsync("bar/bar.txt", true, CancellationToken); await That(FileSystem).HasFile("bar/bar.txt") .WithContent("FooFooFoo").And .WithLastWriteTime(lastWriteTime); } - [Fact] + [Test] public async Task ExtractToFileAsync_WithoutOverwrite_ShouldThrowIOException() { FileSystem.Initialize() @@ -147,7 +147,7 @@ public async Task ExtractToFileAsync_WithoutOverwrite_ShouldThrowIOException() IZipArchiveEntry entry = archive.Entries.Single(); Task Act() - => entry.ExtractToFileAsync("bar/bar.txt", TestContext.Current.CancellationToken); + => entry.ExtractToFileAsync("bar/bar.txt", CancellationToken); await That(Act).Throws() .WithMessage($"*'{FileSystem.Path.GetFullPath("bar/bar.txt")}'*").AsWildcard(); @@ -155,7 +155,7 @@ await That(FileSystem).HasFile("bar/bar.txt") .WhoseContent(f => f.IsNotEqualTo("FooFooFoo")); } - [Fact] + [Test] public async Task ExtractToFileAsync_WithOverwrite_ShouldOverwriteExistingFile() { FileSystem.Initialize() @@ -170,7 +170,7 @@ public async Task ExtractToFileAsync_WithOverwrite_ShouldOverwriteExistingFile() IZipArchive archive = FileSystem.ZipArchive().New(stream, ZipArchiveMode.Read); IZipArchiveEntry entry = archive.Entries.Single(); - await entry.ExtractToFileAsync("bar/bar.txt", true, TestContext.Current.CancellationToken); + await entry.ExtractToFileAsync("bar/bar.txt", true, CancellationToken); await That(FileSystem).HasFile("bar/bar.txt") .WithContent("FooFooFoo"); diff --git a/Tests/Testably.Abstractions.Compression.Tests/ZipArchiveEntry/ExtensionTests.cs b/Tests/Testably.Abstractions.Compression.Tests/ZipArchiveEntry/ExtensionTests.cs index c8e643e51..491399144 100644 --- a/Tests/Testably.Abstractions.Compression.Tests/ZipArchiveEntry/ExtensionTests.cs +++ b/Tests/Testably.Abstractions.Compression.Tests/ZipArchiveEntry/ExtensionTests.cs @@ -6,9 +6,9 @@ namespace Testably.Abstractions.Compression.Tests.ZipArchiveEntry; [FileSystemTests] -public partial class ExtensionTests +public partial class ExtensionTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Fact] + [Test] public async Task ExtractToFile_AccessLengthOnWritableStream_ShouldThrowInvalidOperationException() { @@ -29,8 +29,8 @@ void Act() await That(Act).Throws(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ExtractToFile_DestinationNull_ShouldThrowArgumentNullException( CompressionLevel compressionLevel) { @@ -53,8 +53,8 @@ await That(Act).Throws() .WithParamName("destinationFileName"); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ExtractToFile_DestinationNull_WithOverwrite_ShouldThrowArgumentNullException( CompressionLevel compressionLevel) @@ -77,7 +77,7 @@ void Act() await That(Act).Throws(); } - [Fact] + [Test] public async Task ExtractToFile_IncorrectEntryType_ShouldThrowIOException() { FileSystem.Initialize() @@ -101,10 +101,10 @@ void Act() await That(Act).Throws(); } - [Theory] - [InlineData("2000-01-01T12:14:15")] - [InlineData("1980-01-01T00:00:00")] - [InlineData("2107-12-31T23:59:59")] + [Test] + [Arguments("2000-01-01T12:14:15")] + [Arguments("1980-01-01T00:00:00")] + [Arguments("2107-12-31T23:59:59")] public async Task ExtractToFile_LastWriteTime_ShouldBeCopiedFromFile(string lastWriteTimeString) { DateTime lastWriteTime = DateTime.Parse(lastWriteTimeString, CultureInfo.InvariantCulture); @@ -131,7 +131,7 @@ await That(FileSystem).HasFile("bar/bar.txt") .WithLastWriteTime(lastWriteTime); } - [Fact] + [Test] public async Task ExtractToFile_WithoutOverwrite_ShouldThrowIOException() { FileSystem.Initialize() @@ -157,7 +157,7 @@ await That(FileSystem).HasFile("bar/bar.txt") .WhoseContent(f => f.IsNotEqualTo("FooFooFoo")); } - [Fact] + [Test] public async Task ExtractToFile_WithOverwrite_ShouldOverwriteExistingFile() { FileSystem.Initialize() diff --git a/Tests/Testably.Abstractions.Compression.Tests/ZipArchiveEntry/Tests.cs b/Tests/Testably.Abstractions.Compression.Tests/ZipArchiveEntry/Tests.cs index afeacae20..31cc19e19 100644 --- a/Tests/Testably.Abstractions.Compression.Tests/ZipArchiveEntry/Tests.cs +++ b/Tests/Testably.Abstractions.Compression.Tests/ZipArchiveEntry/Tests.cs @@ -6,9 +6,9 @@ namespace Testably.Abstractions.Compression.Tests.ZipArchiveEntry; [FileSystemTests] -public partial class Tests +public class Tests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Fact] + [Test] public async Task Archive_ShouldBeSetToArchive() { FileSystem.Initialize() @@ -28,7 +28,7 @@ public async Task Archive_ShouldBeSetToArchive() } #if FEATURE_FILESYSTEM_COMMENT_ENCRYPTED - [Fact] + [Test] public async Task Comment_ShouldBeInitializedEmpty() { FileSystem.Initialize() @@ -48,8 +48,8 @@ public async Task Comment_ShouldBeInitializedEmpty() #endif #if FEATURE_FILESYSTEM_COMMENT_ENCRYPTED - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Comment_ShouldBeSettable(string comment) { FileSystem.Initialize() @@ -70,7 +70,7 @@ public async Task Comment_ShouldBeSettable(string comment) } #endif - [Fact] + [Test] public async Task CompressedLength_WithNoCompression_ShouldBeFileLength() { Skip.If(Test.IsNetFramework, "Test is brittle on .NET Framework."); @@ -91,7 +91,7 @@ await That(archive.Entries.Single()) .For(x => x.CompressedLength, l => l.IsEqualTo(9)); } - [Fact] + [Test] public async Task CompressedLength_WithOptimalCompressionLevel_ShouldBeLessThanFileLength() { FileSystem.Initialize() @@ -111,7 +111,7 @@ await That(archive.Entries.Single()) } #if FEATURE_COMPRESSION_ADVANCED - [Fact] + [Test] public async Task Crc32_ShouldBeCalculatedFromTheFileContent() { FileSystem.Initialize() @@ -133,7 +133,7 @@ public async Task Crc32_ShouldBeCalculatedFromTheFileContent() } #endif - [Fact] + [Test] public async Task Delete_ReadMode_ShouldThrowNotSupportedException() { FileSystem.Initialize() @@ -154,7 +154,7 @@ public async Task Delete_ReadMode_ShouldThrowNotSupportedException() await That(Act).Throws(); } - [Fact] + [Test] public async Task Delete_ShouldRemoveEntryFromArchive() { FileSystem.Initialize() @@ -176,8 +176,8 @@ public async Task Delete_ShouldRemoveEntryFromArchive() } #if FEATURE_COMPRESSION_ADVANCED - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ExternalAttributes_ShouldBeSettable(int externalAttributes) { FileSystem.Initialize() @@ -201,7 +201,7 @@ public async Task ExternalAttributes_ShouldBeSettable(int externalAttributes) } #endif - [Fact] + [Test] public async Task FileSystemExtension_ShouldBeSet() { FileSystem.Initialize() @@ -220,7 +220,7 @@ public async Task FileSystemExtension_ShouldBeSet() await That(entry.FileSystem).IsEqualTo(FileSystem); } - [Fact] + [Test] public async Task FullName_ShouldIncludeDirectory() { FileSystem.Initialize() @@ -240,8 +240,8 @@ public async Task FullName_ShouldIncludeDirectory() await That(entry.Name).IsEqualTo("foo.txt"); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task LastWriteTime_ReadOnlyArchive_ShouldThrowNotSupportedException( DateTime lastWriteTime) { @@ -267,8 +267,8 @@ void Act() await That(Act).Throws(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task LastWriteTime_ShouldBeSettable(DateTime lastWriteTime) { FileSystem.Initialize() @@ -292,7 +292,7 @@ public async Task LastWriteTime_ShouldBeSettable(DateTime lastWriteTime) await That(entry2.LastWriteTime.DateTime).IsNotEqualTo(lastWriteTime); } - [Fact] + [Test] public async Task Open_ShouldBeSetToFileName() { FileSystem.Initialize() @@ -314,7 +314,7 @@ public async Task Open_ShouldBeSetToFileName() } #if FEATURE_COMPRESSION_ASYNC - [Fact] + [Test] public async Task OpenAsync_ShouldBeSetToFileName() { FileSystem.Initialize() @@ -330,13 +330,13 @@ public async Task OpenAsync_ShouldBeSetToFileName() IZipArchive archive = FileSystem.ZipArchive().New(stream, ZipArchiveMode.Update); IZipArchiveEntry entry = archive.Entries.Single(); - Stream resultStream = await entry.OpenAsync(TestContext.Current.CancellationToken); + Stream resultStream = await entry.OpenAsync(CancellationToken); await That(resultStream).HasLength().EqualTo("FooFooFoo".Length); } #endif - [Fact] + [Test] public async Task ToString_ShouldBeSetToFileName() { FileSystem.Initialize() diff --git a/Tests/Testably.Abstractions.Compression.Tests/ZipArchiveFactory/Tests.cs b/Tests/Testably.Abstractions.Compression.Tests/ZipArchiveFactory/Tests.cs index d3a49593d..236336b3c 100644 --- a/Tests/Testably.Abstractions.Compression.Tests/ZipArchiveFactory/Tests.cs +++ b/Tests/Testably.Abstractions.Compression.Tests/ZipArchiveFactory/Tests.cs @@ -1,13 +1,14 @@ -using System.IO; +using System.Collections.Generic; +using System.IO; using System.IO.Compression; using System.Text; namespace Testably.Abstractions.Compression.Tests.ZipArchiveFactory; [FileSystemTests] -public partial class Tests +public class Tests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Fact] + [Test] public async Task New_ShouldOpenWithReadMode() { FileSystem.Initialize() @@ -25,7 +26,7 @@ public async Task New_ShouldOpenWithReadMode() await That(archive.Entries).HasCount().EqualTo(1); } - [Fact] + [Test] public async Task New_UpdateMode_ReadOnlyStream_ShouldThrowArgumentException() { FileSystem.Initialize() @@ -46,7 +47,7 @@ await That(Act).Throws() .WithHResult(-2147024809); } - [Fact] + [Test] public async Task New_UpdateMode_ShouldOpenArchive() { FileSystem.Initialize() @@ -65,9 +66,9 @@ public async Task New_UpdateMode_ShouldOpenArchive() await That(archive.Entries).HasCount().EqualTo(1); } - [Theory] - [InlineData(true)] - [InlineData(false)] + [Test] + [Arguments(true)] + [Arguments(false)] public async Task New_WhenLeaveOpen_ShouldDisposeStreamWhenDisposingArchive(bool leaveOpen) { FileSystem.Initialize() @@ -88,8 +89,8 @@ public async Task New_WhenLeaveOpen_ShouldDisposeStreamWhenDisposingArchive(bool await That(Act).Throws().OnlyIf(!leaveOpen); } - [Theory] - [MemberData(nameof(EntryNameEncoding))] + [Test] + [MethodDataSource(nameof(EntryNameEncoding))] public async Task New_WithEntryNameEncoding_ShouldUseEncoding( string entryName, Encoding encoding, bool encodedCorrectly) { @@ -119,23 +120,12 @@ public async Task New_WithEntryNameEncoding_ShouldUseEncoding( #region Helpers - #pragma warning disable MA0018 - public static TheoryData EntryNameEncoding() + public static IEnumerable> EntryNameEncoding() { // ReSharper disable StringLiteralTypo - TheoryData theoryData = new() - { - { - "Dans mes rêves.mp3", Encoding.Default, true - }, - { - "Dans mes rêves.mp3", Encoding.ASCII, false - }, - }; - // ReSharper restore StringLiteralTypo - return theoryData; + yield return () => ("Dans mes rêves.mp3", Encoding.Default, true); + yield return () => ("Dans mes rêves.mp3", Encoding.ASCII, false); } - #pragma warning restore MA0018 #endregion } diff --git a/Tests/Testably.Abstractions.Compression.Tests/ZipFile/CreateFromDirectoryAsyncTests.cs b/Tests/Testably.Abstractions.Compression.Tests/ZipFile/CreateFromDirectoryAsyncTests.cs index 56cc5b517..1a2d75576 100644 --- a/Tests/Testably.Abstractions.Compression.Tests/ZipFile/CreateFromDirectoryAsyncTests.cs +++ b/Tests/Testably.Abstractions.Compression.Tests/ZipFile/CreateFromDirectoryAsyncTests.cs @@ -1,4 +1,5 @@ #if FEATURE_COMPRESSION_ASYNC +using System.Collections.Generic; using System.IO.Compression; using System.Text; #if FEATURE_COMPRESSION_STREAM @@ -9,10 +10,10 @@ namespace Testably.Abstractions.Compression.Tests.ZipFile; [FileSystemTests] -public partial class CreateFromDirectoryAsyncTests +public class CreateFromDirectoryAsyncTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateFromDirectoryAsync_EmptyDirectory_ShouldBeIncluded( CompressionLevel compressionLevel) @@ -23,7 +24,7 @@ public async Task await FileSystem.ZipFile() .CreateFromDirectoryAsync("foo", "destination.zip", compressionLevel, false, - TestContext.Current.CancellationToken); + CancellationToken); using IZipArchive archive = FileSystem.ZipFile().Open("destination.zip", ZipArchiveMode.Read); @@ -32,8 +33,8 @@ await That(archive.Entries).HasSingle() .Which.For(x => x.FullName, f => f.IsEqualTo("bar/")); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateFromDirectoryAsync_EmptySource_DoNotIncludeBaseDirectory_ShouldBeEmpty( CompressionLevel compressionLevel) { @@ -42,7 +43,7 @@ public async Task CreateFromDirectoryAsync_EmptySource_DoNotIncludeBaseDirectory await FileSystem.ZipFile() .CreateFromDirectoryAsync("foo", "destination.zip", compressionLevel, false, - TestContext.Current.CancellationToken); + CancellationToken); using IZipArchive archive = FileSystem.ZipFile().Open("destination.zip", ZipArchiveMode.Read); @@ -50,8 +51,8 @@ await FileSystem.ZipFile() await That(archive.Entries).IsEmpty(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateFromDirectoryAsync_EmptySource_IncludeBaseDirectory_ShouldPrependDirectoryName( CompressionLevel compressionLevel) @@ -61,7 +62,7 @@ public async Task await FileSystem.ZipFile() .CreateFromDirectoryAsync("foo", "destination.zip", compressionLevel, true, - TestContext.Current.CancellationToken); + CancellationToken); using IZipArchive archive = FileSystem.ZipFile().Open("destination.zip", ZipArchiveMode.Read); @@ -70,8 +71,8 @@ await That(archive.Entries).HasSingle() .Which.For(x => x.FullName, f => f.IsEqualTo("foo/")); } - [Theory] - [MemberData(nameof(EntryNameEncoding))] + [Test] + [MethodDataSource(nameof(EntryNameEncoding))] public async Task CreateFromDirectoryAsync_EntryNameEncoding_ShouldUseEncoding( string entryName, Encoding encoding, bool encodedCorrectly) { @@ -81,7 +82,7 @@ public async Task CreateFromDirectoryAsync_EntryNameEncoding_ShouldUseEncoding( await FileSystem.ZipFile() .CreateFromDirectoryAsync("foo", "destination.zip", CompressionLevel.NoCompression, - false, encoding, TestContext.Current.CancellationToken); + false, encoding, CancellationToken); using IZipArchive archive = FileSystem.ZipFile().Open("destination.zip", ZipArchiveMode.Read); @@ -97,8 +98,8 @@ await FileSystem.ZipFile() } } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateFromDirectoryAsync_IncludeBaseDirectory_ShouldPrependDirectoryName( CompressionLevel compressionLevel) { @@ -108,7 +109,7 @@ public async Task CreateFromDirectoryAsync_IncludeBaseDirectory_ShouldPrependDir await FileSystem.ZipFile() .CreateFromDirectoryAsync("foo", "destination.zip", compressionLevel, true, - TestContext.Current.CancellationToken); + CancellationToken); using IZipArchive archive = FileSystem.ZipFile().Open("destination.zip", ZipArchiveMode.Read); @@ -117,8 +118,8 @@ await That(archive.Entries).HasSingle() .Which.For(x => x.FullName, f => f.IsEqualTo("foo/test.txt")); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateFromDirectoryAsync_Overwrite_WithEncoding_ShouldOverwriteFile( string contents, Encoding encoding) { @@ -131,7 +132,7 @@ public async Task CreateFromDirectoryAsync_Overwrite_WithEncoding_ShouldOverwrit contents); await FileSystem.ZipFile().CreateFromDirectoryAsync("foo", "destination.zip", - CompressionLevel.Optimal, false, encoding, TestContext.Current.CancellationToken); + CompressionLevel.Optimal, false, encoding, CancellationToken); IZipArchive archive = FileSystem.ZipFile() .Open("destination.zip", ZipArchiveMode.Read, encoding); @@ -140,7 +141,7 @@ await That(archive.Entries).HasSingle() .Which.For(x => x.FullName, f => f.IsEqualTo("test.txt")); } - [Fact] + [Test] public async Task CreateFromDirectoryAsync_ShouldZipDirectoryContent() { FileSystem.Initialize() @@ -150,7 +151,7 @@ public async Task CreateFromDirectoryAsync_ShouldZipDirectoryContent() .WithFile("test.txt"))); await FileSystem.ZipFile().CreateFromDirectoryAsync("foo", "destination.zip", - TestContext.Current.CancellationToken); + CancellationToken); FileSystem.ZipFile().ExtractToDirectory("destination.zip", "destination"); @@ -158,7 +159,7 @@ await That(FileSystem).HasFile("destination/bar/test.txt") .WithContent().SameAs("foo/bar/test.txt"); } - [Fact] + [Test] public async Task CreateFromDirectoryAsync_WithReadOnlyStream_ShouldThrowArgumentException() { FileSystem.Initialize() @@ -171,7 +172,7 @@ public async Task CreateFromDirectoryAsync_WithReadOnlyStream_ShouldThrowArgumen async Task Act() { // ReSharper disable once AccessToDisposedClosure - await FileSystem.ZipFile().CreateFromDirectoryAsync("foo", stream, TestContext.Current.CancellationToken); + await FileSystem.ZipFile().CreateFromDirectoryAsync("foo", stream, CancellationToken); } await That(Act).Throws() @@ -180,8 +181,8 @@ await That(Act).Throws() .WithHResult(-2147024809); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateFromDirectoryAsync_WithStream_EmptyDirectory_ShouldBeIncluded( CompressionLevel compressionLevel) @@ -193,7 +194,7 @@ public async Task await FileSystem.ZipFile() .CreateFromDirectoryAsync("foo", stream, compressionLevel, false, - TestContext.Current.CancellationToken); + CancellationToken); using IZipArchive archive = FileSystem.ZipArchive().New(stream, ZipArchiveMode.Read); @@ -201,8 +202,8 @@ await That(archive.Entries).HasSingle() .Which.For(x => x.FullName, f => f.IsEqualTo("bar/")); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateFromDirectoryAsync_WithStream_EmptySource_DoNotIncludeBaseDirectory_ShouldBeEmpty( CompressionLevel compressionLevel) @@ -213,15 +214,15 @@ public async Task await FileSystem.ZipFile() .CreateFromDirectoryAsync("foo", stream, compressionLevel, false, - TestContext.Current.CancellationToken); + CancellationToken); using IZipArchive archive = FileSystem.ZipArchive().New(stream, ZipArchiveMode.Read); await That(archive.Entries).IsEmpty(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateFromDirectoryAsync_WithStream_EmptySource_IncludeBaseDirectory_ShouldPrependDirectoryName( CompressionLevel compressionLevel) @@ -232,7 +233,7 @@ public async Task await FileSystem.ZipFile() .CreateFromDirectoryAsync("foo", stream, compressionLevel, true, - TestContext.Current.CancellationToken); + CancellationToken); using IZipArchive archive = FileSystem.ZipArchive().New(stream, ZipArchiveMode.Read); @@ -240,8 +241,8 @@ await That(archive.Entries).HasSingle() .Which.For(x => x.FullName, f => f.IsEqualTo("foo/")); } - [Theory] - [MemberData(nameof(EntryNameEncoding))] + [Test] + [MethodDataSource(nameof(EntryNameEncoding))] public async Task CreateFromDirectoryAsync_WithStream_EntryNameEncoding_ShouldUseEncoding( string entryName, Encoding encoding, bool encodedCorrectly) { @@ -252,7 +253,7 @@ public async Task CreateFromDirectoryAsync_WithStream_EntryNameEncoding_ShouldUs await FileSystem.ZipFile() .CreateFromDirectoryAsync("foo", stream, CompressionLevel.NoCompression, - false, encoding, TestContext.Current.CancellationToken); + false, encoding, CancellationToken); using IZipArchive archive = FileSystem.ZipArchive().New(stream, ZipArchiveMode.Read); @@ -267,8 +268,8 @@ await FileSystem.ZipFile() } } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateFromDirectoryAsync_WithStream_IncludeBaseDirectory_ShouldPrependDirectoryName( CompressionLevel compressionLevel) @@ -280,7 +281,7 @@ public async Task await FileSystem.ZipFile() .CreateFromDirectoryAsync("foo", stream, compressionLevel, true, - TestContext.Current.CancellationToken); + CancellationToken); using IZipArchive archive = FileSystem.ZipArchive().New(stream, ZipArchiveMode.Read); @@ -288,7 +289,7 @@ await That(archive.Entries).HasSingle() .Which.For(x => x.FullName, f => f.IsEqualTo("foo/test.txt")); } - [Fact] + [Test] public async Task CreateFromDirectoryAsync_WithStream_NotWritable_ShouldThrowArgumentException() { @@ -296,7 +297,7 @@ public async Task async Task Act() { - await FileSystem.ZipFile().CreateFromDirectoryAsync("foo", stream, TestContext.Current.CancellationToken); + await FileSystem.ZipFile().CreateFromDirectoryAsync("foo", stream, CancellationToken); } await That(Act).Throws() @@ -305,7 +306,7 @@ await That(Act).Throws() .WithHResult(-2147024809); } - [Fact] + [Test] public async Task CreateFromDirectoryAsync_WithStream_Null_ShouldThrowArgumentNullException() { @@ -313,15 +314,15 @@ public async Task async Task Act() { - await FileSystem.ZipFile().CreateFromDirectoryAsync("foo", stream, TestContext.Current.CancellationToken); + await FileSystem.ZipFile().CreateFromDirectoryAsync("foo", stream, CancellationToken); } await That(Act).Throws() .WithParamName("destination"); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateFromDirectoryAsync_WithStream_Overwrite_WithEncoding_ShouldOverwriteFile( string contents, Encoding encoding) @@ -336,7 +337,7 @@ public async Task using MemoryStream stream = new(); await FileSystem.ZipFile().CreateFromDirectoryAsync("foo", stream, - CompressionLevel.Optimal, false, encoding, TestContext.Current.CancellationToken); + CompressionLevel.Optimal, false, encoding, CancellationToken); IZipArchive archive = FileSystem.ZipArchive().New(stream, ZipArchiveMode.Read, true, encoding); @@ -345,7 +346,7 @@ await That(archive.Entries).HasSingle() .Which.For(x => x.FullName, f => f.IsEqualTo("test.txt")); } - [Fact] + [Test] public async Task CreateFromDirectoryAsync_WithStream_ShouldZipDirectoryContent() { FileSystem.Initialize() @@ -356,7 +357,7 @@ public async Task CreateFromDirectoryAsync_WithStream_ShouldZipDirectoryContent( using MemoryStream stream = new(); await FileSystem.ZipFile() - .CreateFromDirectoryAsync("foo", stream, TestContext.Current.CancellationToken); + .CreateFromDirectoryAsync("foo", stream, CancellationToken); FileSystem.ZipFile().ExtractToDirectory(stream, "destination"); @@ -364,7 +365,7 @@ await That(FileSystem).HasFile("destination/bar/test.txt") .WithContent().SameAs("foo/bar/test.txt"); } - [Fact] + [Test] public async Task ShouldNotLock() { string directory = "ToBeZipped"; @@ -375,30 +376,19 @@ public async Task ShouldNotLock() void Act() => FileSystem.Directory.Delete(directory, true); await FileSystem.ZipFile() - .CreateFromDirectoryAsync(directory, archive, TestContext.Current.CancellationToken); + .CreateFromDirectoryAsync(directory, archive, CancellationToken); await That(Act).DoesNotThrow(); } #region Helpers - #pragma warning disable MA0018 - public static TheoryData EntryNameEncoding() + public static IEnumerable> EntryNameEncoding() { // ReSharper disable StringLiteralTypo - TheoryData theoryData = new() - { - { - "Dans mes rêves.mp3", Encoding.Default, true - }, - { - "Dans mes rêves.mp3", Encoding.ASCII, false - }, - }; - // ReSharper restore StringLiteralTypo - return theoryData; + yield return () => ("Dans mes rêves.mp3", Encoding.Default, true); + yield return () => ("Dans mes rêves.mp3", Encoding.ASCII, false); } - #pragma warning restore MA0018 #endregion } diff --git a/Tests/Testably.Abstractions.Compression.Tests/ZipFile/CreateFromDirectoryTests.cs b/Tests/Testably.Abstractions.Compression.Tests/ZipFile/CreateFromDirectoryTests.cs index 94a284725..39b219f3d 100644 --- a/Tests/Testably.Abstractions.Compression.Tests/ZipFile/CreateFromDirectoryTests.cs +++ b/Tests/Testably.Abstractions.Compression.Tests/ZipFile/CreateFromDirectoryTests.cs @@ -1,4 +1,5 @@ -using System.IO.Compression; +using System.Collections.Generic; +using System.IO.Compression; using System.Text; #if FEATURE_COMPRESSION_STREAM using System.IO; @@ -8,10 +9,10 @@ namespace Testably.Abstractions.Compression.Tests.ZipFile; [FileSystemTests] -public partial class CreateFromDirectoryTests +public class CreateFromDirectoryTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateFromDirectory_EmptyDirectory_ShouldBeIncluded( CompressionLevel compressionLevel) @@ -30,8 +31,8 @@ await That(archive.Entries).HasSingle() .Which.For(x => x.FullName, f => f.IsEqualTo("bar/")); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateFromDirectory_EmptySource_DoNotIncludeBaseDirectory_ShouldBeEmpty( CompressionLevel compressionLevel) { @@ -47,8 +48,8 @@ public async Task CreateFromDirectory_EmptySource_DoNotIncludeBaseDirectory_Shou await That(archive.Entries).IsEmpty(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateFromDirectory_EmptySource_IncludeBaseDirectory_ShouldPrependDirectoryName( CompressionLevel compressionLevel) @@ -66,8 +67,8 @@ await That(archive.Entries).HasSingle() .Which.For(x => x.FullName, f => f.IsEqualTo("foo/")); } - [Theory] - [MemberData(nameof(EntryNameEncoding))] + [Test] + [MethodDataSource(nameof(EntryNameEncoding))] public async Task CreateFromDirectory_EntryNameEncoding_ShouldUseEncoding( string entryName, Encoding encoding, bool encodedCorrectly) { @@ -93,8 +94,8 @@ public async Task CreateFromDirectory_EntryNameEncoding_ShouldUseEncoding( } } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateFromDirectory_IncludeBaseDirectory_ShouldPrependDirectoryName( CompressionLevel compressionLevel) { @@ -113,8 +114,8 @@ await That(archive.Entries).HasSingle() } #if FEATURE_COMPRESSION_OVERWRITE - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateFromDirectory_Overwrite_WithEncoding_ShouldOverwriteFile( string contents, Encoding encoding) { @@ -137,7 +138,7 @@ await That(archive.Entries).HasSingle() } #endif - [Fact] + [Test] public async Task CreateFromDirectory_ShouldZipDirectoryContent() { FileSystem.Initialize() @@ -155,7 +156,7 @@ await That(FileSystem).HasFile("destination/bar/test.txt") } #if FEATURE_COMPRESSION_STREAM - [Fact] + [Test] public async Task CreateFromDirectory_WithReadOnlyStream_ShouldThrowArgumentException() { FileSystem.Initialize() @@ -179,8 +180,8 @@ await That(Act).Throws() #endif #if FEATURE_COMPRESSION_STREAM - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateFromDirectory_WithStream_EmptyDirectory_ShouldBeIncluded( CompressionLevel compressionLevel) @@ -201,8 +202,8 @@ await That(archive.Entries).HasSingle() #endif #if FEATURE_COMPRESSION_STREAM - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateFromDirectory_WithStream_EmptySource_DoNotIncludeBaseDirectory_ShouldBeEmpty( CompressionLevel compressionLevel) @@ -221,8 +222,8 @@ public async Task #endif #if FEATURE_COMPRESSION_STREAM - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateFromDirectory_WithStream_EmptySource_IncludeBaseDirectory_ShouldPrependDirectoryName( CompressionLevel compressionLevel) @@ -242,8 +243,8 @@ await That(archive.Entries).HasSingle() #endif #if FEATURE_COMPRESSION_STREAM - [Theory] - [MemberData(nameof(EntryNameEncoding))] + [Test] + [MethodDataSource(nameof(EntryNameEncoding))] public async Task CreateFromDirectory_WithStream_EntryNameEncoding_ShouldUseEncoding( string entryName, Encoding encoding, bool encodedCorrectly) { @@ -271,8 +272,8 @@ public async Task CreateFromDirectory_WithStream_EntryNameEncoding_ShouldUseEnco #endif #if FEATURE_COMPRESSION_STREAM - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateFromDirectory_WithStream_IncludeBaseDirectory_ShouldPrependDirectoryName( CompressionLevel compressionLevel) @@ -293,7 +294,7 @@ await That(archive.Entries).HasSingle() #endif #if FEATURE_COMPRESSION_STREAM - [Fact] + [Test] public async Task CreateFromDirectory_WithStream_NotWritable_ShouldThrowArgumentException() { @@ -312,7 +313,7 @@ await That(Act).Throws() #endif #if FEATURE_COMPRESSION_STREAM - [Fact] + [Test] public async Task CreateFromDirectory_WithStream_Null_ShouldThrowArgumentNullException() { @@ -329,8 +330,8 @@ await That(Act).Throws() #endif #if FEATURE_COMPRESSION_STREAM - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateFromDirectory_WithStream_Overwrite_WithEncoding_ShouldOverwriteFile( string contents, Encoding encoding) { @@ -355,7 +356,7 @@ await That(archive.Entries).HasSingle() #endif #if FEATURE_COMPRESSION_STREAM - [Fact] + [Test] public async Task CreateFromDirectory_WithStream_ShouldZipDirectoryContent() { FileSystem.Initialize() @@ -374,7 +375,7 @@ await That(FileSystem).HasFile("destination/bar/test.txt") } #endif - [Fact] + [Test] public async Task ShouldNotLock() { string directory = "ToBeZipped"; @@ -391,23 +392,12 @@ public async Task ShouldNotLock() #region Helpers - #pragma warning disable MA0018 - public static TheoryData EntryNameEncoding() + public static IEnumerable> EntryNameEncoding() { // ReSharper disable StringLiteralTypo - TheoryData theoryData = new() - { - { - "Dans mes rêves.mp3", Encoding.Default, true - }, - { - "Dans mes rêves.mp3", Encoding.ASCII, false - }, - }; - // ReSharper restore StringLiteralTypo - return theoryData; + yield return () => ("Dans mes rêves.mp3", Encoding.Default, true); + yield return () => ("Dans mes rêves.mp3", Encoding.ASCII, false); } - #pragma warning restore MA0018 #endregion } diff --git a/Tests/Testably.Abstractions.Compression.Tests/ZipFile/ExtractToDirectoryAsyncTests.cs b/Tests/Testably.Abstractions.Compression.Tests/ZipFile/ExtractToDirectoryAsyncTests.cs index b1bfe6bb4..2e96399fe 100644 --- a/Tests/Testably.Abstractions.Compression.Tests/ZipFile/ExtractToDirectoryAsyncTests.cs +++ b/Tests/Testably.Abstractions.Compression.Tests/ZipFile/ExtractToDirectoryAsyncTests.cs @@ -9,9 +9,9 @@ namespace Testably.Abstractions.Compression.Tests.ZipFile; [FileSystemTests] -public partial class ExtractToDirectoryAsyncAsyncTests +public class ExtractToDirectoryAsyncAsyncTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Fact] + [Test] public async Task ExtractToDirectoryAsync_MissingDestinationDirectory_ShouldCreateDirectory() { FileSystem.Initialize() @@ -21,13 +21,13 @@ public async Task ExtractToDirectoryAsync_MissingDestinationDirectory_ShouldCrea FileSystem.ZipFile().CreateFromDirectory("foo", "destination.zip"); await FileSystem.ZipFile().ExtractToDirectoryAsync("destination.zip", "bar", - TestContext.Current.CancellationToken); + CancellationToken); await That(FileSystem).HasFile("bar/test.txt") .WithContent().SameAs("foo/test.txt"); } - [Fact] + [Test] public async Task ExtractToDirectoryAsync_MissingSourceFileName_ShouldThrowArgumentNullException() { @@ -37,14 +37,14 @@ public async Task async Task Act() { await FileSystem.ZipFile().ExtractToDirectoryAsync(sourceArchiveFileName, "bar", - TestContext.Current.CancellationToken); + CancellationToken); } await That(Act).Throws() .WithMessage($"*'{FileSystem.Path.GetFullPath(sourceArchiveFileName)}*").AsWildcard(); } - [Fact] + [Test] public async Task ExtractToDirectoryAsync_NullAsSourceFileName_ShouldThrowArgumentNullException() { @@ -53,15 +53,15 @@ public async Task async Task Act() { - await FileSystem.ZipFile().ExtractToDirectoryAsync(sourceArchiveFileName, "bar", TestContext.Current.CancellationToken); + await FileSystem.ZipFile().ExtractToDirectoryAsync(sourceArchiveFileName, "bar", CancellationToken); } await That(Act).Throws() .WithParamName("sourceArchiveFileName"); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ExtractToDirectoryAsync_Overwrite_ShouldOverwriteFile( string contents) { @@ -76,14 +76,14 @@ public async Task ExtractToDirectoryAsync_Overwrite_ShouldOverwriteFile( FileSystem.ZipFile().CreateFromDirectory("foo", "destination.zip"); await FileSystem.ZipFile().ExtractToDirectoryAsync("destination.zip", "bar", true, - TestContext.Current.CancellationToken); + CancellationToken); await That(FileSystem).HasFile(FileSystem.Path.Combine("bar", "test.txt")) .WithContent(contents); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ExtractToDirectoryAsync_WithEncoding_Overwrite_ShouldOverwriteFile( string contents, Encoding encoding) @@ -99,14 +99,14 @@ public async Task ExtractToDirectoryAsync_WithEncoding_Overwrite_ShouldOverwrite FileSystem.ZipFile().CreateFromDirectory("foo", "destination.zip"); await FileSystem.ZipFile().ExtractToDirectoryAsync("destination.zip", "bar", encoding, true, - TestContext.Current.CancellationToken); + CancellationToken); await That(FileSystem).HasFile(FileSystem.Path.Combine("bar", "test.txt")) .WithContent(contents); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ExtractToDirectoryAsync_WithEncoding_ShouldZipDirectoryContent( Encoding encoding) { @@ -119,14 +119,14 @@ public async Task ExtractToDirectoryAsync_WithEncoding_ShouldZipDirectoryContent CompressionLevel.Fastest, false, encoding); await FileSystem.ZipFile().ExtractToDirectoryAsync("destination.zip", "bar", encoding, - TestContext.Current.CancellationToken); + CancellationToken); await That(FileSystem).HasFile(FileSystem.Path.Combine("bar", "test.txt")) .WithContent().SameAs(FileSystem.Path.Combine("foo", "test.txt")); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ExtractToDirectoryAsync_WithoutOverwriteAndExistingFile_ShouldOverwriteFile( string contents) { @@ -144,7 +144,7 @@ public async Task ExtractToDirectoryAsync_WithoutOverwriteAndExistingFile_Should async Task Act() { - await FileSystem.ZipFile().ExtractToDirectoryAsync("destination.zip", "bar", TestContext.Current.CancellationToken); + await FileSystem.ZipFile().ExtractToDirectoryAsync("destination.zip", "bar", CancellationToken); } await That(Act).Throws() @@ -153,7 +153,7 @@ await That(FileSystem.File.ReadAllText(destinationPath)) .IsNotEqualTo(contents); } - [Fact] + [Test] public async Task ExtractToDirectoryAsync_WithStream_MissingDestinationDirectory_ShouldCreateDirectory() { @@ -165,13 +165,13 @@ public async Task FileSystem.ZipFile().CreateFromDirectory("foo", stream); await FileSystem.ZipFile() - .ExtractToDirectoryAsync(stream, "bar", TestContext.Current.CancellationToken); + .ExtractToDirectoryAsync(stream, "bar", CancellationToken); await That(FileSystem).HasFile("bar/test.txt") .WithContent().SameAs("foo/test.txt"); } - [Fact] + [Test] public async Task ExtractToDirectoryAsync_WithStream_NotReadable_ShouldThrowArgumentNullException() { @@ -180,7 +180,7 @@ public async Task async Task Act() { - await FileSystem.ZipFile().ExtractToDirectoryAsync(source, "bar", TestContext.Current.CancellationToken); + await FileSystem.ZipFile().ExtractToDirectoryAsync(source, "bar", CancellationToken); } await That(Act).Throws() @@ -189,7 +189,7 @@ await That(Act).Throws() .WithHResult(-2147024809); } - [Fact] + [Test] public async Task ExtractToDirectoryAsync_WithStream_Null_ShouldThrowArgumentNullException() { @@ -198,15 +198,15 @@ public async Task async Task Act() { - await FileSystem.ZipFile().ExtractToDirectoryAsync(source, "bar", TestContext.Current.CancellationToken); + await FileSystem.ZipFile().ExtractToDirectoryAsync(source, "bar", CancellationToken); } await That(Act).Throws() .WithParamName("source"); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ExtractToDirectoryAsync_WithStream_Overwrite_ShouldOverwriteFile( string contents) { @@ -222,14 +222,14 @@ public async Task ExtractToDirectoryAsync_WithStream_Overwrite_ShouldOverwriteFi FileSystem.ZipFile().CreateFromDirectory("foo", stream); await FileSystem.ZipFile() - .ExtractToDirectoryAsync(stream, "bar", true, TestContext.Current.CancellationToken); + .ExtractToDirectoryAsync(stream, "bar", true, CancellationToken); await That(FileSystem).HasFile(FileSystem.Path.Combine("bar", "test.txt")) .WithContent(contents); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ExtractToDirectoryAsync_WithStream_WithEncoding_Overwrite_ShouldOverwriteFile( string contents, Encoding encoding) @@ -246,14 +246,14 @@ public async Task ExtractToDirectoryAsync_WithStream_WithEncoding_Overwrite_Shou FileSystem.ZipFile().CreateFromDirectory("foo", stream); await FileSystem.ZipFile().ExtractToDirectoryAsync(stream, "bar", encoding, true, - TestContext.Current.CancellationToken); + CancellationToken); await That(FileSystem).HasFile(FileSystem.Path.Combine("bar", "test.txt")) .WithContent(contents); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ExtractToDirectoryAsync_WithStream_WithEncoding_ShouldZipDirectoryContent( Encoding encoding) { @@ -267,14 +267,14 @@ public async Task ExtractToDirectoryAsync_WithStream_WithEncoding_ShouldZipDirec CompressionLevel.Fastest, false, encoding); await FileSystem.ZipFile().ExtractToDirectoryAsync(stream, "bar", encoding, - TestContext.Current.CancellationToken); + CancellationToken); await That(FileSystem).HasFile(FileSystem.Path.Combine("bar", "test.txt")) .WithContent().SameAs(FileSystem.Path.Combine("foo", "test.txt")); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ExtractToDirectoryAsync_WithStream_WithoutOverwriteAndExistingFile_ShouldOverwriteFile( string contents) @@ -295,7 +295,7 @@ public async Task async Task Act() { // ReSharper disable once AccessToDisposedClosure - await FileSystem.ZipFile().ExtractToDirectoryAsync(stream, "bar", TestContext.Current.CancellationToken); + await FileSystem.ZipFile().ExtractToDirectoryAsync(stream, "bar", CancellationToken); } await That(Act).Throws() @@ -304,7 +304,7 @@ await That(FileSystem.File.ReadAllText(destinationPath)) .IsNotEqualTo(contents); } - [Fact] + [Test] public async Task ExtractToDirectoryAsync_WithWriteOnlyStream_ShouldThrowArgumentException() { FileSystem.Initialize() @@ -319,7 +319,7 @@ public async Task ExtractToDirectoryAsync_WithWriteOnlyStream_ShouldThrowArgumen async Task Act() { // ReSharper disable once AccessToDisposedClosure - await FileSystem.ZipFile().ExtractToDirectoryAsync(stream, "bar", TestContext.Current.CancellationToken); + await FileSystem.ZipFile().ExtractToDirectoryAsync(stream, "bar", CancellationToken); } await That(Act).Throws() diff --git a/Tests/Testably.Abstractions.Compression.Tests/ZipFile/ExtractToDirectoryTests.cs b/Tests/Testably.Abstractions.Compression.Tests/ZipFile/ExtractToDirectoryTests.cs index ef4c4ef42..b1acf35d9 100644 --- a/Tests/Testably.Abstractions.Compression.Tests/ZipFile/ExtractToDirectoryTests.cs +++ b/Tests/Testably.Abstractions.Compression.Tests/ZipFile/ExtractToDirectoryTests.cs @@ -8,9 +8,9 @@ namespace Testably.Abstractions.Compression.Tests.ZipFile; [FileSystemTests] -public partial class ExtractToDirectoryTests +public class ExtractToDirectoryTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Fact] + [Test] public async Task ExtractToDirectory_MissingDestinationDirectory_ShouldCreateDirectory() { FileSystem.Initialize() @@ -25,7 +25,7 @@ await That(FileSystem).HasFile("bar/test.txt") .WithContent().SameAs("foo/test.txt"); } - [Fact] + [Test] public async Task ExtractToDirectory_MissingSourceFileName_ShouldThrowArgumentNullException() { @@ -41,7 +41,7 @@ await That(Act).Throws() .WithMessage($"*'{FileSystem.Path.GetFullPath(sourceArchiveFileName)}*").AsWildcard(); } - [Fact] + [Test] public async Task ExtractToDirectory_NullAsSourceFileName_ShouldThrowArgumentNullException() { @@ -58,8 +58,8 @@ await That(Act).Throws() } #if FEATURE_COMPRESSION_OVERWRITE - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ExtractToDirectory_Overwrite_ShouldOverwriteFile( string contents) { @@ -81,8 +81,8 @@ await That(FileSystem).HasFile(FileSystem.Path.Combine("bar", "test.txt")) #endif #if FEATURE_COMPRESSION_OVERWRITE - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ExtractToDirectory_WithEncoding_Overwrite_ShouldOverwriteFile( string contents, Encoding encoding) @@ -104,8 +104,8 @@ await That(FileSystem).HasFile(FileSystem.Path.Combine("bar", "test.txt")) } #endif - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ExtractToDirectory_WithEncoding_ShouldZipDirectoryContent( Encoding encoding) { @@ -123,8 +123,8 @@ await That(FileSystem).HasFile(FileSystem.Path.Combine("bar", "test.txt")) .WithContent().SameAs(FileSystem.Path.Combine("foo", "test.txt")); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ExtractToDirectory_WithoutOverwriteAndExistingFile_ShouldOverwriteFile( string contents) { @@ -152,7 +152,7 @@ await That(FileSystem.File.ReadAllText(destinationPath)) } #if FEATURE_COMPRESSION_STREAM - [Fact] + [Test] public async Task ExtractToDirectory_WithStream_MissingDestinationDirectory_ShouldCreateDirectory() { @@ -171,7 +171,7 @@ await That(FileSystem).HasFile("bar/test.txt") #endif #if FEATURE_COMPRESSION_STREAM - [Fact] + [Test] public async Task ExtractToDirectory_WithStream_NotReadable_ShouldThrowArgumentNullException() { @@ -191,7 +191,7 @@ await That(Act).Throws() #endif #if FEATURE_COMPRESSION_STREAM - [Fact] + [Test] public async Task ExtractToDirectory_WithStream_Null_ShouldThrowArgumentNullException() { @@ -209,8 +209,8 @@ await That(Act).Throws() #endif #if FEATURE_COMPRESSION_STREAM - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ExtractToDirectory_WithStream_Overwrite_ShouldOverwriteFile( string contents) { @@ -233,8 +233,8 @@ await That(FileSystem).HasFile(FileSystem.Path.Combine("bar", "test.txt")) #endif #if FEATURE_COMPRESSION_STREAM - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ExtractToDirectory_WithStream_WithEncoding_Overwrite_ShouldOverwriteFile( string contents, Encoding encoding) @@ -258,8 +258,8 @@ await That(FileSystem).HasFile(FileSystem.Path.Combine("bar", "test.txt")) #endif #if FEATURE_COMPRESSION_STREAM - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ExtractToDirectory_WithStream_WithEncoding_ShouldZipDirectoryContent( Encoding encoding) { @@ -280,8 +280,8 @@ await That(FileSystem).HasFile(FileSystem.Path.Combine("bar", "test.txt")) #endif #if FEATURE_COMPRESSION_STREAM - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ExtractToDirectory_WithStream_WithoutOverwriteAndExistingFile_ShouldOverwriteFile( string contents) @@ -313,7 +313,7 @@ await That(FileSystem.File.ReadAllText(destinationPath)) #endif #if FEATURE_COMPRESSION_STREAM - [Fact] + [Test] public async Task ExtractToDirectory_WithWriteOnlyStream_ShouldThrowArgumentException() { FileSystem.Initialize() diff --git a/Tests/Testably.Abstractions.Compression.Tests/ZipFile/OpenTests.cs b/Tests/Testably.Abstractions.Compression.Tests/ZipFile/OpenTests.cs index 1c407343d..669535471 100644 --- a/Tests/Testably.Abstractions.Compression.Tests/ZipFile/OpenTests.cs +++ b/Tests/Testably.Abstractions.Compression.Tests/ZipFile/OpenTests.cs @@ -3,9 +3,9 @@ namespace Testably.Abstractions.Compression.Tests.ZipFile; [FileSystemTests] -public partial class OpenTests +public class OpenTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Fact] + [Test] public async Task Open_CreateMode_ShouldInitializeEmptyArchive() { IZipArchive archive = FileSystem.ZipFile().Open("destination.zip", ZipArchiveMode.Create); @@ -13,7 +13,7 @@ public async Task Open_CreateMode_ShouldInitializeEmptyArchive() await That(archive.Mode).IsEqualTo(ZipArchiveMode.Create); } - [Fact] + [Test] public async Task Open_InvalidMode_ShouldThrowArgumentOutOfRangeException() { ZipArchiveMode invalidMode = (ZipArchiveMode)(-1); @@ -27,9 +27,9 @@ await That(Act).Throws() .WithParamName("mode"); } - [Theory] - [InlineData(ZipArchiveMode.Read)] - [InlineData(ZipArchiveMode.Update)] + [Test] + [Arguments(ZipArchiveMode.Read)] + [Arguments(ZipArchiveMode.Update)] public async Task Open_ShouldOpenExistingArchive(ZipArchiveMode mode) { FileSystem.Initialize() @@ -45,7 +45,7 @@ public async Task Open_ShouldOpenExistingArchive(ZipArchiveMode mode) await That(archive.Entries).HasCount().EqualTo(1); } - [Fact] + [Test] public async Task OpenRead_ShouldOpenExistingArchiveInReadMode() { FileSystem.Initialize() diff --git a/Tests/Testably.Abstractions.Compression.Tests/ZipFile/Tests.cs b/Tests/Testably.Abstractions.Compression.Tests/ZipFile/Tests.cs index 73f33f609..fc47b2036 100644 --- a/Tests/Testably.Abstractions.Compression.Tests/ZipFile/Tests.cs +++ b/Tests/Testably.Abstractions.Compression.Tests/ZipFile/Tests.cs @@ -1,9 +1,9 @@ namespace Testably.Abstractions.Compression.Tests.ZipFile; [FileSystemTests] -public partial class Tests +public class Tests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Fact] + [Test] public async Task FileSystemExtension_ShouldBeSet() { IZipFile result = FileSystem.ZipFile(); diff --git a/Tests/Testably.Abstractions.Parity.Tests/Net10ParityTests.cs b/Tests/Testably.Abstractions.Parity.Tests/Net10ParityTests.cs index 586d961fd..85b8ec650 100644 --- a/Tests/Testably.Abstractions.Parity.Tests/Net10ParityTests.cs +++ b/Tests/Testably.Abstractions.Parity.Tests/Net10ParityTests.cs @@ -3,11 +3,12 @@ namespace Testably.Abstractions.Parity.Tests; +[InheritsTests] // ReSharper disable once UnusedMember.Global public class Net10ParityTests : ParityTests { - public Net10ParityTests(ITestOutputHelper testOutputHelper) - : base(new TestHelpers.Parity(), testOutputHelper) + public Net10ParityTests() + : base(new TestHelpers.Parity()) { Parity.File.MissingMethods.Add( typeof(File).GetMethod(nameof(File.OpenHandle))); diff --git a/Tests/Testably.Abstractions.Parity.Tests/Net48ParityTests.cs b/Tests/Testably.Abstractions.Parity.Tests/Net48ParityTests.cs index 54bffc9e6..b101ee28b 100644 --- a/Tests/Testably.Abstractions.Parity.Tests/Net48ParityTests.cs +++ b/Tests/Testably.Abstractions.Parity.Tests/Net48ParityTests.cs @@ -5,6 +5,7 @@ namespace Testably.Abstractions.Parity.Tests; +[InheritsTests] public class Net48ParityTests : ParityTests { /// @@ -12,8 +13,8 @@ public class Net48ParityTests : ParityTests /// /// As we only support .NET Standard 2.0 these are blacklisted. /// - public Net48ParityTests(ITestOutputHelper testOutputHelper) - : base(new TestHelpers.Parity(), testOutputHelper) + public Net48ParityTests() + : base(new TestHelpers.Parity()) { #region Directory diff --git a/Tests/Testably.Abstractions.Parity.Tests/Net8ParityTests.cs b/Tests/Testably.Abstractions.Parity.Tests/Net8ParityTests.cs index 4ba4882cf..e4d4e4311 100644 --- a/Tests/Testably.Abstractions.Parity.Tests/Net8ParityTests.cs +++ b/Tests/Testably.Abstractions.Parity.Tests/Net8ParityTests.cs @@ -3,11 +3,12 @@ namespace Testably.Abstractions.Parity.Tests; +[InheritsTests] // ReSharper disable once UnusedMember.Global public class Net8ParityTests : ParityTests { - public Net8ParityTests(ITestOutputHelper testOutputHelper) - : base(new TestHelpers.Parity(), testOutputHelper) + public Net8ParityTests() + : base(new TestHelpers.Parity()) { Parity.File.MissingMethods.Add( typeof(File).GetMethod(nameof(File.OpenHandle))); diff --git a/Tests/Testably.Abstractions.Parity.Tests/Net9ParityTests.cs b/Tests/Testably.Abstractions.Parity.Tests/Net9ParityTests.cs index 80cab2232..04765cc6c 100644 --- a/Tests/Testably.Abstractions.Parity.Tests/Net9ParityTests.cs +++ b/Tests/Testably.Abstractions.Parity.Tests/Net9ParityTests.cs @@ -3,11 +3,12 @@ namespace Testably.Abstractions.Parity.Tests; +[InheritsTests] // ReSharper disable once UnusedMember.Global public class Net9ParityTests : ParityTests { - public Net9ParityTests(ITestOutputHelper testOutputHelper) - : base(new TestHelpers.Parity(), testOutputHelper) + public Net9ParityTests() + : base(new TestHelpers.Parity()) { Parity.File.MissingMethods.Add( typeof(File).GetMethod(nameof(File.OpenHandle))); diff --git a/Tests/Testably.Abstractions.Parity.Tests/ParityTests.cs b/Tests/Testably.Abstractions.Parity.Tests/ParityTests.cs index 869678fb2..c486e1685 100644 --- a/Tests/Testably.Abstractions.Parity.Tests/ParityTests.cs +++ b/Tests/Testably.Abstractions.Parity.Tests/ParityTests.cs @@ -11,8 +11,7 @@ namespace Testably.Abstractions.Parity.Tests; public abstract class ParityTests( - TestHelpers.Parity parity, - ITestOutputHelper testOutputHelper) + TestHelpers.Parity parity) { #region Test Setup @@ -20,208 +19,189 @@ public abstract class ParityTests( #endregion - [Fact] + [Test] public async Task IDirectory_EnsureParityWith_Directory() { List parityErrors = Parity.Directory .GetErrorsToStaticType( - typeof(Directory), - testOutputHelper); + typeof(Directory)); await That(parityErrors).IsEmpty(); } - [Fact] + [Test] public async Task IDirectoryInfoAndIDirectoryInfoFactory_EnsureParityWith_DirectoryInfo() { List parityErrors = Parity.DirectoryInfo .GetErrorsToInstanceType( - typeof(DirectoryInfo), - testOutputHelper); + typeof(DirectoryInfo)); await That(parityErrors).IsEmpty(); } - [Fact] + [Test] public async Task IDriveInfoAndIDriveInfoFactory_EnsureParityWith_DriveInfo() { List parityErrors = Parity.Drive .GetErrorsToInstanceType( - typeof(DriveInfo), - testOutputHelper); + typeof(DriveInfo)); await That(parityErrors).IsEmpty(); } - [Fact] + [Test] public async Task IFile_EnsureParityWith_File() { List parityErrors = Parity.File .GetErrorsToStaticType( - typeof(File), - testOutputHelper); + typeof(File)); await That(parityErrors).IsEmpty(); } - [Fact] + [Test] public async Task IFileInfoAndIFileInfoFactory_EnsureParityWith_FileInfo() { List parityErrors = Parity.FileInfo .GetErrorsToInstanceType( - typeof(FileInfo), - testOutputHelper); + typeof(FileInfo)); await That(parityErrors).IsEmpty(); } - [Fact] + [Test] public async Task IFileSystemInfo_EnsureParityWith_FileSystemInfo() { List parityErrors = Parity.FileSystemInfo .GetErrorsToInstanceType( - typeof(FileSystemInfo), - testOutputHelper); + typeof(FileSystemInfo)); await That(parityErrors).IsEmpty(); } - [Fact] + [Test] public async Task IFileSystemWatcherAndIFileSystemWatcherFactory_EnsureParityWith_FileSystemWatcher() { List parityErrors = Parity.FileSystemWatcher .GetErrorsToInstanceType( - typeof(FileSystemWatcher), - testOutputHelper); + typeof(FileSystemWatcher)); await That(parityErrors).IsEmpty(); } - [Fact] + [Test] public async Task IFileVersionInfoAndIFileVersionInfoFactory_EnsureParityWith_FileVersionInfo() { List parityErrors = Parity.FileVersionInfo .GetErrorsToInstanceType( - typeof(FileVersionInfo), - testOutputHelper); + typeof(FileVersionInfo)); await That(parityErrors).IsEmpty(); } - [Fact] + [Test] public async Task IGuid_EnsureParityWith_Guid() { List parityErrors = Parity.Guid .GetErrorsToStaticType( - typeof(Guid), - testOutputHelper); + typeof(Guid)); await That(parityErrors).IsEmpty(); } - [Fact] + [Test] public async Task IPath_EnsureParityWith_Path() { List parityErrors = Parity.Path .GetErrorsToStaticType( - typeof(Path), - testOutputHelper); + typeof(Path)); await That(parityErrors).IsEmpty(); } - [Fact] + [Test] public async Task IRandomAndIRandomFactory_EnsureParityWith_Random() { List parityErrors = Parity.Random .GetErrorsToInstanceType( - typeof(Random), - testOutputHelper); + typeof(Random)); await That(parityErrors).IsEmpty(); } - [Fact] + [Test] public async Task ITimerAndITimerFactory_EnsureParityWith_Timer() { List parityErrors = Parity.Timer .GetErrorsToInstanceType( - typeof(Timer), - testOutputHelper); + typeof(Timer)); await That(parityErrors).IsEmpty(); } - [Fact] + [Test] public async Task IStopwatchAndIStopwatchFactory_EnsureParityWith_Stopwatch() { List parityErrors = Parity.Stopwatch .GetErrorsToInstanceType( - typeof(Stopwatch), - testOutputHelper); + typeof(Stopwatch)); parityErrors.AddRange(Parity.Stopwatch .GetErrorsToStaticType( - typeof(Stopwatch), - testOutputHelper)); + typeof(Stopwatch))); await That(parityErrors).IsEmpty(); } - [Fact] + [Test] public async Task IZipArchive_EnsureParityWith_ZipArchive() { List parityErrors = Parity.ZipArchive .GetErrorsToInstanceType( - typeof(ZipArchive), - testOutputHelper); + typeof(ZipArchive)); await That(parityErrors).IsEmpty(); } - [Fact] + [Test] public async Task IZipArchive_EnsureParityWith_ZipFileExtensions() { List parityErrors = Parity.ZipArchive .GetErrorsToExtensionMethods( - typeof(ZipFileExtensions), - testOutputHelper); + typeof(ZipFileExtensions)); await That(parityErrors).IsEmpty(); } - [Fact] + [Test] public async Task IZipArchiveEntry_EnsureParityWith_ZipArchiveEntry() { List parityErrors = Parity.ZipArchiveEntry .GetErrorsToInstanceType( - typeof(ZipArchiveEntry), - testOutputHelper); + typeof(ZipArchiveEntry)); await That(parityErrors).IsEmpty(); } - [Fact] + [Test] public async Task IZipArchiveEntry_EnsureParityWith_ZipFileExtensions() { List parityErrors = Parity.ZipArchiveEntry .GetErrorsToExtensionMethods( - typeof(ZipFileExtensions), - testOutputHelper); + typeof(ZipFileExtensions)); await That(parityErrors).IsEmpty(); } - [Fact] + [Test] public async Task IZipFile_EnsureParityWith_ZipFile() { List parityErrors = Parity.ZipFile .GetErrorsToStaticType( - typeof(ZipFile), - testOutputHelper); + typeof(ZipFile)); await That(parityErrors).IsEmpty(); } diff --git a/Tests/Testably.Abstractions.Parity.Tests/TestHelpers/ParityCheck.cs b/Tests/Testably.Abstractions.Parity.Tests/TestHelpers/ParityCheck.cs index 5618becca..3d891360d 100644 --- a/Tests/Testably.Abstractions.Parity.Tests/TestHelpers/ParityCheck.cs +++ b/Tests/Testably.Abstractions.Parity.Tests/TestHelpers/ParityCheck.cs @@ -52,52 +52,52 @@ public ParityCheck(Type[]? excludeBaseTypes = null, } public List GetErrorsToExtensionMethods( - Type systemType, ITestOutputHelper testOutputHelper) + Type systemType) { List parityErrors = []; parityErrors.AddRange(GetParityErrorsBetweenExtensionMethods( - systemType, testOutputHelper)); + systemType)); return parityErrors; } public List GetErrorsToInstanceType( - Type systemType, ITestOutputHelper testOutputHelper) + Type systemType) { List parityErrors = []; parityErrors.AddRange(GetParityErrorsBetweenInstanceProperties( - systemType, testOutputHelper)); + systemType)); parityErrors.AddRange(GetParityErrorsBetweenInstanceMethods( - systemType, testOutputHelper)); + systemType)); return parityErrors; } public List GetErrorsToInstanceType( - Type systemType, ITestOutputHelper testOutputHelper) + Type systemType) { List parityErrors = []; parityErrors.AddRange( GetParityErrorsBetweenInstanceConstructors( - systemType, testOutputHelper)); + systemType)); parityErrors.AddRange(GetParityErrorsBetweenInstanceProperties( - systemType, testOutputHelper)); + systemType)); parityErrors.AddRange(GetParityErrorsBetweenInstanceMethods( - systemType, testOutputHelper)); + systemType)); return parityErrors; } public List GetErrorsToStaticType( - Type systemType, ITestOutputHelper testOutputHelper) + Type systemType) { List parityErrors = []; parityErrors.AddRange(GetParityErrorsBetweenStaticFields( - systemType, testOutputHelper)); + systemType)); parityErrors.AddRange(GetParityErrorsBetweenStaticMethods( - systemType, testOutputHelper)); + systemType)); return parityErrors; } private IEnumerable GetParityErrorsBetweenExtensionMethods( - Type systemType, ITestOutputHelper testOutputHelper) + Type systemType) { foreach (MethodInfo method in systemType .GetMethods( @@ -116,7 +116,7 @@ private IEnumerable GetParityErrorsBetweenExtensionMethods continue; } - testOutputHelper.WriteLine( + Console.WriteLine( $"Check parity for static method {method.PrintMethod($"{systemType.Name}.", "this ")}"); if (!typeof(TAbstraction) .ContainsEquivalentExtensionMethod(method)) @@ -128,7 +128,7 @@ private IEnumerable GetParityErrorsBetweenExtensionMethods private IEnumerable GetParityErrorsBetweenInstanceConstructors< TAbstractionFactory>( - Type systemType, ITestOutputHelper testOutputHelper) + Type systemType) { foreach (ConstructorInfo constructor in systemType .GetConstructors() @@ -136,7 +136,7 @@ private IEnumerable GetParityErrorsBetweenInstanceConstructors< .OrderBy(f => f.Name) .ThenBy(m => m.GetParameters().Length)) { - testOutputHelper.WriteLine( + Console.WriteLine( $"Check parity for constructor {constructor.PrintConstructor()}"); if (!typeof(TAbstractionFactory) .ContainsEquivalentMethod(constructor)) @@ -147,7 +147,7 @@ private IEnumerable GetParityErrorsBetweenInstanceConstructors< } private IEnumerable GetParityErrorsBetweenInstanceMethods( - Type systemType, ITestOutputHelper testOutputHelper) + Type systemType) { foreach (MethodInfo method in systemType .GetMethods( @@ -160,7 +160,7 @@ private IEnumerable GetParityErrorsBetweenInstanceMethods( .OrderBy(m => m.Name) .ThenBy(m => m.GetParameters().Length)) { - testOutputHelper.WriteLine( + Console.WriteLine( $"Check parity for method {method.PrintMethod($"{systemType.Name}.")}"); if (!typeof(TAbstraction) .ContainsEquivalentMethod(method)) @@ -171,7 +171,7 @@ private IEnumerable GetParityErrorsBetweenInstanceMethods( } private IEnumerable GetParityErrorsBetweenInstanceProperties( - Type systemType, ITestOutputHelper testOutputHelper) + Type systemType) { foreach (PropertyInfo property in systemType .GetProperties( @@ -183,7 +183,7 @@ private IEnumerable GetParityErrorsBetweenInstanceProperties !p.IsSpecialName) .OrderBy(p => p.Name)) { - testOutputHelper.WriteLine( + Console.WriteLine( $"Check parity for property {property.PrintProperty($"{systemType.Name}.")}"); if (!typeof(TAbstraction) .ContainsEquivalentProperty(property)) @@ -194,7 +194,7 @@ private IEnumerable GetParityErrorsBetweenInstanceProperties GetParityErrorsBetweenStaticFields( - Type systemType, ITestOutputHelper testOutputHelper) + Type systemType) { foreach (FieldInfo field in systemType .GetFields( @@ -204,7 +204,7 @@ private IEnumerable GetParityErrorsBetweenStaticFields( .Where(f => !f.IsSpecialName) .OrderBy(f => f.Name)) { - testOutputHelper.WriteLine( + Console.WriteLine( $"Check parity for static field {field.PrintField($"{systemType.Name}.")}"); if (!typeof(TAbstraction) .ContainsEquivalentProperty(field)) @@ -215,7 +215,7 @@ private IEnumerable GetParityErrorsBetweenStaticFields( } private IEnumerable GetParityErrorsBetweenStaticMethods( - Type systemType, ITestOutputHelper testOutputHelper) + Type systemType) { foreach (MethodInfo method in systemType .GetMethods( @@ -226,7 +226,7 @@ private IEnumerable GetParityErrorsBetweenStaticMethods( .OrderBy(f => f.Name) .ThenBy(m => m.GetParameters().Length)) { - testOutputHelper.WriteLine( + Console.WriteLine( $"Check parity for static method {method.PrintMethod($"{systemType.Name}.")}"); if (!typeof(TAbstraction) .ContainsEquivalentMethod(method)) diff --git a/Tests/Testably.Abstractions.Parity.Tests/TestHelpers/Usings.cs b/Tests/Testably.Abstractions.Parity.Tests/TestHelpers/Usings.cs index d94e613d6..eea765a00 100644 --- a/Tests/Testably.Abstractions.Parity.Tests/TestHelpers/Usings.cs +++ b/Tests/Testably.Abstractions.Parity.Tests/TestHelpers/Usings.cs @@ -1,5 +1,5 @@ global using System; global using System.IO.Abstractions; -global using Xunit; +global using TUnit; global using aweXpect; global using static aweXpect.Expect; diff --git a/Tests/Testably.Abstractions.Testing.Tests/AwaitableCallbackExtensionsTests.cs b/Tests/Testably.Abstractions.Testing.Tests/AwaitableCallbackExtensionsTests.cs index cfd49ebc5..04d4f10eb 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/AwaitableCallbackExtensionsTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/AwaitableCallbackExtensionsTests.cs @@ -10,8 +10,8 @@ public class AwaitableCallbackExtensionsTests #if NET6_0_OR_GREATER public sealed class ToAsyncEnumerableTests { - [Fact] - public async Task ShouldReturnAllEvents() + [Test] + public async Task ShouldReturnAllEvents(CancellationToken cancellationToken) { MockFileSystem fileSystem = new(); IAwaitableCallback sut = fileSystem.Notify.OnEvent(); @@ -22,9 +22,9 @@ public async Task ShouldReturnAllEvents() fileSystem.Directory.Delete("Test"); ChangeDescription[] results = await sut - .ToAsyncEnumerable(cancellationToken: TestContext.Current.CancellationToken) + .ToAsyncEnumerable(cancellationToken: cancellationToken) .Take(6) - .ToArrayAsync(cancellationToken: TestContext.Current.CancellationToken); + .ToArrayAsync(cancellationToken: cancellationToken); await That(results[0]).IsEquivalentTo(new { @@ -52,8 +52,8 @@ await That(results[5]).IsEquivalentTo(new }); } - [Fact] - public async Task WithCancelledToken_ShouldAbort() + [Test] + public async Task WithCancelledToken_ShouldAbort(CancellationToken cancellationToken) { MockFileSystem fileSystem = new(); IAwaitableCallback sut = fileSystem.Notify @@ -66,24 +66,24 @@ public async Task WithCancelledToken_ShouldAbort() for (int i = 0; i < 10; i++) { fileSystem.Directory.CreateDirectory($"Test{i}"); - await Task.Delay(100, TestContext.Current.CancellationToken); + await Task.Delay(100, cancellationToken); if (i == 5) { // ReSharper disable once AccessToDisposedClosure cts.Cancel(); } } - }, TestContext.Current.CancellationToken); + }, cancellationToken); ChangeDescription[] results = await sut.ToAsyncEnumerable(cancellationToken: token) .Take(10) - .ToArrayAsync(cancellationToken: TestContext.Current.CancellationToken); + .ToArrayAsync(cancellationToken: cancellationToken); await That(results.Length).IsEqualTo(6); } - [Fact] - public async Task WithFilter_ShouldOnlyReturnMatchingEvents() + [Test] + public async Task WithFilter_ShouldOnlyReturnMatchingEvents(CancellationToken cancellationToken) { MockFileSystem fileSystem = new(); IAwaitableCallback sut = fileSystem.Notify @@ -95,9 +95,9 @@ public async Task WithFilter_ShouldOnlyReturnMatchingEvents() fileSystem.Directory.Delete("Test"); ChangeDescription[] results = await sut - .ToAsyncEnumerable(cancellationToken: TestContext.Current.CancellationToken) + .ToAsyncEnumerable(cancellationToken: cancellationToken) .Take(2) - .ToArrayAsync(cancellationToken: TestContext.Current.CancellationToken); + .ToArrayAsync(cancellationToken: cancellationToken); await That(results[0]).IsEquivalentTo(new { @@ -113,8 +113,8 @@ await That(results[1]).IsEquivalentTo(new }); } - [Fact] - public async Task WithIntTimeout_ShouldAbortAfterwards() + [Test] + public async Task WithIntTimeout_ShouldAbortAfterwards(CancellationToken cancellationToken) { MockFileSystem fileSystem = new(); IAwaitableCallback sut = fileSystem.Notify @@ -125,20 +125,20 @@ public async Task WithIntTimeout_ShouldAbortAfterwards() for (int i = 0; i < 10; i++) { fileSystem.Directory.CreateDirectory($"Test{i}"); - await Task.Delay(100, TestContext.Current.CancellationToken); + await Task.Delay(100, cancellationToken); } - }, TestContext.Current.CancellationToken); + }, cancellationToken); ChangeDescription[] results = await sut - .ToAsyncEnumerable(150, cancellationToken: TestContext.Current.CancellationToken) + .ToAsyncEnumerable(150, cancellationToken: cancellationToken) .Take(10) - .ToArrayAsync(cancellationToken: TestContext.Current.CancellationToken); + .ToArrayAsync(cancellationToken: cancellationToken); await That(results.Length).IsLessThan(9); } - [Fact] - public async Task WithTimeout_ShouldAbortAfterwards() + [Test] + public async Task WithTimeout_ShouldAbortAfterwards(CancellationToken cancellationToken) { MockFileSystem fileSystem = new(); IAwaitableCallback sut = fileSystem.Notify @@ -149,15 +149,15 @@ public async Task WithTimeout_ShouldAbortAfterwards() for (int i = 0; i < 10; i++) { fileSystem.Directory.CreateDirectory($"Test{i}"); - await Task.Delay(100, TestContext.Current.CancellationToken); + await Task.Delay(100, cancellationToken); } - }, TestContext.Current.CancellationToken); + }, cancellationToken); ChangeDescription[] results = await sut .ToAsyncEnumerable(TimeSpan.FromMilliseconds(150), - cancellationToken: TestContext.Current.CancellationToken) + cancellationToken: cancellationToken) .Take(10) - .ToArrayAsync(cancellationToken: TestContext.Current.CancellationToken); + .ToArrayAsync(cancellationToken: cancellationToken); await That(results.Length).IsLessThan(9); } diff --git a/Tests/Testably.Abstractions.Testing.Tests/FileSystem/ChangeDescriptionTests.cs b/Tests/Testably.Abstractions.Testing.Tests/FileSystem/ChangeDescriptionTests.cs index 5c1a06061..d7bc03623 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/FileSystem/ChangeDescriptionTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/FileSystem/ChangeDescriptionTests.cs @@ -6,8 +6,8 @@ namespace Testably.Abstractions.Testing.Tests.FileSystem; public class ChangeDescriptionTests { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ToString_ShouldIncludeChangeType( WatcherChangeTypes changeType, FileSystemTypes fileSystemType, @@ -28,8 +28,8 @@ public async Task ToString_ShouldIncludeChangeType( await That(result).Contains(changeType.ToString()); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ToString_ShouldIncludeFileSystemType( WatcherChangeTypes changeType, FileSystemTypes fileSystemType, @@ -50,8 +50,8 @@ public async Task ToString_ShouldIncludeFileSystemType( await That(result).Contains(fileSystemType.ToString()); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ToString_ShouldIncludeNotifyFilters( WatcherChangeTypes changeType, FileSystemTypes fileSystemType, @@ -72,8 +72,8 @@ public async Task ToString_ShouldIncludeNotifyFilters( await That(result).Contains(notifyFilters.ToString()); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ToString_ShouldIncludePath( WatcherChangeTypes changeType, FileSystemTypes fileSystemType, diff --git a/Tests/Testably.Abstractions.Testing.Tests/FileSystem/ChangeHandlerTests.cs b/Tests/Testably.Abstractions.Testing.Tests/FileSystem/ChangeHandlerTests.cs index 4d7751778..1fdaf2a61 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/FileSystem/ChangeHandlerTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/FileSystem/ChangeHandlerTests.cs @@ -1,10 +1,11 @@ using aweXpect.Synchronous; +using System.Collections.Generic; using System.IO; using Testably.Abstractions.Testing.FileSystem; namespace Testably.Abstractions.Testing.Tests.FileSystem; -public class ChangeHandlerTests(ITestOutputHelper testOutputHelper) +public class ChangeHandlerTests { #region Test Setup @@ -12,8 +13,8 @@ public class ChangeHandlerTests(ITestOutputHelper testOutputHelper) #endregion - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateDirectory_CustomException_ShouldNotCreateDirectory( string path, Exception exceptionToThrow) { @@ -31,8 +32,8 @@ public async Task CreateDirectory_CustomException_ShouldNotCreateDirectory( await That(exception).IsEqualTo(exceptionToThrow); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateDirectory_CustomException_ShouldOnlyTriggerChangeOccurring( string path, Exception exceptionToThrow) { @@ -47,8 +48,8 @@ public async Task CreateDirectory_CustomException_ShouldOnlyTriggerChangeOccurri await That(receivedPath!).IsNull(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateDirectory_WithParentDirectories_ShouldTriggerNotificationForEachDirectory( string path1, string path2, string path3) @@ -60,7 +61,7 @@ public async Task using IAwaitableCallback onEvent = FileSystem.Notify .OnEvent(c => { - testOutputHelper.WriteLine($"Received event {c}"); + Console.WriteLine($"Received event {c}"); eventCount++; }, c => c.ChangeType == WatcherChangeTypes.Created); @@ -71,8 +72,8 @@ public async Task await That(eventCount).IsEqualTo(3); } - [Theory] - [MemberData(nameof(NotificationTriggeringMethods))] + [Test] + [MethodDataSource(nameof(NotificationTriggeringMethods))] public async Task ExecuteCallback_ShouldTriggerNotification( Action? initialization, Action callback, @@ -96,7 +97,7 @@ public async Task ExecuteCallback_ShouldTriggerNotification( await That(receivedPath).IsEqualTo(FileSystem.Path.GetFullPath(path)); } - [Fact] + [Test] public async Task Watcher_ShouldNotTriggerWhenFileSystemWatcherDoesNotMatch() { FileSystem.Directory.CreateDirectory("bar"); @@ -114,7 +115,7 @@ void Act() => await That(Act).Throws(); } - [Fact] + [Test] public async Task Watcher_ShouldTriggerWhenFileSystemWatcherSendsNotification() { bool isTriggered = false; @@ -126,7 +127,7 @@ public async Task Watcher_ShouldTriggerWhenFileSystemWatcherSendsNotification() using IAwaitableCallback onEvent = FileSystem.Watcher.OnTriggered(); FileSystem.File.WriteAllText(@"foo.txt", "some-text"); - onEvent.Wait(timeout: 5000); + onEvent.Wait(timeout: 30000); await That(isTriggered).IsTrue(); } @@ -134,37 +135,21 @@ public async Task Watcher_ShouldTriggerWhenFileSystemWatcherSendsNotification() #region Helpers public static - TheoryData< + IEnumerable<( Action?, Action, WatcherChangeTypes, FileSystemTypes, - string> NotificationTriggeringMethods() + string)> NotificationTriggeringMethods() { - return new TheoryData< - Action?, - Action, - WatcherChangeTypes, - FileSystemTypes, - string> - { - { - null, (f, p) => f.Directory.CreateDirectory(p), WatcherChangeTypes.Created, - FileSystemTypes.Directory, $"path_{Guid.NewGuid()}" - }, - { - (f, p) => f.Directory.CreateDirectory(p), (f, p) => f.Directory.Delete(p), - WatcherChangeTypes.Deleted, FileSystemTypes.Directory, $"path_{Guid.NewGuid()}" - }, - { - null, (f, p) => f.File.WriteAllText(p, null), WatcherChangeTypes.Created, - FileSystemTypes.File, $"path_{Guid.NewGuid()}" - }, - { - (f, p) => f.File.WriteAllText(p, null), (f, p) => f.File.Delete(p), - WatcherChangeTypes.Deleted, FileSystemTypes.File, $"path_{Guid.NewGuid()}" - }, - }; + yield return (null, (f, p) => f.Directory.CreateDirectory(p), WatcherChangeTypes.Created, + FileSystemTypes.Directory, $"path_{Guid.NewGuid()}"); + yield return ((f, p) => f.Directory.CreateDirectory(p), (f, p) => f.Directory.Delete(p), + WatcherChangeTypes.Deleted, FileSystemTypes.Directory, $"path_{Guid.NewGuid()}"); + yield return (null, (f, p) => f.File.WriteAllText(p, null), WatcherChangeTypes.Created, + FileSystemTypes.File, $"path_{Guid.NewGuid()}"); + yield return ((f, p) => f.File.WriteAllText(p, null), (f, p) => f.File.Delete(p), + WatcherChangeTypes.Deleted, FileSystemTypes.File, $"path_{Guid.NewGuid()}"); } #endregion diff --git a/Tests/Testably.Abstractions.Testing.Tests/FileSystem/DefaultAccessControlStrategyTests.cs b/Tests/Testably.Abstractions.Testing.Tests/FileSystem/DefaultAccessControlStrategyTests.cs index 37aaff048..7ea23b1cb 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/FileSystem/DefaultAccessControlStrategyTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/FileSystem/DefaultAccessControlStrategyTests.cs @@ -11,7 +11,7 @@ public class DefaultAccessControlStrategyTests #endregion - [Fact] + [Test] public async Task Constructor_NullCallback_ShouldThrowArgumentNullException() { void Act() @@ -22,7 +22,7 @@ void Act() await That(Act).ThrowsExactly().WithParamName("callback"); } - [Fact] + [Test] public async Task IsAccessGranted_ShouldUseCallback() { DefaultAccessControlStrategy sut = new((p, _) => p.StartsWith('a')); diff --git a/Tests/Testably.Abstractions.Testing.Tests/FileSystem/DefaultSafeFileHandleStrategyTests.cs b/Tests/Testably.Abstractions.Testing.Tests/FileSystem/DefaultSafeFileHandleStrategyTests.cs index 189f7ea29..956dd89ad 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/FileSystem/DefaultSafeFileHandleStrategyTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/FileSystem/DefaultSafeFileHandleStrategyTests.cs @@ -13,7 +13,7 @@ public class DefaultSafeFileHandleStrategyTests #endregion - [Fact] + [Test] public async Task Constructor_NullCallback_ShouldThrowArgumentNullException() { void Act() @@ -24,7 +24,7 @@ void Act() await That(Act).ThrowsExactly().WithParamName("callback"); } - [Fact] + [Test] public async Task MapSafeFileHandle_ShouldReturnExpectedValue() { SafeFileHandle fooSafeFileHandle = new(); diff --git a/Tests/Testably.Abstractions.Testing.Tests/FileSystem/DirectoryMockTests.cs b/Tests/Testably.Abstractions.Testing.Tests/FileSystem/DirectoryMockTests.cs index 9e8fcf62f..63140d62c 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/FileSystem/DirectoryMockTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/FileSystem/DirectoryMockTests.cs @@ -4,7 +4,7 @@ namespace Testably.Abstractions.Testing.Tests.FileSystem; public class DirectoryMockTests { - [Fact] + [Test] public async Task EnumerateDirectories_UnauthorizedParentAccess_ShouldThrowUnauthorizedAccessExceptionImmediately() { @@ -25,7 +25,7 @@ await That(Act).Throws() .WithHResult(-2147024891); } - [Fact] + [Test] public async Task EnumerateFiles_UnauthorizedParentAccess_ShouldThrowUnauthorizedAccessExceptionImmediately() { @@ -46,7 +46,7 @@ await That(Act).Throws() .WithHResult(-2147024891); } - [Fact] + [Test] public async Task EnumerateFileSystemEntries_UnauthorizedParentAccess_ShouldThrowUnauthorizedAccessExceptionImmediately() { diff --git a/Tests/Testably.Abstractions.Testing.Tests/FileSystem/DriveInfoMockTests.cs b/Tests/Testably.Abstractions.Testing.Tests/FileSystem/DriveInfoMockTests.cs index 74b468087..dd1c8c967 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/FileSystem/DriveInfoMockTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/FileSystem/DriveInfoMockTests.cs @@ -12,8 +12,8 @@ public class DriveInfoMockTests #endregion - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AvailableFreeSpace_CannotGetNegative(long size) { FileSystem.WithDrive(d => d.SetTotalSize(size)); @@ -24,8 +24,8 @@ public async Task AvailableFreeSpace_CannotGetNegative(long size) await That(drive.AvailableFreeSpace).IsEqualTo(size); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AvailableFreeSpace_NotEnoughSpace_ShouldThrowIOException( int fileSize, string path) { @@ -41,8 +41,8 @@ void Act() await That(drive.AvailableFreeSpace).IsEqualTo(fileSize - 1); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AvailableFreeSpace_ShouldBeChangedWhenAppendingToAFile( string fileContent1, string fileContent2, int expectedRemainingBytes, string path, Encoding encoding) @@ -60,10 +60,10 @@ public async Task AvailableFreeSpace_ShouldBeChangedWhenAppendingToAFile( await That(drive.AvailableFreeSpace).IsEqualTo(expectedRemainingBytes); } - [Theory] - [InlineAutoData(0)] - [InlineAutoData(1)] - [InlineAutoData(10)] + [Test] + [AutoArguments(0)] + [AutoArguments(1)] + [AutoArguments(10)] public async Task AvailableFreeSpace_ShouldBeChangedWhenWorkingWithStreams( int reduceLength, string path, string previousContent) { @@ -81,8 +81,8 @@ public async Task AvailableFreeSpace_ShouldBeChangedWhenWorkingWithStreams( await That(drive.AvailableFreeSpace).IsEqualTo(previousFreeSpace + reduceLength); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AvailableFreeSpace_ShouldBeReducedByWritingToFile( int fileSize, string path) { @@ -97,8 +97,8 @@ public async Task AvailableFreeSpace_ShouldBeReducedByWritingToFile( await That(drive.AvailableFreeSpace).IsEqualTo(0); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AvailableFreeSpace_ShouldBeReleasedWhenDeletingAFile( int fileSize, string path) { @@ -114,8 +114,8 @@ public async Task AvailableFreeSpace_ShouldBeReleasedWhenDeletingAFile( await That(drive.AvailableFreeSpace).IsEqualTo(fileSize); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AvailableFreeSpace_ShouldBeSetTotalSize(long size) { FileSystem.WithDrive(d => d.SetTotalSize(size)); @@ -125,10 +125,10 @@ public async Task AvailableFreeSpace_ShouldBeSetTotalSize(long size) await That(drive.AvailableFreeSpace).IsEqualTo(size); } - [Theory] - [InlineData(@"//foo", @"//foo")] - [InlineData(@"//foo/bar", @"//foo")] - [InlineData(@"//foo/bar/xyz", @"//foo")] + [Test] + [Arguments(@"//foo", @"//foo")] + [Arguments(@"//foo/bar", @"//foo")] + [Arguments(@"//foo/bar/xyz", @"//foo")] public async Task New_DriveNameWithUncPath_ShouldUseTopMostDirectory( string driveName, string expectedName) { @@ -141,8 +141,8 @@ public async Task New_DriveNameWithUncPath_ShouldUseTopMostDirectory( await That(drive.Name).IsEqualTo(expectedName); } - [Theory] - [InlineData("foo")] + [Test] + [Arguments("foo")] public async Task New_InvalidDriveName_ShouldThrowArgumentException(string driveName) { Exception? exception = Record.Exception(() => @@ -153,7 +153,7 @@ public async Task New_InvalidDriveName_ShouldThrowArgumentException(string drive await That(exception).IsExactly(); } - [Fact] + [Test] public async Task New_Null_ShouldReturnNull() { IDriveInfo? drive = @@ -162,7 +162,7 @@ public async Task New_Null_ShouldReturnNull() await That(drive).IsNull(); } - [Fact] + [Test] public async Task New_UncPath_ShouldSetFlag() { IDriveInfo drive = @@ -171,9 +171,9 @@ public async Task New_UncPath_ShouldSetFlag() await That((drive as DriveInfoMock)?.IsUncPath).IsTrue(); } - [Theory] - [InlineData("C", "C:\\")] - [InlineData("d", "D:\\")] + [Test] + [Arguments("C", "C:\\")] + [Arguments("d", "D:\\")] public async Task New_ValidDriveName_ShouldAppendColonAndSlash( string driveName, string expectedDriveName) { @@ -183,8 +183,8 @@ public async Task New_ValidDriveName_ShouldAppendColonAndSlash( await That(result.Name).IsEqualTo(expectedDriveName); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task NotReady_AccessDirectory_ShouldThrowIOException( string path) { @@ -198,8 +198,8 @@ public async Task NotReady_AccessDirectory_ShouldThrowIOException( await That(exception).IsExactly(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task NotReady_AccessFile_ShouldThrowIOException( string path, string contents) { @@ -214,7 +214,7 @@ public async Task NotReady_AccessFile_ShouldThrowIOException( await That(exception).IsExactly(); } - [Fact] + [Test] public async Task SetDriveFormat_Default_ShouldBeNTFS() { FileSystem.WithDrive(d => d.SetDriveFormat()); @@ -223,8 +223,8 @@ public async Task SetDriveFormat_Default_ShouldBeNTFS() await That(drive.DriveFormat).IsEqualTo("NTFS"); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task SetDriveFormat_ShouldChangeDriveFormat(string driveFormat) { FileSystem.WithDrive(d => d.SetDriveFormat(driveFormat)); @@ -233,7 +233,7 @@ public async Task SetDriveFormat_ShouldChangeDriveFormat(string driveFormat) await That(drive.DriveFormat).IsEqualTo(driveFormat); } - [Fact] + [Test] public async Task SetDriveType_Default_ShouldBeFixed() { FileSystem.WithDrive(d => d.SetDriveType()); @@ -242,8 +242,8 @@ public async Task SetDriveType_Default_ShouldBeFixed() await That(drive.DriveType).IsEqualTo(DriveType.Fixed); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task SetDriveType_ShouldChangeDriveType(DriveType driveType) { FileSystem.WithDrive(d => d.SetDriveType(driveType)); @@ -252,9 +252,9 @@ public async Task SetDriveType_ShouldChangeDriveType(DriveType driveType) await That(drive.DriveType).IsEqualTo(driveType); } - [Theory] - [InlineData(true)] - [InlineData(false)] + [Test] + [Arguments(true)] + [Arguments(false)] public async Task SetIsReady_ShouldChangeIsReady(bool isReady) { FileSystem.WithDrive(d => d.SetIsReady(isReady)); @@ -263,7 +263,7 @@ public async Task SetIsReady_ShouldChangeIsReady(bool isReady) await That(drive.IsReady).IsEqualTo(isReady); } - [Fact] + [Test] public async Task SetTotalSize_Default_ShouldBe1Gigabyte() { FileSystem.WithDrive(d => d.SetTotalSize()); diff --git a/Tests/Testably.Abstractions.Testing.Tests/FileSystem/FileMockTests.cs b/Tests/Testably.Abstractions.Testing.Tests/FileSystem/FileMockTests.cs index a4b10f6b1..62b92215b 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/FileSystem/FileMockTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/FileSystem/FileMockTests.cs @@ -10,8 +10,8 @@ namespace Testably.Abstractions.Testing.Tests.FileSystem; public class FileMockTests { #if FEATURE_FILESYSTEM_SAFEFILEHANDLE - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetAttributes_SafeFileHandle_WithMissingFile_ShouldThrowFileNotFoundException( string path) { @@ -29,8 +29,8 @@ public async Task GetAttributes_SafeFileHandle_WithMissingFile_ShouldThrowFileNo } #endif #if FEATURE_FILESYSTEM_SAFEFILEHANDLE - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetUnixFileMode_SafeFileHandle_ShouldThrowPlatformNotSupportedExceptionOnWindows( string path) { @@ -54,8 +54,8 @@ public async Task GetUnixFileMode_SafeFileHandle_ShouldThrowPlatformNotSupported #endif #if FEATURE_FILESYSTEM_SAFEFILEHANDLE - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task SetAttributes_SafeFileHandle_ShouldUpdateValue( string path, FileAttributes attributes) { @@ -75,8 +75,8 @@ public async Task SetAttributes_SafeFileHandle_ShouldUpdateValue( } #endif - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task SetCreationTime(string path, DateTime creationTime) { MockFileSystem fileSystem = new(); @@ -88,8 +88,8 @@ public async Task SetCreationTime(string path, DateTime creationTime) } #if FEATURE_FILESYSTEM_SAFEFILEHANDLE - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task SetCreationTime_SafeFileHandle_ShouldUpdateValue( string path, DateTime creationTime) { @@ -107,8 +107,8 @@ public async Task SetCreationTime_SafeFileHandle_ShouldUpdateValue( } #endif - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task SetCreationTimeUtc(string path, DateTime creationTime) { MockFileSystem fileSystem = new(); @@ -120,8 +120,8 @@ public async Task SetCreationTimeUtc(string path, DateTime creationTime) } #if FEATURE_FILESYSTEM_SAFEFILEHANDLE - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task SetCreationTimeUtc_SafeFileHandle_ShouldUpdateValue( string path, DateTime creationTimeUtc) { @@ -140,8 +140,8 @@ public async Task SetCreationTimeUtc_SafeFileHandle_ShouldUpdateValue( #endif #if FEATURE_FILESYSTEM_SAFEFILEHANDLE - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task SetLastAccessTime_SafeFileHandle_ShouldUpdateValue( string path, DateTime lastAccessTime) { @@ -160,8 +160,8 @@ public async Task SetLastAccessTime_SafeFileHandle_ShouldUpdateValue( #endif #if FEATURE_FILESYSTEM_SAFEFILEHANDLE - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task SetLastAccessTimeUtc_SafeFileHandle_ShouldUpdateValue( string path, DateTime lastAccessTimeUtc) { @@ -180,8 +180,8 @@ public async Task SetLastAccessTimeUtc_SafeFileHandle_ShouldUpdateValue( #endif #if FEATURE_FILESYSTEM_SAFEFILEHANDLE - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task SetLastWriteTime_SafeFileHandle_ShouldUpdateValue( string path, DateTime lastWriteTime) { @@ -200,8 +200,8 @@ public async Task SetLastWriteTime_SafeFileHandle_ShouldUpdateValue( #endif #if FEATURE_FILESYSTEM_SAFEFILEHANDLE - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task SetLastWriteTimeUtc_SafeFileHandle_ShouldUpdateValue( string path, DateTime lastWriteTimeUtc) { @@ -220,8 +220,8 @@ public async Task SetLastWriteTimeUtc_SafeFileHandle_ShouldUpdateValue( #endif #if FEATURE_FILESYSTEM_SAFEFILEHANDLE - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task SetUnixFileMode_SafeFileHandle_ShouldUpdateValue( string path, UnixFileMode mode) { diff --git a/Tests/Testably.Abstractions.Testing.Tests/FileSystem/FileStreamFactoryMockTests.SafeFileHandle.cs b/Tests/Testably.Abstractions.Testing.Tests/FileSystem/FileStreamFactoryMockTests.SafeFileHandle.cs index dba2dcd33..db4e47f4f 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/FileSystem/FileStreamFactoryMockTests.SafeFileHandle.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/FileSystem/FileStreamFactoryMockTests.SafeFileHandle.cs @@ -8,8 +8,8 @@ namespace Testably.Abstractions.Testing.Tests.FileSystem; public sealed partial class FileStreamFactoryMockTests { - [Theory] - [AutoData] + [Test] + [AutoArguments] public void MissingFile_ShouldThrowFileNotFoundException( string path, string contents) { @@ -33,8 +33,8 @@ public void MissingFile_ShouldThrowFileNotFoundException( .Which.Message.Should().Contain($"'{MockFileSystem.Path.GetFullPath(path)}'"); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public void UnregisteredFileHandle_ShouldThrowNotSupportedException( string path, string contents) { @@ -55,8 +55,8 @@ public void UnregisteredFileHandle_ShouldThrowNotSupportedException( nameof(MockFileSystem.WithSafeFileHandleStrategy)); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public void UnregisteredFileHandle_WithBufferSize_ShouldThrowNotSupportedException( string path, string contents, int bufferSize) { @@ -77,8 +77,8 @@ public void UnregisteredFileHandle_WithBufferSize_ShouldThrowNotSupportedExcepti nameof(MockFileSystem.WithSafeFileHandleStrategy)); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public void UnregisteredFileHandle_WithBufferSizeAndIsAsync_ShouldThrowNotSupportedException( string path, string contents, int bufferSize, bool isAsync) diff --git a/Tests/Testably.Abstractions.Testing.Tests/FileSystem/FileStreamFactoryMockTests.cs b/Tests/Testably.Abstractions.Testing.Tests/FileSystem/FileStreamFactoryMockTests.cs index 927d54d05..a7354a34f 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/FileSystem/FileStreamFactoryMockTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/FileSystem/FileStreamFactoryMockTests.cs @@ -4,7 +4,7 @@ namespace Testably.Abstractions.Testing.Tests.FileSystem; -[Collection(nameof(IDirectoryCleaner))] +[NotInParallel(nameof(IDirectoryCleaner))] public sealed class FileStreamFactoryMockTests : IDisposable { #region Test Setup @@ -28,8 +28,8 @@ public void Dispose() #endregion - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Wrap_ShouldThrowNotSupportedException( string path, string contents) { @@ -46,11 +46,11 @@ public async Task Wrap_ShouldThrowNotSupportedException( } #if FEATURE_FILESYSTEM_UNIXFILEMODE - [Theory] - [InlineAutoData(FileMode.CreateNew)] - [InlineAutoData(FileMode.Create)] - [InlineAutoData(FileMode.OpenOrCreate)] - [InlineAutoData(FileMode.Append)] + [Test] + [AutoArguments(FileMode.CreateNew)] + [AutoArguments(FileMode.Create)] + [AutoArguments(FileMode.OpenOrCreate)] + [AutoArguments(FileMode.Append)] [SuppressMessage("Interoperability", "CA1416:Validate platform compatibility", Justification = "Skip.If(Test.RunsOnWindows) handles platform check.")] public async Task New_ShouldSetUnixFileMode(FileMode mode, string path) @@ -70,9 +70,9 @@ public async Task New_ShouldSetUnixFileMode(FileMode mode, string path) await That(result).IsEqualTo(options.UnixCreateMode); } - [Theory] - [InlineAutoData(FileMode.Open)] - [InlineAutoData(FileMode.Truncate)] + [Test] + [AutoArguments(FileMode.Open)] + [AutoArguments(FileMode.Truncate)] [SuppressMessage("Interoperability", "CA1416:Validate platform compatibility", Justification = "Skip.If(Test.RunsOnWindows) handles platform check.")] public async Task New_ShouldThrowArgumentException_When_InvalidFileMode(FileMode mode, diff --git a/Tests/Testably.Abstractions.Testing.Tests/FileSystem/FileSystemExtensibilityTests.cs b/Tests/Testably.Abstractions.Testing.Tests/FileSystem/FileSystemExtensibilityTests.cs index b794592e7..6453861a1 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/FileSystem/FileSystemExtensibilityTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/FileSystem/FileSystemExtensibilityTests.cs @@ -1,20 +1,17 @@ +using System.Collections.Generic; + namespace Testably.Abstractions.Testing.Tests.FileSystem; public class FileSystemExtensibilityTests { - #region Test Setup - - public static TheoryData GetFileSystems - => new() - { - (IFileSystem)new RealFileSystem(), - (IFileSystem)new MockFileSystem(), - }; - - #endregion + public static IEnumerable> GetFileSystems() + { + yield return () => new RealFileSystem(); + yield return () => new MockFileSystem(); + } - [Theory] - [MemberData(nameof(GetFileSystems))] + [Test] + [MethodDataSource(nameof(GetFileSystems))] public async Task Directory_ShouldSetExtensionPoint(IFileSystem fileSystem) { IDirectory sut = fileSystem.Directory; @@ -24,8 +21,8 @@ public async Task Directory_ShouldSetExtensionPoint(IFileSystem fileSystem) await That(result).IsSameAs(fileSystem); } - [Theory] - [MemberData(nameof(GetFileSystems))] + [Test] + [MethodDataSource(nameof(GetFileSystems))] public async Task DirectoryInfo_ShouldSetExtensionPoint(IFileSystem fileSystem) { IDirectoryInfo sut = fileSystem.DirectoryInfo.New("foo"); @@ -35,8 +32,8 @@ public async Task DirectoryInfo_ShouldSetExtensionPoint(IFileSystem fileSystem) await That(result).IsSameAs(fileSystem); } - [Theory] - [MemberData(nameof(GetFileSystems))] + [Test] + [MethodDataSource(nameof(GetFileSystems))] public async Task DirectoryInfoFactory_ShouldSetExtensionPoint(IFileSystem fileSystem) { IDirectoryInfoFactory sut = fileSystem.DirectoryInfo; @@ -46,8 +43,8 @@ public async Task DirectoryInfoFactory_ShouldSetExtensionPoint(IFileSystem fileS await That(result).IsSameAs(fileSystem); } - [Theory] - [MemberData(nameof(GetFileSystems))] + [Test] + [MethodDataSource(nameof(GetFileSystems))] public async Task DriveInfo_ShouldSetExtensionPoint(IFileSystem fileSystem) { IDriveInfo sut = fileSystem.DriveInfo.GetDrives()[0]; @@ -57,8 +54,8 @@ public async Task DriveInfo_ShouldSetExtensionPoint(IFileSystem fileSystem) await That(result).IsSameAs(fileSystem); } - [Theory] - [MemberData(nameof(GetFileSystems))] + [Test] + [MethodDataSource(nameof(GetFileSystems))] public async Task DriveInfoFactory_ShouldSetExtensionPoint(IFileSystem fileSystem) { IDriveInfoFactory sut = fileSystem.DriveInfo; @@ -68,8 +65,8 @@ public async Task DriveInfoFactory_ShouldSetExtensionPoint(IFileSystem fileSyste await That(result).IsSameAs(fileSystem); } - [Theory] - [MemberData(nameof(GetFileSystems))] + [Test] + [MethodDataSource(nameof(GetFileSystems))] public async Task File_ShouldSetExtensionPoint(IFileSystem fileSystem) { IFile sut = fileSystem.File; @@ -79,8 +76,8 @@ public async Task File_ShouldSetExtensionPoint(IFileSystem fileSystem) await That(result).IsSameAs(fileSystem); } - [Theory] - [MemberData(nameof(GetFileSystems))] + [Test] + [MethodDataSource(nameof(GetFileSystems))] public async Task FileInfo_ShouldSetExtensionPoint(IFileSystem fileSystem) { IFileInfo sut = fileSystem.FileInfo.New("foo"); @@ -90,8 +87,8 @@ public async Task FileInfo_ShouldSetExtensionPoint(IFileSystem fileSystem) await That(result).IsSameAs(fileSystem); } - [Theory] - [MemberData(nameof(GetFileSystems))] + [Test] + [MethodDataSource(nameof(GetFileSystems))] public async Task FileInfoFactory_ShouldSetExtensionPoint(IFileSystem fileSystem) { IFileInfoFactory sut = fileSystem.FileInfo; @@ -101,8 +98,8 @@ public async Task FileInfoFactory_ShouldSetExtensionPoint(IFileSystem fileSystem await That(result).IsSameAs(fileSystem); } - [Theory] - [MemberData(nameof(GetFileSystems))] + [Test] + [MethodDataSource(nameof(GetFileSystems))] public async Task FileStreamFactory_ShouldSetExtensionPoint(IFileSystem fileSystem) { IFileStreamFactory sut = fileSystem.FileStream; @@ -112,8 +109,8 @@ public async Task FileStreamFactory_ShouldSetExtensionPoint(IFileSystem fileSyst await That(result).IsSameAs(fileSystem); } - [Theory] - [MemberData(nameof(GetFileSystems))] + [Test] + [MethodDataSource(nameof(GetFileSystems))] public async Task FileSystemInfo_ShouldSetExtensionPoint(IFileSystem fileSystem) { IFileSystemInfo sut = fileSystem.FileInfo.New("foo"); @@ -123,8 +120,8 @@ public async Task FileSystemInfo_ShouldSetExtensionPoint(IFileSystem fileSystem) await That(result).IsSameAs(fileSystem); } - [Theory] - [MemberData(nameof(GetFileSystems))] + [Test] + [MethodDataSource(nameof(GetFileSystems))] public async Task FileSystemWatcher_ShouldSetExtensionPoint(IFileSystem fileSystem) { IFileSystemWatcher sut = fileSystem.FileSystemWatcher.New(); @@ -134,8 +131,8 @@ public async Task FileSystemWatcher_ShouldSetExtensionPoint(IFileSystem fileSyst await That(result).IsSameAs(fileSystem); } - [Theory] - [MemberData(nameof(GetFileSystems))] + [Test] + [MethodDataSource(nameof(GetFileSystems))] public async Task FileSystemWatcherFactory_ShouldSetExtensionPoint(IFileSystem fileSystem) { IFileSystemWatcherFactory sut = fileSystem.FileSystemWatcher; @@ -145,8 +142,8 @@ public async Task FileSystemWatcherFactory_ShouldSetExtensionPoint(IFileSystem f await That(result).IsSameAs(fileSystem); } - [Theory] - [MemberData(nameof(GetFileSystems))] + [Test] + [MethodDataSource(nameof(GetFileSystems))] public async Task Path_ShouldSetExtensionPoint(IFileSystem fileSystem) { IPath sut = fileSystem.Path; diff --git a/Tests/Testably.Abstractions.Testing.Tests/FileSystem/FileSystemWatcherFactoryMockTests.cs b/Tests/Testably.Abstractions.Testing.Tests/FileSystem/FileSystemWatcherFactoryMockTests.cs index 0a09f884c..19bcdc603 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/FileSystem/FileSystemWatcherFactoryMockTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/FileSystem/FileSystemWatcherFactoryMockTests.cs @@ -3,7 +3,7 @@ namespace Testably.Abstractions.Testing.Tests.FileSystem; -[Collection(nameof(IDirectoryCleaner))] +[NotInParallel(nameof(IDirectoryCleaner))] public sealed class FileSystemWatcherFactoryMockTests : IDisposable { #region Test Setup @@ -29,8 +29,8 @@ public void Dispose() #endregion - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Wrap_ShouldUsePropertiesFromFileSystemWatcher( string path, bool includeSubdirectories, NotifyFilters notifyFilter, int internalBufferSize, bool enableRaisingEvents, string filter) @@ -56,8 +56,8 @@ public async Task Wrap_ShouldUsePropertiesFromFileSystemWatcher( } #if FEATURE_FILESYSTEMWATCHER_ADVANCED - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Wrap_WithFilters_ShouldUsePropertiesFromFileSystemWatcher( string[] filters) { diff --git a/Tests/Testably.Abstractions.Testing.Tests/FileSystem/FileSystemWatcherMockTests.cs b/Tests/Testably.Abstractions.Testing.Tests/FileSystem/FileSystemWatcherMockTests.cs index d49e81997..f2849da84 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/FileSystem/FileSystemWatcherMockTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/FileSystem/FileSystemWatcherMockTests.cs @@ -4,7 +4,7 @@ namespace Testably.Abstractions.Testing.Tests.FileSystem; -[Collection(nameof(IDirectoryCleaner))] +[NotInParallel(nameof(IDirectoryCleaner))] public sealed class FileSystemWatcherMockTests : IDisposable { #region Test Setup @@ -32,8 +32,8 @@ public void Dispose() #endregion - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Error_DefaultTo64Messages_ShouldBeTriggeredWhenBufferOverflows( string path) { @@ -63,7 +63,7 @@ public async Task Error_DefaultTo64Messages_ShouldBeTriggeredWhenBufferOverflows // ReSharper disable once AccessToDisposedClosure try { - block1.Wait(10000, TestContext.Current.CancellationToken); + block1.Wait(10000, TestContext.Current!.Execution.CancellationToken); } catch (ObjectDisposedException) { @@ -82,14 +82,14 @@ public async Task Error_DefaultTo64Messages_ShouldBeTriggeredWhenBufferOverflows FileSystem.Directory.CreateDirectory($"{i}_{path}"); } - await That(block2.Wait(10000, TestContext.Current.CancellationToken)).IsTrue(); + await That(block2.Wait(10000, TestContext.Current!.Execution.CancellationToken)).IsTrue(); await That(result).IsNotNull(); await That(result!.GetException()).IsExactly(); } - [Theory] - [InlineAutoData(4096)] - [InlineAutoData(8192)] + [Test] + [AutoArguments(4096)] + [AutoArguments(8192)] public async Task Error_ShouldBeTriggeredWhenBufferOverflows( int internalBufferSize, string path) { @@ -120,7 +120,7 @@ public async Task Error_ShouldBeTriggeredWhenBufferOverflows( // ReSharper disable once AccessToDisposedClosure try { - block1.Wait(5000, TestContext.Current.CancellationToken); + block1.Wait(30000, TestContext.Current!.Execution.CancellationToken); } catch (ObjectDisposedException) { @@ -140,14 +140,14 @@ public async Task Error_ShouldBeTriggeredWhenBufferOverflows( FileSystem.Directory.CreateDirectory($"{i}_{path}"); } - await That(block2.Wait(5000, TestContext.Current.CancellationToken)).IsTrue(); + await That(block2.Wait(30000, TestContext.Current!.Execution.CancellationToken)).IsTrue(); await That(result).IsNotNull(); await That(result!.GetException()).IsExactly(); } #if FEATURE_FILESYSTEMWATCHER_ADVANCED - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Filter_ShouldResetFiltersToOnlyContainASingleValue( string[] filters, string expectedFilter) { @@ -168,8 +168,8 @@ public async Task Filter_ShouldResetFiltersToOnlyContainASingleValue( } #endif - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task InternalBufferSize_ShouldResetQueue(string path1, string path2) { Skip.If(true, "Brittle test fails on build system (disabled in #284)"); @@ -199,7 +199,7 @@ public async Task InternalBufferSize_ShouldResetQueue(string path1, string path2 // ReSharper disable once AccessToDisposedClosure try { - block1.Wait(100, TestContext.Current.CancellationToken); + block1.Wait(100, TestContext.Current!.Execution.CancellationToken); } catch (ObjectDisposedException) { @@ -230,17 +230,17 @@ public async Task InternalBufferSize_ShouldResetQueue(string path1, string path2 FileSystem.Directory.CreateDirectory($"{i}_{path2}"); } - await That(block2.Wait(100, TestContext.Current.CancellationToken)).IsFalse(); + await That(block2.Wait(100, TestContext.Current!.Execution.CancellationToken)).IsFalse(); await That(result).IsNull(); } #if CAN_SIMULATE_OTHER_OS public sealed class EventArgsTests { - [Theory] - [InlineAutoData(SimulationMode.Linux)] - [InlineAutoData(SimulationMode.MacOS)] - [InlineAutoData(SimulationMode.Windows)] + [Test] + [AutoArguments(SimulationMode.Linux)] + [AutoArguments(SimulationMode.MacOS)] + [AutoArguments(SimulationMode.Windows)] public async Task FileSystemEventArgs_ShouldUseDirectorySeparatorFromSimulatedFileSystem( SimulationMode simulationMode, string parentDirectory, string directoryName) { @@ -269,7 +269,7 @@ public async Task FileSystemEventArgs_ShouldUseDirectorySeparatorFromSimulatedFi fileSystemWatcher.NotifyFilter = NotifyFilters.DirectoryName; fileSystemWatcher.EnableRaisingEvents = true; fileSystem.Directory.CreateDirectory(expectedFullPath); - ms.Wait(5000, TestContext.Current.CancellationToken); + ms.Wait(30000, TestContext.Current!.Execution.CancellationToken); await That(result).IsNotNull(); await That(result!.FullPath).IsEqualTo(expectedFullPath); @@ -279,10 +279,10 @@ public async Task FileSystemEventArgs_ShouldUseDirectorySeparatorFromSimulatedFi #endif #if CAN_SIMULATE_OTHER_OS - [Theory] - [InlineAutoData(SimulationMode.Linux)] - [InlineAutoData(SimulationMode.MacOS)] - [InlineAutoData(SimulationMode.Windows)] + [Test] + [AutoArguments(SimulationMode.Linux)] + [AutoArguments(SimulationMode.MacOS)] + [AutoArguments(SimulationMode.Windows)] public async Task RenamedEventArgs_ShouldUseDirectorySeparatorFromSimulatedFileSystem( SimulationMode simulationMode, string parentDirectory, string sourceName, string destinationName) @@ -316,7 +316,7 @@ public async Task RenamedEventArgs_ShouldUseDirectorySeparatorFromSimulatedFileS fileSystemWatcher.NotifyFilter = NotifyFilters.FileName; fileSystemWatcher.EnableRaisingEvents = true; fileSystem.File.Move(expectedOldFullPath, expectedFullPath); - ms.Wait(5000, TestContext.Current.CancellationToken); + ms.Wait(30000, TestContext.Current!.Execution.CancellationToken); await That(result).IsNotNull(); await That(result!.FullPath).IsEqualTo(expectedFullPath); diff --git a/Tests/Testably.Abstractions.Testing.Tests/FileSystem/FileVersionInfoFactoryMockTests.cs b/Tests/Testably.Abstractions.Testing.Tests/FileSystem/FileVersionInfoFactoryMockTests.cs index 4e5a9a364..4af16d18c 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/FileSystem/FileVersionInfoFactoryMockTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/FileSystem/FileVersionInfoFactoryMockTests.cs @@ -2,14 +2,14 @@ public sealed class FileVersionInfoFactoryMockTests { - [Theory] - [InlineData(".", "foo", "*", true)] - [InlineData(".", "foo", "f*o", true)] - [InlineData(".", "foo", "*fo", false)] - [InlineData("bar", "foo", "f*o", true)] - [InlineData("bar", "foo", "baz/f*o", false)] - [InlineData("bar", "foo", "/f*o", false)] - [InlineData("bar", "foo", "**/f*o", true)] + [Test] + [Arguments(".", "foo", "*", true)] + [Arguments(".", "foo", "f*o", true)] + [Arguments(".", "foo", "*fo", false)] + [Arguments("bar", "foo", "f*o", true)] + [Arguments("bar", "foo", "baz/f*o", false)] + [Arguments("bar", "foo", "/f*o", false)] + [Arguments("bar", "foo", "**/f*o", true)] public async Task ShouldSupportGlobPattern( string baseDirectory, string fileName, string globPattern, bool expectMatch) { @@ -25,8 +25,8 @@ public async Task ShouldSupportGlobPattern( await That(result.Comments).IsEqualTo(expected); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WhenRegistered_ShouldReturnFileVersionInfoWithRegisteredValues( string comments) { @@ -39,8 +39,8 @@ public async Task WhenRegistered_ShouldReturnFileVersionInfoWithRegisteredValues await That(result.Comments).IsEqualTo(comments); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WhenRegisteredUnderDifferentName_ShouldReturnDefaultValues( string comments) { diff --git a/Tests/Testably.Abstractions.Testing.Tests/FileSystem/PathMockTests.cs b/Tests/Testably.Abstractions.Testing.Tests/FileSystem/PathMockTests.cs index 986309f35..46a0bae6a 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/FileSystem/PathMockTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/FileSystem/PathMockTests.cs @@ -5,11 +5,11 @@ namespace Testably.Abstractions.Testing.Tests.FileSystem; public sealed class PathMockTests { #if CAN_SIMULATE_OTHER_OS - [Theory] - [InlineAutoData(SimulationMode.Native)] - [InlineAutoData(SimulationMode.Linux)] - [InlineAutoData(SimulationMode.MacOS)] - [InlineAutoData(SimulationMode.Windows)] + [Test] + [AutoArguments(SimulationMode.Native)] + [AutoArguments(SimulationMode.Linux)] + [AutoArguments(SimulationMode.MacOS)] + [AutoArguments(SimulationMode.Windows)] public async Task GetTempFileName_WithCollisions_ShouldThrowIOException( SimulationMode simulationMode, int fixedRandomValue) { @@ -31,8 +31,8 @@ void Act() await That(fileSystem.File.Exists(result)).IsTrue(); } #else - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetTempFileName_WithCollisions_ShouldThrowIOException( int fixedRandomValue) { diff --git a/Tests/Testably.Abstractions.Testing.Tests/FileSystemInitializer/DirectoryCleanerTests.cs b/Tests/Testably.Abstractions.Testing.Tests/FileSystemInitializer/DirectoryCleanerTests.cs index 2f4da4ac9..9839cbc07 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/FileSystemInitializer/DirectoryCleanerTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/FileSystemInitializer/DirectoryCleanerTests.cs @@ -5,7 +5,7 @@ namespace Testably.Abstractions.Testing.Tests.FileSystemInitializer; -[Collection(nameof(IDirectoryCleaner))] +[NotInParallel(nameof(IDirectoryCleaner))] public class DirectoryCleanerTests { #region Test Setup @@ -17,8 +17,8 @@ public DirectoryCleanerTests() #endregion - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Dispose_PermanentFailure_ShouldNotThrowException( Exception exception) { @@ -56,7 +56,7 @@ await That(receivedLogs).Contains(m => await That(receivedLogs).DoesNotContain("Cleanup was successful :-)"); } - [Fact] + [Test] public async Task Dispose_ShouldForceDeleteCurrentDirectory() { MockFileSystem sut = new(); @@ -70,7 +70,7 @@ public async Task Dispose_ShouldForceDeleteCurrentDirectory() await That(receivedLogs).Contains("Cleanup was successful :-)"); } - [Fact] + [Test] public async Task Dispose_ShouldResetCurrentDirectory() { MockFileSystem sut = new(); @@ -81,8 +81,8 @@ public async Task Dispose_ShouldResetCurrentDirectory() await That(sut.Directory.GetCurrentDirectory()).IsNotEqualTo(currentDirectory); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Dispose_TemporaryFailure_ShouldRetryAgain( Exception exception) { @@ -103,7 +103,7 @@ public async Task Dispose_TemporaryFailure_ShouldRetryAgain( await That(sut.Directory.Exists(currentDirectory)).IsFalse(); } - [Fact] + [Test] public async Task InitializeBasePath_ShouldCreateDirectoryAndLogBasePath() { MockFileSystem sut = new(); diff --git a/Tests/Testably.Abstractions.Testing.Tests/FileSystemInitializer/DirectoryDescriptionTests.cs b/Tests/Testably.Abstractions.Testing.Tests/FileSystemInitializer/DirectoryDescriptionTests.cs index 0646669d0..05e3d43a0 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/FileSystemInitializer/DirectoryDescriptionTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/FileSystemInitializer/DirectoryDescriptionTests.cs @@ -5,8 +5,8 @@ namespace Testably.Abstractions.Testing.Tests.FileSystemInitializer; public class DirectoryDescriptionTests { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Children_ShouldBeSortedAlphabetically(string[] childNames) { DirectoryDescription sut = new("foo", @@ -19,7 +19,7 @@ await That(sut.Children.Select(c => c.Name)).IsInAscendingOrder() .Using(StringComparer.Ordinal); } - [Fact] + [Test] public async Task Index_AccessToMissingChildShouldThrowTestingException() { DirectoryDescription sut = new("foo"); @@ -32,7 +32,7 @@ void Act() await That(Act).ThrowsExactly().WithMessage("*'bar'*").AsWildcard(); } - [Fact] + [Test] public async Task Index_ShouldGiveAccessToExistingChildDirectory() { DirectoryDescription child = new("bar"); @@ -43,7 +43,7 @@ public async Task Index_ShouldGiveAccessToExistingChildDirectory() await That(result).IsSameAs(child); } - [Fact] + [Test] public async Task Index_ShouldGiveAccessToNestedChildren() { FileDescription child3 = new("child3", "some-content"); diff --git a/Tests/Testably.Abstractions.Testing.Tests/FileSystemInitializer/FileDescriptionTests.cs b/Tests/Testably.Abstractions.Testing.Tests/FileSystemInitializer/FileDescriptionTests.cs index d7520a9d6..b14e89a87 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/FileSystemInitializer/FileDescriptionTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/FileSystemInitializer/FileDescriptionTests.cs @@ -4,8 +4,8 @@ namespace Testably.Abstractions.Testing.Tests.FileSystemInitializer; public class FileDescriptionTests { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Constructor_WithBytes_ShouldSetBytes(byte[] bytes) { FileDescription sut = new("foo", bytes); @@ -14,8 +14,8 @@ public async Task Constructor_WithBytes_ShouldSetBytes(byte[] bytes) await That(sut.Bytes).IsEqualTo(bytes).InAnyOrder(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Constructor_WithContent_ShouldSetContent(string content) { FileDescription sut = new("foo", content); @@ -24,7 +24,7 @@ public async Task Constructor_WithContent_ShouldSetContent(string content) await That(sut.Bytes).IsNull(); } - [Fact] + [Test] public async Task Index_AccessShouldThrowTestingException() { FileDescription sut = new("foo"); diff --git a/Tests/Testably.Abstractions.Testing.Tests/FileSystemInitializer/FileSystemInitializerTests.cs b/Tests/Testably.Abstractions.Testing.Tests/FileSystemInitializer/FileSystemInitializerTests.cs index 119d9be5f..88780ed71 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/FileSystemInitializer/FileSystemInitializerTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/FileSystemInitializer/FileSystemInitializerTests.cs @@ -6,8 +6,8 @@ namespace Testably.Abstractions.Testing.Tests.FileSystemInitializer; public class FileSystemInitializerTests { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task With_DirectoryDescriptions_ShouldCreateDirectories( DirectoryDescription[] directories) { @@ -23,8 +23,8 @@ public async Task With_DirectoryDescriptions_ShouldCreateDirectories( } } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task With_DirectoryDescriptions_WithSubdirectories_ShouldCreateDirectories( string parent, DirectoryDescription[] directories) { @@ -42,8 +42,8 @@ public async Task With_DirectoryDescriptions_WithSubdirectories_ShouldCreateDire } } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task With_FileDescription_WithBytes_ShouldCreateFileContent(string name, byte[] bytes) { @@ -58,8 +58,8 @@ public async Task With_FileDescription_WithBytes_ShouldCreateFileContent(string await That(fileSystem.File.ReadAllBytes(name)).IsEqualTo(bytes); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task With_FileDescription_WithContent_ShouldCreateFileContent(string name, string content) { @@ -74,8 +74,8 @@ public async Task With_FileDescription_WithContent_ShouldCreateFileContent(strin await That(fileSystem.File.ReadAllText(name)).IsEqualTo(content); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task With_FileDescriptions_ShouldCreateFiles(FileDescription[] files) { MockFileSystem fileSystem = new(); @@ -90,9 +90,9 @@ public async Task With_FileDescriptions_ShouldCreateFiles(FileDescription[] file } } - [Theory] - [InlineAutoData(true)] - [InlineAutoData(false)] + [Test] + [AutoArguments(true)] + [AutoArguments(false)] public async Task With_FileDescriptions_ShouldSetIsReadOnlyFlag(bool isReadOnly, string name) { FileDescription description = new(name) @@ -109,8 +109,8 @@ public async Task With_FileDescriptions_ShouldSetIsReadOnlyFlag(bool isReadOnly, await That(fileSystem.FileInfo.New(name).IsReadOnly).IsEqualTo(isReadOnly); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task With_FilesAndDirectories_ShouldBothBeCreated(string fileName, string directoryName) { @@ -126,8 +126,8 @@ public async Task With_FilesAndDirectories_ShouldBothBeCreated(string fileName, await That(fileSystem.Directory.Exists(directoryName)).IsTrue(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task With_FilesAndDirectoriesWithMultiplePathComponents_ShouldBeCreatedAtTheCorrectPath( string level1, string level2, string fileName) { @@ -145,8 +145,8 @@ public async Task With_FilesAndDirectoriesWithMultiplePathComponents_ShouldBeCre await That(fileSystem.File.Exists(filePath)).IsTrue(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task With_AbsoluteDirectoryWithChildren_ShouldBeCreatedAtTheCorrectPath( string level1, string level2, string fileName) { @@ -164,8 +164,8 @@ public async Task With_AbsoluteDirectoryWithChildren_ShouldBeCreatedAtTheCorrect await That(fileSystem.File.Exists(filePath)).IsTrue(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WithFile_ExistingDirectory_ShouldThrowTestingException(string path) { MockFileSystem fileSystem = new(); @@ -180,8 +180,8 @@ void Act() await That(Act).ThrowsExactly().WithMessage($"*{path}*").AsWildcard(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WithFile_ExistingFile_ShouldThrowTestingException(string path) { MockFileSystem fileSystem = new(); @@ -194,8 +194,8 @@ void Act() await That(Act).ThrowsExactly().WithMessage($"*{path}*").AsWildcard(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WithFile_HasStringContent_ShouldWriteFileContent(string path) { MockFileSystem fileSystem = new(); @@ -208,8 +208,8 @@ public async Task WithFile_HasStringContent_ShouldWriteFileContent(string path) await That(fileSystem.File.ReadAllText(path)).IsEqualTo("foo"); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WithFile_MissingDirectory_ShouldCreateDirectory(string directoryPath, string fileName) { @@ -224,8 +224,8 @@ public async Task WithFile_MissingDirectory_ShouldCreateDirectory(string directo await That(fileSystem.Directory.Exists(directoryPath)).IsTrue(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WithFile_MultiplePathComponents_ShouldCreateDirectories(string level1, string level2, string level3, string fileName) { @@ -242,8 +242,8 @@ public async Task WithFile_MultiplePathComponents_ShouldCreateDirectories(string await That(fileSystem.Directory.Exists(Path.Combine(level1, level2, level3))).IsTrue(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WithSubdirectories_ShouldCreateAllDirectories(string[] paths) { MockFileSystem fileSystem = new(); @@ -261,8 +261,8 @@ public async Task WithSubdirectories_ShouldCreateAllDirectories(string[] paths) await That(result).IsEqualTo(sut); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WithSubdirectory_ExistingDirectory_ShouldThrowTestingException(string path) { MockFileSystem fileSystem = new(); @@ -275,8 +275,8 @@ void Act() await That(Act).ThrowsExactly().WithMessage($"*{path}*").AsWildcard(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WithSubdirectory_ExistingFile_ShouldThrowTestingException(string path) { MockFileSystem fileSystem = new(); @@ -289,8 +289,8 @@ void Act() await That(Act).ThrowsExactly().WithMessage($"*{path}*").AsWildcard(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WithSubdirectory_MultipleDirectoryLevels(string level1, string level2) { string path = Path.Combine(level1, level2); diff --git a/Tests/Testably.Abstractions.Testing.Tests/FileSystemInitializer/FileVersionInfoBuilderTests.cs b/Tests/Testably.Abstractions.Testing.Tests/FileSystemInitializer/FileVersionInfoBuilderTests.cs index d544d81a0..cdfc9f15b 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/FileSystemInitializer/FileVersionInfoBuilderTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/FileSystemInitializer/FileVersionInfoBuilderTests.cs @@ -2,8 +2,8 @@ public class FileVersionInfoBuilderTests { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ShouldBePossibleToChainMethods( string comments, string companyName, @@ -68,8 +68,8 @@ public async Task ShouldBePossibleToChainMethods( await That(result.SpecialBuild).IsEqualTo(specialBuild); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WithComments_ShouldSetComments(string comments) { MockFileSystem fileSystem = new(); @@ -81,8 +81,8 @@ public async Task WithComments_ShouldSetComments(string comments) await That(result.Comments).IsEqualTo(comments); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WithCompanyName_ShouldSetCompanyName(string? companyName) { MockFileSystem fileSystem = new(); @@ -94,8 +94,8 @@ public async Task WithCompanyName_ShouldSetCompanyName(string? companyName) await That(result.CompanyName).IsEqualTo(companyName); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WithFileDescription_ShouldSetFileDescription(string? fileDescription) { MockFileSystem fileSystem = new(); @@ -107,12 +107,12 @@ public async Task WithFileDescription_ShouldSetFileDescription(string? fileDescr await That(result.FileDescription).IsEqualTo(fileDescription); } - [Theory] - [InlineData("1", 1, 0)] - [InlineData("0.1", 0, 1)] - [InlineData("1.2", 1, 2)] - [InlineData("1.2.3", 1, 2, 3)] - [InlineData("1.2.3.4", 1, 2, 3, 4)] + [Test] + [Arguments("1", 1, 0)] + [Arguments("0.1", 0, 1)] + [Arguments("1.2", 1, 2)] + [Arguments("1.2.3", 1, 2, 3)] + [Arguments("1.2.3.4", 1, 2, 3, 4)] public async Task WithFileVersion_ShouldSetFileVersion( string? fileVersion, int fileMajorPart, int fileMinorPart, int fileBuildPart = 0, int filePrivatePart = 0) @@ -130,22 +130,22 @@ public async Task WithFileVersion_ShouldSetFileVersion( await That(result.FilePrivatePart).IsEqualTo(filePrivatePart); } - [Theory] - [InlineData("1-foo", 1, 0)] - [InlineData("1+bar", 1, 0)] - [InlineData("1some-text", 1, 0)] - [InlineData("0.1-foo", 0, 1)] - [InlineData("0.1+bar", 0, 1)] - [InlineData("0.1some-text", 0, 1)] - [InlineData("1.2-foo", 1, 2)] - [InlineData("1.2+bar", 1, 2)] - [InlineData("1.2some-text", 1, 2)] - [InlineData("1.2.3-foo", 1, 2, 3)] - [InlineData("1.2.3+bar", 1, 2, 3)] - [InlineData("1.2.3some-text", 1, 2, 3)] - [InlineData("1.2.3.4-foo", 1, 2, 3, 4)] - [InlineData("1.2.3.4+bar", 1, 2, 3, 4)] - [InlineData("1.2.3.4some-text", 1, 2, 3, 4)] + [Test] + [Arguments("1-foo", 1, 0)] + [Arguments("1+bar", 1, 0)] + [Arguments("1some-text", 1, 0)] + [Arguments("0.1-foo", 0, 1)] + [Arguments("0.1+bar", 0, 1)] + [Arguments("0.1some-text", 0, 1)] + [Arguments("1.2-foo", 1, 2)] + [Arguments("1.2+bar", 1, 2)] + [Arguments("1.2some-text", 1, 2)] + [Arguments("1.2.3-foo", 1, 2, 3)] + [Arguments("1.2.3+bar", 1, 2, 3)] + [Arguments("1.2.3some-text", 1, 2, 3)] + [Arguments("1.2.3.4-foo", 1, 2, 3, 4)] + [Arguments("1.2.3.4+bar", 1, 2, 3, 4)] + [Arguments("1.2.3.4some-text", 1, 2, 3, 4)] public async Task WithFileVersion_WhenContainsPreReleaseInfo_ShouldIgnorePreReleaseInfo( string? fileVersion, int fileMajorPart, int fileMinorPart, int fileBuildPart = 0, int filePrivatePart = 0) @@ -162,11 +162,11 @@ public async Task WithFileVersion_WhenContainsPreReleaseInfo_ShouldIgnorePreRele await That(result.FilePrivatePart).IsEqualTo(filePrivatePart); } - [Theory] - [InlineData("")] - [InlineData("-1")] - [InlineData("+1.2.3-bar")] - [InlineData("abc")] + [Test] + [Arguments("")] + [Arguments("-1")] + [Arguments("+1.2.3-bar")] + [Arguments("abc")] public async Task WithFileVersion_WhenStringIsInvalid_ShouldNotSetFileVersionParts( string? fileVersion) { @@ -183,8 +183,8 @@ public async Task WithFileVersion_WhenStringIsInvalid_ShouldNotSetFileVersionPar await That(result.FilePrivatePart).IsEqualTo(0); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WithInternalName_ShouldSetInternalName(string? internalName) { MockFileSystem fileSystem = new(); @@ -196,8 +196,8 @@ public async Task WithInternalName_ShouldSetInternalName(string? internalName) await That(result.InternalName).IsEqualTo(internalName); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WithIsDebug_ShouldSetIsDebug(bool isDebug) { MockFileSystem fileSystem = new(); @@ -209,8 +209,8 @@ public async Task WithIsDebug_ShouldSetIsDebug(bool isDebug) await That(result.IsDebug).IsEqualTo(isDebug); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WithIsPatched_ShouldSetIsPatched(bool isPatched) { MockFileSystem fileSystem = new(); @@ -222,8 +222,8 @@ public async Task WithIsPatched_ShouldSetIsPatched(bool isPatched) await That(result.IsPatched).IsEqualTo(isPatched); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WithIsPreRelease_ShouldSetIsPreRelease(bool isPreRelease) { MockFileSystem fileSystem = new(); @@ -235,8 +235,8 @@ public async Task WithIsPreRelease_ShouldSetIsPreRelease(bool isPreRelease) await That(result.IsPreRelease).IsEqualTo(isPreRelease); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WithIsPrivateBuild_ShouldSetIsPrivateBuild(bool isPrivateBuild) { MockFileSystem fileSystem = new(); @@ -248,8 +248,8 @@ public async Task WithIsPrivateBuild_ShouldSetIsPrivateBuild(bool isPrivateBuild await That(result.IsPrivateBuild).IsEqualTo(isPrivateBuild); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WithIsSpecialBuild_ShouldSetIsSpecialBuild(bool isSpecialBuild) { MockFileSystem fileSystem = new(); @@ -261,8 +261,8 @@ public async Task WithIsSpecialBuild_ShouldSetIsSpecialBuild(bool isSpecialBuild await That(result.IsSpecialBuild).IsEqualTo(isSpecialBuild); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WithLanguage_ShouldSetLanguage(string? language) { MockFileSystem fileSystem = new(); @@ -274,8 +274,8 @@ public async Task WithLanguage_ShouldSetLanguage(string? language) await That(result.Language).IsEqualTo(language); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WithLegalCopyright_ShouldSetLegalCopyright(string? legalCopyright) { MockFileSystem fileSystem = new(); @@ -287,8 +287,8 @@ public async Task WithLegalCopyright_ShouldSetLegalCopyright(string? legalCopyri await That(result.LegalCopyright).IsEqualTo(legalCopyright); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WithLegalTrademarks_ShouldSetLegalTrademarks(string? legalTrademarks) { MockFileSystem fileSystem = new(); @@ -300,8 +300,8 @@ public async Task WithLegalTrademarks_ShouldSetLegalTrademarks(string? legalTrad await That(result.LegalTrademarks).IsEqualTo(legalTrademarks); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WithOriginalFilename_ShouldSetOriginalFilename(string? originalFilename) { MockFileSystem fileSystem = new(); @@ -313,8 +313,8 @@ public async Task WithOriginalFilename_ShouldSetOriginalFilename(string? origina await That(result.OriginalFilename).IsEqualTo(originalFilename); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WithPrivateBuild_ShouldSetPrivateBuild(string? privateBuild) { MockFileSystem fileSystem = new(); @@ -326,8 +326,8 @@ public async Task WithPrivateBuild_ShouldSetPrivateBuild(string? privateBuild) await That(result.PrivateBuild).IsEqualTo(privateBuild); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WithProductName_ShouldSetProductName(string? productName) { MockFileSystem fileSystem = new(); @@ -339,12 +339,12 @@ public async Task WithProductName_ShouldSetProductName(string? productName) await That(result.ProductName).IsEqualTo(productName); } - [Theory] - [InlineData("1", 1, 0)] - [InlineData("0.1", 0, 1)] - [InlineData("1.2", 1, 2)] - [InlineData("1.2.3", 1, 2, 3)] - [InlineData("1.2.3.4", 1, 2, 3, 4)] + [Test] + [Arguments("1", 1, 0)] + [Arguments("0.1", 0, 1)] + [Arguments("1.2", 1, 2)] + [Arguments("1.2.3", 1, 2, 3)] + [Arguments("1.2.3.4", 1, 2, 3, 4)] public async Task WithProductVersion_ShouldSetProductVersion( string? productVersion, int fileMajorPart, int fileMinorPart, int fileBuildPart = 0, int filePrivatePart = 0) @@ -362,22 +362,22 @@ public async Task WithProductVersion_ShouldSetProductVersion( await That(result.ProductPrivatePart).IsEqualTo(filePrivatePart); } - [Theory] - [InlineData("1-foo", 1, 0)] - [InlineData("1+bar", 1, 0)] - [InlineData("1some-text", 1, 0)] - [InlineData("0.1-foo", 0, 1)] - [InlineData("0.1+bar", 0, 1)] - [InlineData("0.1some-text", 0, 1)] - [InlineData("1.2-foo", 1, 2)] - [InlineData("1.2+bar", 1, 2)] - [InlineData("1.2some-text", 1, 2)] - [InlineData("1.2.3-foo", 1, 2, 3)] - [InlineData("1.2.3+bar", 1, 2, 3)] - [InlineData("1.2.3some-text", 1, 2, 3)] - [InlineData("1.2.3.4-foo", 1, 2, 3, 4)] - [InlineData("1.2.3.4+bar", 1, 2, 3, 4)] - [InlineData("1.2.3.4some-text", 1, 2, 3, 4)] + [Test] + [Arguments("1-foo", 1, 0)] + [Arguments("1+bar", 1, 0)] + [Arguments("1some-text", 1, 0)] + [Arguments("0.1-foo", 0, 1)] + [Arguments("0.1+bar", 0, 1)] + [Arguments("0.1some-text", 0, 1)] + [Arguments("1.2-foo", 1, 2)] + [Arguments("1.2+bar", 1, 2)] + [Arguments("1.2some-text", 1, 2)] + [Arguments("1.2.3-foo", 1, 2, 3)] + [Arguments("1.2.3+bar", 1, 2, 3)] + [Arguments("1.2.3some-text", 1, 2, 3)] + [Arguments("1.2.3.4-foo", 1, 2, 3, 4)] + [Arguments("1.2.3.4+bar", 1, 2, 3, 4)] + [Arguments("1.2.3.4some-text", 1, 2, 3, 4)] public async Task WithProductVersion_WhenContainsPreReleaseInfo_ShouldIgnorePreReleaseInfo( string? productVersion, int fileMajorPart, int fileMinorPart, int fileBuildPart = 0, int filePrivatePart = 0) @@ -394,11 +394,11 @@ public async Task WithProductVersion_WhenContainsPreReleaseInfo_ShouldIgnorePreR await That(result.ProductPrivatePart).IsEqualTo(filePrivatePart); } - [Theory] - [InlineData("")] - [InlineData("-1")] - [InlineData("+1.2.3-bar")] - [InlineData("abc")] + [Test] + [Arguments("")] + [Arguments("-1")] + [Arguments("+1.2.3-bar")] + [Arguments("abc")] public async Task WithProductVersion_WhenStringIsInvalid_ShouldNotSetProductVersionParts( string? productVersion) { @@ -415,8 +415,8 @@ public async Task WithProductVersion_WhenStringIsInvalid_ShouldNotSetProductVers await That(result.ProductPrivatePart).IsEqualTo(0); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WithSpecialBuild_ShouldSetSpecialBuild(string? specialBuild) { MockFileSystem fileSystem = new(); diff --git a/Tests/Testably.Abstractions.Testing.Tests/FileSystemInitializer/TestingExceptionTests.cs b/Tests/Testably.Abstractions.Testing.Tests/FileSystemInitializer/TestingExceptionTests.cs index 5653fd42f..e9f1db98f 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/FileSystemInitializer/TestingExceptionTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/FileSystemInitializer/TestingExceptionTests.cs @@ -7,8 +7,8 @@ namespace Testably.Abstractions.Testing.Tests.FileSystemInitializer; public class TestingExceptionTests { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task TestingException_SerializationAndDeserialization_ShouldKeepMessageAndInnerException( string message, Exception innerException) diff --git a/Tests/Testably.Abstractions.Testing.Tests/FileSystemInitializerExtensionsTests.cs b/Tests/Testably.Abstractions.Testing.Tests/FileSystemInitializerExtensionsTests.cs index 24a72f988..58008d2e8 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/FileSystemInitializerExtensionsTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/FileSystemInitializerExtensionsTests.cs @@ -2,16 +2,15 @@ using System.Collections.Generic; using System.IO; using System.Linq; -using System.Reflection; -using Testably.Abstractions.TestHelpers.Settings; using Testably.Abstractions.Testing.Initializer; +using Assembly = System.Reflection.Assembly; namespace Testably.Abstractions.Testing.Tests; -[Collection("RealFileSystemTests")] -public class FileSystemInitializerExtensionsTests(TestSettingsFixture fixture) +[NotInParallel(nameof(RealFileSystem))] +public class FileSystemInitializerExtensionsTests { - [Fact] + [Test] public async Task Initialize_WithAFile_ShouldCreateFile() { MockFileSystem sut = new(); @@ -21,8 +20,8 @@ public async Task Initialize_WithAFile_ShouldCreateFile() await That(sut.Directory.EnumerateFiles(".")).HasSingle(); } - [Theory] - [AutoData] + [Test] + [Arguments("txt")] public async Task Initialize_WithAFile_WithExtension_ShouldCreateFileWithExtension( string extension) { @@ -33,7 +32,7 @@ public async Task Initialize_WithAFile_WithExtension_ShouldCreateFileWithExtensi await That(sut.Directory.EnumerateFiles(".", $"*.{extension}")).HasSingle(); } - [Fact] + [Test] public async Task Initialize_WithASubdirectory_ShouldCreateDirectory() { MockFileSystem sut = new(); @@ -43,8 +42,8 @@ public async Task Initialize_WithASubdirectory_ShouldCreateDirectory() await That(sut.Directory.EnumerateDirectories(".")).HasSingle(); } - [Theory] - [AutoData] + [Test] + [Arguments("foo.txt")] public async Task Initialize_WithFile_Existing_ShouldThrowTestingException(string fileName) { MockFileSystem sut = new(); @@ -55,11 +54,11 @@ void Act() sut.Initialize().WithFile(fileName); } - await That(Act).ThrowsExactly().WithMessage("*fileName*").AsWildcard(); + await That(Act).ThrowsExactly().WithMessage($"*{fileName}*").AsWildcard(); } - [Theory] - [AutoData] + [Test] + [Arguments("foo.txt", new byte[]{ 0x1, 0x2, 0x3, })] public async Task Initialize_WithFile_HasBytesContent_ShouldCreateFileWithGivenFileContent( string fileName, byte[] fileContent) { @@ -74,8 +73,8 @@ public async Task Initialize_WithFile_HasBytesContent_ShouldCreateFileWithGivenF await That(result).IsEqualTo(fileContent).InAnyOrder(); } - [Theory] - [AutoData] + [Test] + [Arguments("foo.txt", "file-content")] public async Task Initialize_WithFile_HasStringContent_ShouldCreateFileWithGivenFileContent( string fileName, string fileContent) { @@ -90,8 +89,8 @@ public async Task Initialize_WithFile_HasStringContent_ShouldCreateFileWithGiven await That(result).IsEqualTo(fileContent); } - [Theory] - [AutoData] + [Test] + [Arguments("foo.txt")] public async Task Initialize_WithFile_ShouldCreateFileWithGivenFileName(string fileName) { MockFileSystem sut = new(); @@ -101,7 +100,7 @@ public async Task Initialize_WithFile_ShouldCreateFileWithGivenFileName(string f await That(sut.Directory.EnumerateFiles(".", fileName)).HasSingle(); } - [Fact] + [Test] public async Task Initialize_WithNestedSubdirectories_ShouldCreateAllNestedDirectories() { MockFileSystem sut = new(); @@ -120,9 +119,9 @@ public async Task Initialize_WithNestedSubdirectories_ShouldCreateAllNestedDirec await That(result).Contains(sut.Path.Combine(".", "foo", "bar", "xyz")); } - [Theory] - [InlineData(false)] - [InlineData(true)] + [Test] + [Arguments(false)] + [Arguments(true)] public async Task Initialize_WithOptions_ShouldConsiderValueOfInitializeTempDirectory( bool initializeTempDirectory) { @@ -134,8 +133,8 @@ public async Task Initialize_WithOptions_ShouldConsiderValueOfInitializeTempDire await That(sut.Directory.Exists(sut.Path.GetTempPath())).IsEqualTo(initializeTempDirectory); } - [Theory] - [AutoData] + [Test] + [Arguments("my-directory")] public async Task Initialize_WithSubdirectory_Existing_ShouldThrowTestingException( string directoryName) { @@ -149,8 +148,8 @@ await That(Act).ThrowsExactly().WithMessage($"*{directoryName} .AsWildcard(); } - [Theory] - [AutoData] + [Test] + [Arguments("my-directory")] public async Task Initialize_WithSubdirectory_ShouldCreateDirectoryWithGivenDirectoryName( string directoryName) { @@ -161,8 +160,8 @@ public async Task Initialize_WithSubdirectory_ShouldCreateDirectoryWithGivenDire await That(sut.Directory.EnumerateDirectories(".", directoryName)).HasSingle(); } - [Theory] - [AutoData] + [Test] + [Arguments("my-directory")] public async Task Initialize_WithSubdirectory_ShouldExist(string directoryName) { MockFileSystem sut = new(); @@ -174,8 +173,8 @@ public async Task Initialize_WithSubdirectory_ShouldExist(string directoryName) await That(result.Directory.Exists).IsTrue(); } - [Theory] - [AutoData] + [Test] + [Arguments("my-path")] public async Task InitializeEmbeddedResourcesFromAssembly_ShouldCopyAllMatchingResourceFilesInDirectory( string path) @@ -200,8 +199,8 @@ await That(result2) .Contains(x => x.EndsWith("SubResourceFile1.txt", StringComparison.Ordinal)); } - [Theory] - [AutoData] + [Test] + [Arguments("my-path")] public async Task InitializeEmbeddedResourcesFromAssembly_WithoutRecurseSubdirectories_ShouldOnlyCopyTopmostFilesInRelativePath( string path) @@ -224,8 +223,8 @@ public async Task await That(fileSystem.Directory.Exists(Path.Combine(path, "SubResource"))).IsFalse(); } - [Theory] - [AutoData] + [Test] + [Arguments("my-path")] public async Task InitializeEmbeddedResourcesFromAssembly_WithRelativePath_ShouldCopyAllResourceInMatchingPathInDirectory( string path) @@ -246,8 +245,8 @@ await That(result) .Contains(x => x.EndsWith("SubResourceFile1.txt", StringComparison.Ordinal)); } - [Theory] - [AutoData] + [Test] + [Arguments("my-directory")] public async Task InitializeFromRealDirectory_MissingDrive_ShouldCreateDrive( string directoryName) { @@ -282,7 +281,7 @@ public async Task InitializeFromRealDirectory_MissingDrive_ShouldCreateDrive( } } - [Fact] + [Test] public async Task InitializeFromRealDirectory_ShouldCopyFileToTargetDirectory() { SkipIfRealFileSystemShouldBeSkipped(); @@ -306,7 +305,7 @@ public async Task InitializeFromRealDirectory_ShouldCopyFileToTargetDirectory() } } - [Fact] + [Test] public async Task InitializeFromRealDirectory_ShouldRecursivelyCopyDirectoriesToTargetDirectory() { @@ -335,7 +334,7 @@ await That(fileSystem).HasFile(fileSystem.Path.Combine(tempPath, "subdir", "test } } - [Fact] + [Test] public async Task InitializeFromRealDirectory_WhenDirectoryDoesNotExist_ShouldThrowDirectoryNotFoundException() { @@ -353,8 +352,8 @@ await That(Act).Throws() .WithMessage($"The directory '{tempPath}' does not exist."); } - [Theory] - [AutoData] + [Test] + [Arguments("my-directory")] public async Task InitializeIn_MissingDrive_ShouldCreateDrive(string directoryName) { Skip.IfNot(Test.RunsOnWindows); @@ -378,8 +377,8 @@ public async Task InitializeIn_MissingDrive_ShouldCreateDrive(string directoryNa await That(sut.DriveInfo.GetDrives()).HasCount(drives.Length + 1); } - [Theory] - [AutoData] + [Test] + [Arguments("my-path")] public async Task InitializeIn_ShouldSetCurrentDirectory(string path) { MockFileSystem sut = new(); @@ -393,19 +392,14 @@ public async Task InitializeIn_ShouldSetCurrentDirectory(string path) #region Helpers - private void SkipIfRealFileSystemShouldBeSkipped() + private static void SkipIfRealFileSystemShouldBeSkipped() { #if DEBUG - if (fixture.RealFileSystemTests != TestSettingStatus.AlwaysEnabled) - { - aweXpect.Skip.Test( - $"Tests against the real file system are {fixture.RealFileSystemTests}. You can enable them by executing the corresponding tests in Testably.Abstractions.TestSettings.RealFileSystemTests."); - } + Skip.If(Settings.RealFileSystemTests == Settings.TestSettingStatus.AlwaysDisabled, + $"Tests against the real file system are {Settings.RealFileSystemTests}. You can enable them by executing the corresponding tests in Testably.Abstractions.TestSettings.RealFileSystemTests."); #else - if (fixture.RealFileSystemTests == TestSettingStatus.AlwaysDisabled) - { - aweXpect.Skip.Test($"Tests against the real file system are {fixture.RealFileSystemTests}. You can enable them by executing the corresponding tests in Testably.Abstractions.TestSettings.RealFileSystemTests."); - } + Skip.If(Settings.RealFileSystemTests != Settings.TestSettingStatus.AlwaysEnabled, + $"Tests against the real file system are {Settings.RealFileSystemTests}. You can enable them by executing the corresponding tests in Testably.Abstractions.TestSettings.RealFileSystemTests."); #endif } diff --git a/Tests/Testably.Abstractions.Testing.Tests/FileSystemInitializerOptionsTests.cs b/Tests/Testably.Abstractions.Testing.Tests/FileSystemInitializerOptionsTests.cs index f1a5a0507..24c70bea0 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/FileSystemInitializerOptionsTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/FileSystemInitializerOptionsTests.cs @@ -2,7 +2,7 @@ public sealed class FileSystemInitializerOptionsTests { - [Fact] + [Test] public async Task InitializeTempDirectory_ShouldBeInitializedToTrue() { FileSystemInitializerOptions sut = new(); diff --git a/Tests/Testably.Abstractions.Testing.Tests/Helpers/AssemblyNameExtensionsTests.cs b/Tests/Testably.Abstractions.Testing.Tests/Helpers/AssemblyNameExtensionsTests.cs index c467fec4c..2df504a30 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/Helpers/AssemblyNameExtensionsTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/Helpers/AssemblyNameExtensionsTests.cs @@ -1,11 +1,12 @@ using System.Reflection; using Testably.Abstractions.Testing.Helpers; +using Assembly = System.Reflection.Assembly; namespace Testably.Abstractions.Testing.Tests.Helpers; public class AssemblyNameExtensionsTests { - [Fact] + [Test] public async Task GetNameOrDefault_ExecutingAssembly_ShouldReturnCorrectString() { AssemblyName assemblyName = Assembly.GetExecutingAssembly().GetName(); @@ -15,7 +16,7 @@ public async Task GetNameOrDefault_ExecutingAssembly_ShouldReturnCorrectString() await That(result).IsEqualTo("Testably.Abstractions.Testing.Tests"); } - [Fact] + [Test] public async Task GetNameOrDefault_NullName_ShouldReturnEmptyString() { AssemblyName assemblyName = Assembly.GetExecutingAssembly().GetName(); diff --git a/Tests/Testably.Abstractions.Testing.Tests/Helpers/CallerArgumentExpressionAttribute.cs b/Tests/Testably.Abstractions.Testing.Tests/Helpers/CallerArgumentExpressionAttribute.cs deleted file mode 100644 index 3dfe0cf41..000000000 --- a/Tests/Testably.Abstractions.Testing.Tests/Helpers/CallerArgumentExpressionAttribute.cs +++ /dev/null @@ -1,33 +0,0 @@ -#if !NET6_0_OR_GREATER -using System.Diagnostics.CodeAnalysis; - -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -// ReSharper disable once CheckNamespace -namespace System.Runtime.CompilerServices -{ - /// - /// Indicates that a parameter captures the expression passed for another parameter as a string. - /// - [AttributeUsage(AttributeTargets.Parameter)] - [ExcludeFromCodeCoverage] - internal sealed class CallerArgumentExpressionAttribute : Attribute - { - /// - /// Gets the name of the parameter whose expression should be captured as a string. - /// - public string ParameterName { get; } - - /// - /// Initializes a new instance of the class. - /// - /// The name of the parameter whose expression should be captured as a string. - public CallerArgumentExpressionAttribute(string parameterName) - { - ParameterName = parameterName; - } - } -} - -#endif diff --git a/Tests/Testably.Abstractions.Testing.Tests/Helpers/CharExtensionMethodsTests.cs b/Tests/Testably.Abstractions.Testing.Tests/Helpers/CharExtensionMethodsTests.cs index 783faf926..21ae7828e 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/Helpers/CharExtensionMethodsTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/Helpers/CharExtensionMethodsTests.cs @@ -4,13 +4,13 @@ namespace Testably.Abstractions.Testing.Tests.Helpers; public sealed class CharExtensionMethodsTests { - [Theory] - [InlineData('A')] - [InlineData('Z')] - [InlineData('a')] - [InlineData('z')] - [InlineData('M')] - [InlineData('d')] + [Test] + [Arguments('A')] + [Arguments('Z')] + [Arguments('a')] + [Arguments('z')] + [Arguments('M')] + [Arguments('d')] public async Task IsAsciiLetter_WithAsciiLetterChar_ShouldReturnTrue(char c) { bool result = c.IsAsciiLetter(); @@ -18,14 +18,14 @@ public async Task IsAsciiLetter_WithAsciiLetterChar_ShouldReturnTrue(char c) await That(result).IsTrue(); } - [Theory] - [InlineData((char)64)] - [InlineData((char)91)] - [InlineData((char)96)] - [InlineData((char)123)] - [InlineData((char)55)] - [InlineData((char)0)] - [InlineData((char)127)] + [Test] + [Arguments((char)64)] + [Arguments((char)91)] + [Arguments((char)96)] + [Arguments((char)123)] + [Arguments((char)55)] + [Arguments((char)0)] + [Arguments((char)127)] public async Task IsAsciiLetter_WithNonAsciiLetterChar_ShouldReturnFalse(char c) { bool result = c.IsAsciiLetter(); diff --git a/Tests/Testably.Abstractions.Testing.Tests/Helpers/EncryptionHelperTests.cs b/Tests/Testably.Abstractions.Testing.Tests/Helpers/EncryptionHelperTests.cs index aba83381d..c0fc9b046 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/Helpers/EncryptionHelperTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/Helpers/EncryptionHelperTests.cs @@ -4,8 +4,8 @@ namespace Testably.Abstractions.Testing.Tests.Helpers; public class EncryptionHelperTests { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Decrypt_ShouldBeDifferentThanBefore(byte[] bytes) { byte[] encryptedBytes = EncryptionHelper.Encrypt(bytes); @@ -15,8 +15,8 @@ public async Task Decrypt_ShouldBeDifferentThanBefore(byte[] bytes) await That(result).IsNotEqualTo(encryptedBytes).InAnyOrder(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Encrypt_ShouldBeDifferentThanBefore(byte[] bytes) { byte[] result = EncryptionHelper.Encrypt(bytes); @@ -24,8 +24,8 @@ public async Task Encrypt_ShouldBeDifferentThanBefore(byte[] bytes) await That(result).IsNotEqualTo(bytes).InAnyOrder(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Encrypt_ThenDecrypt_ShouldBeEquivalentToBefore(byte[] bytes) { byte[] encrypted = EncryptionHelper.Encrypt(bytes); diff --git a/Tests/Testably.Abstractions.Testing.Tests/Helpers/EnumerationOptionsHelperTests.cs b/Tests/Testably.Abstractions.Testing.Tests/Helpers/EnumerationOptionsHelperTests.cs index 0d98ae39b..fb9ab3be5 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/Helpers/EnumerationOptionsHelperTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/Helpers/EnumerationOptionsHelperTests.cs @@ -5,7 +5,7 @@ namespace Testably.Abstractions.Testing.Tests.Helpers; public class EnumerationOptionsHelperTests { - [Fact] + [Test] public async Task FromSearchOption_InvalidValue_ShouldThrowArgumentOutOfRangeException() { SearchOption invalidSearchOption = (SearchOption)(-1); @@ -19,7 +19,7 @@ void Act() } #if NET6_0_OR_GREATER - [Fact] + [Test] public async Task MatchesPattern_InvalidMatchType_ShouldThrowArgumentOutOfRangeException() { EnumerationOptions invalidEnumerationOptions = new() diff --git a/Tests/Testably.Abstractions.Testing.Tests/Helpers/ExceptionFactoryTests.cs b/Tests/Testably.Abstractions.Testing.Tests/Helpers/ExceptionFactoryTests.cs index 00077b875..2db391046 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/Helpers/ExceptionFactoryTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/Helpers/ExceptionFactoryTests.cs @@ -4,7 +4,7 @@ namespace Testably.Abstractions.Testing.Tests.Helpers; public sealed class ExceptionFactoryTests { - [Fact] + [Test] public async Task NotSupportedSafeFileHandle_ShouldMentionWithSafeFileHandleStrategy() { NotSupportedException sut = ExceptionFactory.NotSupportedSafeFileHandle(); @@ -12,7 +12,7 @@ public async Task NotSupportedSafeFileHandle_ShouldMentionWithSafeFileHandleStra await That(sut.Message).Contains(nameof(MockFileSystem.WithSafeFileHandleStrategy)); } - [Fact] + [Test] public async Task OperationNotSupportedOnThisPlatform_ShouldMentionPlatform() { PlatformNotSupportedException sut = ExceptionFactory.OperationNotSupportedOnThisPlatform(); @@ -20,9 +20,9 @@ public async Task OperationNotSupportedOnThisPlatform_ShouldMentionPlatform() await That(sut.Message).Contains("platform"); } - [Theory] - [InlineAutoData(SimulationMode.Windows, false)] - [InlineAutoData(SimulationMode.Windows, true)] + [Test] + [AutoArguments(SimulationMode.Windows, false)] + [AutoArguments(SimulationMode.Windows, true)] public async Task PathCannotBeEmpty_ShouldSetParamNameExceptOnNetFramework( SimulationMode type, bool isNetFramework, string paramName) { @@ -43,7 +43,7 @@ public async Task PathCannotBeEmpty_ShouldSetParamNameExceptOnNetFramework( } } - [Fact] + [Test] public async Task SearchPatternCannotContainTwoDots_ShouldMentionTwoDots() { ArgumentException sut = ExceptionFactory.SearchPatternCannotContainTwoDots(); diff --git a/Tests/Testably.Abstractions.Testing.Tests/Helpers/ExecuteTests.SimulatedPathTests.cs b/Tests/Testably.Abstractions.Testing.Tests/Helpers/ExecuteTests.SimulatedPathTests.cs index bcdcef072..a7e34f498 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/Helpers/ExecuteTests.SimulatedPathTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/Helpers/ExecuteTests.SimulatedPathTests.cs @@ -5,10 +5,10 @@ public sealed partial class ExecuteTests #if CAN_SIMULATE_OTHER_OS public sealed class SimulatedPathTests { - [Theory] - [InlineData(SimulationMode.Linux)] - [InlineData(SimulationMode.MacOS)] - [InlineData(SimulationMode.Windows)] + [Test] + [Arguments(SimulationMode.Linux)] + [Arguments(SimulationMode.MacOS)] + [Arguments(SimulationMode.Windows)] public async Task FileSystem_ShouldBeMockFileSystem(SimulationMode simulationMode) { MockFileSystem sut = new(o => o.SimulatingOperatingSystem(simulationMode)); diff --git a/Tests/Testably.Abstractions.Testing.Tests/Helpers/ExecuteTests.cs b/Tests/Testably.Abstractions.Testing.Tests/Helpers/ExecuteTests.cs index f8863787a..332f65771 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/Helpers/ExecuteTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/Helpers/ExecuteTests.cs @@ -4,7 +4,7 @@ namespace Testably.Abstractions.Testing.Tests.Helpers; public sealed partial class ExecuteTests { - [Fact] + [Test] public async Task Constructor_ForLinux_ShouldInitializeAccordingly() { #pragma warning disable CS0618 @@ -18,7 +18,7 @@ public async Task Constructor_ForLinux_ShouldInitializeAccordingly() await That(sut.StringComparisonMode).IsEqualTo(StringComparison.Ordinal); } - [Fact] + [Test] public async Task Constructor_ForMacOS_ShouldInitializeAccordingly() { #pragma warning disable CS0618 @@ -32,7 +32,7 @@ public async Task Constructor_ForMacOS_ShouldInitializeAccordingly() await That(sut.StringComparisonMode).IsEqualTo(StringComparison.OrdinalIgnoreCase); } - [Fact] + [Test] public async Task Constructor_ForWindows_ShouldInitializeAccordingly() { #pragma warning disable CS0618 @@ -46,7 +46,7 @@ public async Task Constructor_ForWindows_ShouldInitializeAccordingly() await That(sut.StringComparisonMode).IsEqualTo(StringComparison.OrdinalIgnoreCase); } - [Fact] + [Test] public async Task Constructor_UnsupportedSimulationMode_ShouldThrowNotSupportedException() { void Act() diff --git a/Tests/Testably.Abstractions.Testing.Tests/Helpers/FilePlatformIndependenceExtensionsTests.cs b/Tests/Testably.Abstractions.Testing.Tests/Helpers/FilePlatformIndependenceExtensionsTests.cs index d2e1ab64d..61d6a97c1 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/Helpers/FilePlatformIndependenceExtensionsTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/Helpers/FilePlatformIndependenceExtensionsTests.cs @@ -5,7 +5,7 @@ namespace Testably.Abstractions.Testing.Tests.Helpers; public class FilePlatformIndependenceExtensionsTests { - [Fact] + [Test] public async Task NormalizePath_Null_ShouldReturnNull() { string? path = null; @@ -15,8 +15,8 @@ public async Task NormalizePath_Null_ShouldReturnNull() await That(path).IsNull(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task NormalizePath_Unix_RootedPath_ShouldRemoveDriveInfo(string part1) { Skip.If(Test.RunsOnWindows); @@ -30,8 +30,8 @@ public async Task NormalizePath_Unix_RootedPath_ShouldRemoveDriveInfo(string par await That(path).IsEqualTo(expectedPath); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task NormalizePath_Unix_ShouldReplaceAltDirectorySeparatorChar( string part1, string part2) { @@ -52,8 +52,8 @@ public async Task NormalizePath_Unix_ShouldReplaceAltDirectorySeparatorChar( } } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task NormalizePath_Windows_ShouldAlsoKeepAltDirectorySeparatorChar( string part1, string part2) { @@ -73,7 +73,7 @@ public async Task NormalizePath_Windows_ShouldAlsoKeepAltDirectorySeparatorChar( } } - [Fact] + [Test] public async Task PrefixRoot_Null_ShouldReturnNull() { string? path = null; @@ -83,8 +83,8 @@ public async Task PrefixRoot_Null_ShouldReturnNull() await That(result).IsNull(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task PrefixRoot_RootedPath_ShouldReturnPath(string path) { path = path.PrefixRoot(new MockFileSystem()); @@ -94,8 +94,8 @@ public async Task PrefixRoot_RootedPath_ShouldReturnPath(string path) await That(result).IsEqualTo(path); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task PrefixRoot_UnRootedPath_ShouldPrefixRoot(string path) { string result = path.PrefixRoot(new MockFileSystem()); diff --git a/Tests/Testably.Abstractions.Testing.Tests/Helpers/FileSystemExtensibilityTests.cs b/Tests/Testably.Abstractions.Testing.Tests/Helpers/FileSystemExtensibilityTests.cs index b3400140f..156a067ef 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/Helpers/FileSystemExtensibilityTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/Helpers/FileSystemExtensibilityTests.cs @@ -4,7 +4,7 @@ namespace Testably.Abstractions.Testing.Tests.Helpers; public sealed class FileSystemExtensibilityTests { - [Fact] + [Test] public async Task ToString_Empty_ShouldBeEmptyArray() { FileSystemExtensibility extensibility = new(); @@ -14,7 +14,7 @@ public async Task ToString_Empty_ShouldBeEmptyArray() await That(result).IsEqualTo("[]"); } - [Fact] + [Test] public async Task ToString_WithMetadata_Should() { FileSystemExtensibility extensibility = new(); diff --git a/Tests/Testably.Abstractions.Testing.Tests/Helpers/FileSystemExtensionsTests.cs b/Tests/Testably.Abstractions.Testing.Tests/Helpers/FileSystemExtensionsTests.cs index ead742321..aae336fa1 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/Helpers/FileSystemExtensionsTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/Helpers/FileSystemExtensionsTests.cs @@ -5,8 +5,8 @@ namespace Testably.Abstractions.Testing.Tests.Helpers; public class FileSystemExtensionsTests { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetMoveLocation_LocationNotUnderSource_ShouldThrowNotSupportedException( string location, string source, string destination) { @@ -26,7 +26,7 @@ await That(Act).ThrowsExactly() .Contains($"'{sut.Path.GetFullPath(source)}'")); } - [Fact] + [Test] public async Task RandomOrDefault_WithMockFileSystem_ShouldUseRandomFromRandomSystem() { MockFileSystem fileSystem = new(); @@ -37,7 +37,7 @@ public async Task RandomOrDefault_WithMockFileSystem_ShouldUseRandomFromRandomSy await That(result).IsEqualTo(fileSystem.RandomSystem.Random.Shared); } - [Fact] + [Test] public async Task RandomOrDefault_WithRealFileSystem_ShouldUseSharedRandom() { RealFileSystem fileSystem = new(); diff --git a/Tests/Testably.Abstractions.Testing.Tests/Helpers/PathHelperTests.cs b/Tests/Testably.Abstractions.Testing.Tests/Helpers/PathHelperTests.cs index 43c3d9391..c4c1054d9 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/Helpers/PathHelperTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/Helpers/PathHelperTests.cs @@ -5,7 +5,7 @@ namespace Testably.Abstractions.Testing.Tests.Helpers; public class PathHelperTests { - [Fact] + [Test] public async Task EnsureValidFormat_WithWhiteSpaceAndIncludeIsEmptyCheck_ShouldThrowArgumentException() { @@ -20,8 +20,8 @@ void Act() await That(Act).ThrowsExactly().WithHResult(-2147024809); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetFullPathOrWhiteSpace_NormalPath_ShouldReturnFullPath(string path) { MockFileSystem fileSystem = new(); @@ -33,7 +33,7 @@ public async Task GetFullPathOrWhiteSpace_NormalPath_ShouldReturnFullPath(string await That(result).IsEqualTo(expectedPath); } - [Fact] + [Test] public async Task GetFullPathOrWhiteSpace_Null_ShouldReturnEmptyString() { MockFileSystem fileSystem = new(); @@ -44,9 +44,9 @@ public async Task GetFullPathOrWhiteSpace_Null_ShouldReturnEmptyString() await That(result).IsEqualTo(""); } - [Theory] - [InlineData(" ")] - [InlineData("\t")] + [Test] + [Arguments(" ")] + [Arguments("\t")] public async Task GetFullPathOrWhiteSpace_WhiteSpace_ShouldReturnPath(string path) { MockFileSystem fileSystem = new(); @@ -56,8 +56,8 @@ public async Task GetFullPathOrWhiteSpace_WhiteSpace_ShouldReturnPath(string pat await That(result).IsEqualTo(path); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task IsUncPath_AltDirectorySeparatorChar_ShouldReturnTrue(string path) { string prefix = new(Path.AltDirectorySeparatorChar, 2); @@ -68,8 +68,8 @@ public async Task IsUncPath_AltDirectorySeparatorChar_ShouldReturnTrue(string pa await That(result).IsTrue(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task IsUncPath_DirectorySeparatorChar_ShouldReturnTrue(string path) { string prefix = new(Path.DirectorySeparatorChar, 2); @@ -80,8 +80,8 @@ public async Task IsUncPath_DirectorySeparatorChar_ShouldReturnTrue(string path) await That(result).IsTrue(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task IsUncPath_MixedDirectorySeparatorChars_ShouldReturnFalse(string path) { Skip.IfNot(Test.RunsOnWindows, @@ -94,7 +94,7 @@ public async Task IsUncPath_MixedDirectorySeparatorChars_ShouldReturnFalse(strin await That(result).IsFalse(); } - [Fact] + [Test] public async Task IsUncPath_Null_ShouldReturnFalse() { string? path = null; @@ -104,7 +104,7 @@ public async Task IsUncPath_Null_ShouldReturnFalse() await That(result).IsFalse(); } - [Fact] + [Test] public async Task ThrowCommonExceptionsIfPathIsInvalid_StartWithNull_ShouldThrowArgumentException() { @@ -119,10 +119,10 @@ void Act() } #if CAN_SIMULATE_OTHER_OS - [Theory] - [InlineData('|')] - [InlineData((char)1)] - [InlineData((char)31)] + [Test] + [Arguments('|')] + [Arguments((char)1)] + [Arguments((char)31)] public async Task ThrowCommonExceptionsIfPathIsInvalid_WithInvalidCharacters( char invalidChar) { @@ -139,7 +139,7 @@ void Act() } #endif - [Fact] + [Test] public async Task ThrowCommonExceptionsIfPathToTargetIsInvalid_NullCharacter_ShouldThrowArgumentException() { diff --git a/Tests/Testably.Abstractions.Testing.Tests/Helpers/RandomSystemExtensionsTests.cs b/Tests/Testably.Abstractions.Testing.Tests/Helpers/RandomSystemExtensionsTests.cs index 1eecebfcf..88540b583 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/Helpers/RandomSystemExtensionsTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/Helpers/RandomSystemExtensionsTests.cs @@ -6,7 +6,7 @@ namespace Testably.Abstractions.Testing.Tests.Helpers; public class RandomSystemExtensionsTests { - [Fact] + [Test] public async Task GenerateRandomFileExtension_ShouldNotStartWithDotOrReturnEmptyString() { MockRandomSystem randomSystem = new( @@ -34,7 +34,7 @@ public async Task GenerateRandomFileExtension_ShouldNotStartWithDotOrReturnEmpty } } - [Fact] + [Test] public async Task GenerateRandomFileName_ShouldGenerateEdgeCases() { MockRandomSystem randomSystem = new( diff --git a/Tests/Testably.Abstractions.Testing.Tests/InterceptionHandlerExtensionsTests.cs b/Tests/Testably.Abstractions.Testing.Tests/InterceptionHandlerExtensionsTests.cs index 186909545..2bcba2075 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/InterceptionHandlerExtensionsTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/InterceptionHandlerExtensionsTests.cs @@ -8,8 +8,8 @@ public class InterceptionHandlerExtensionsTests #endregion - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Changing_File_OtherEvent_ShouldNotTrigger( string path, Exception exceptionToThrow) { @@ -26,8 +26,8 @@ public async Task Changing_File_OtherEvent_ShouldNotTrigger( await That(isNotified).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Changing_File_ShouldConsiderBasePath(string path1, string path2, Exception exceptionToThrow) { @@ -44,13 +44,13 @@ public async Task Changing_File_ShouldConsiderBasePath(string path1, string path await That(isNotified).IsFalse(); } - [Theory] - [InlineAutoData(".", "foo", "f*o", true)] - [InlineAutoData(".", "foo", "*fo", false)] - [InlineAutoData("bar", "foo", "f*o", true)] - [InlineAutoData("bar", "foo", "baz/f*o", false)] - [InlineAutoData("bar", "foo", "/f*o", false)] - [InlineAutoData("bar", "foo", "**/f*o", true)] + [Test] + [AutoArguments(".", "foo", "f*o", true)] + [AutoArguments(".", "foo", "*fo", false)] + [AutoArguments("bar", "foo", "f*o", true)] + [AutoArguments("bar", "foo", "baz/f*o", false)] + [AutoArguments("bar", "foo", "/f*o", false)] + [AutoArguments("bar", "foo", "**/f*o", true)] public async Task Changing_File_ShouldConsiderGlobPattern( string basePath, string fileName, string globPattern, bool expectedResult, Exception exceptionToThrow) @@ -82,9 +82,9 @@ public async Task Changing_File_ShouldConsiderGlobPattern( await That(isNotified).IsEqualTo(expectedResult); } - [Theory] - [InlineAutoData(false)] - [InlineAutoData(true)] + [Test] + [AutoArguments(false)] + [AutoArguments(true)] public async Task Changing_File_ShouldUsePredicate(bool expectedResult, string path, Exception exceptionToThrow) { @@ -113,8 +113,8 @@ public async Task Changing_File_ShouldUsePredicate(bool expectedResult, string p await That(isNotified).IsEqualTo(expectedResult); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Creating_Directory_OtherEvent_ShouldNotTrigger( string path, Exception exceptionToThrow) { @@ -131,8 +131,8 @@ public async Task Creating_Directory_OtherEvent_ShouldNotTrigger( await That(isNotified).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Creating_Directory_ShouldConsiderBasePath( string path1, string path2, Exception exceptionToThrow) { @@ -148,13 +148,13 @@ public async Task Creating_Directory_ShouldConsiderBasePath( await That(isNotified).IsFalse(); } - [Theory] - [InlineAutoData(".", "foo", "f*o", true)] - [InlineAutoData(".", "foo", "*fo", false)] - [InlineAutoData("bar", "foo", "f*o", true)] - [InlineAutoData("bar", "foo", "baz/f*o", false)] - [InlineAutoData("bar", "foo", "/f*o", false)] - [InlineAutoData("bar", "foo", "**/f*o", true)] + [Test] + [AutoArguments(".", "foo", "f*o", true)] + [AutoArguments(".", "foo", "*fo", false)] + [AutoArguments("bar", "foo", "f*o", true)] + [AutoArguments("bar", "foo", "baz/f*o", false)] + [AutoArguments("bar", "foo", "/f*o", false)] + [AutoArguments("bar", "foo", "**/f*o", true)] public async Task Creating_Directory_ShouldConsiderGlobPattern( string basePath, string fileName, string globPattern, bool expectedResult, Exception exceptionToThrow) @@ -186,9 +186,9 @@ public async Task Creating_Directory_ShouldConsiderGlobPattern( await That(isNotified).IsEqualTo(expectedResult); } - [Theory] - [InlineAutoData(false)] - [InlineAutoData(true)] + [Test] + [AutoArguments(false)] + [AutoArguments(true)] public async Task Creating_Directory_ShouldUsePredicate(bool expectedResult, string path, Exception exceptionToThrow) { @@ -216,8 +216,8 @@ public async Task Creating_Directory_ShouldUsePredicate(bool expectedResult, str await That(isNotified).IsEqualTo(expectedResult); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Creating_File_OtherEvent_ShouldNotTrigger( string path, Exception exceptionToThrow) { @@ -234,8 +234,8 @@ public async Task Creating_File_OtherEvent_ShouldNotTrigger( await That(isNotified).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Creating_File_ShouldConsiderBasePath(string path1, string path2, Exception exceptionToThrow) { @@ -251,13 +251,13 @@ public async Task Creating_File_ShouldConsiderBasePath(string path1, string path await That(isNotified).IsFalse(); } - [Theory] - [InlineAutoData(".", "foo", "f*o", true)] - [InlineAutoData(".", "foo", "*fo", false)] - [InlineAutoData("bar", "foo", "f*o", true)] - [InlineAutoData("bar", "foo", "baz/f*o", false)] - [InlineAutoData("bar", "foo", "/f*o", false)] - [InlineAutoData("bar", "foo", "**/f*o", true)] + [Test] + [AutoArguments(".", "foo", "f*o", true)] + [AutoArguments(".", "foo", "*fo", false)] + [AutoArguments("bar", "foo", "f*o", true)] + [AutoArguments("bar", "foo", "baz/f*o", false)] + [AutoArguments("bar", "foo", "/f*o", false)] + [AutoArguments("bar", "foo", "**/f*o", true)] public async Task Creating_File_ShouldConsiderGlobPattern( string basePath, string fileName, string globPattern, bool expectedResult, Exception exceptionToThrow) @@ -289,9 +289,9 @@ public async Task Creating_File_ShouldConsiderGlobPattern( await That(isNotified).IsEqualTo(expectedResult); } - [Theory] - [InlineAutoData(false)] - [InlineAutoData(true)] + [Test] + [AutoArguments(false)] + [AutoArguments(true)] public async Task Creating_File_ShouldUsePredicate(bool expectedResult, string path, Exception exceptionToThrow) { @@ -319,8 +319,8 @@ public async Task Creating_File_ShouldUsePredicate(bool expectedResult, string p await That(isNotified).IsEqualTo(expectedResult); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Deleting_Directory_OtherEvent_ShouldNotTrigger( string path, Exception exceptionToThrow) { @@ -336,8 +336,8 @@ public async Task Deleting_Directory_OtherEvent_ShouldNotTrigger( await That(isNotified).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Deleting_Directory_ShouldConsiderBasePath( string path1, string path2, Exception exceptionToThrow) { @@ -354,13 +354,13 @@ public async Task Deleting_Directory_ShouldConsiderBasePath( await That(isNotified).IsFalse(); } - [Theory] - [InlineAutoData(".", "foo", "f*o", true)] - [InlineAutoData(".", "foo", "*fo", false)] - [InlineAutoData("bar", "foo", "f*o", true)] - [InlineAutoData("bar", "foo", "baz/f*o", false)] - [InlineAutoData("bar", "foo", "/f*o", false)] - [InlineAutoData("bar", "foo", "**/f*o", true)] + [Test] + [AutoArguments(".", "foo", "f*o", true)] + [AutoArguments(".", "foo", "*fo", false)] + [AutoArguments("bar", "foo", "f*o", true)] + [AutoArguments("bar", "foo", "baz/f*o", false)] + [AutoArguments("bar", "foo", "/f*o", false)] + [AutoArguments("bar", "foo", "**/f*o", true)] public async Task Deleting_Directory_ShouldConsiderGlobPattern( string basePath, string directoryName, string globPattern, bool expectedResult, Exception exceptionToThrow) @@ -392,9 +392,9 @@ public async Task Deleting_Directory_ShouldConsiderGlobPattern( await That(isNotified).IsEqualTo(expectedResult); } - [Theory] - [InlineAutoData(false)] - [InlineAutoData(true)] + [Test] + [AutoArguments(false)] + [AutoArguments(true)] public async Task Deleting_Directory_ShouldUsePredicate(bool expectedResult, string path, Exception exceptionToThrow) { @@ -423,8 +423,8 @@ public async Task Deleting_Directory_ShouldUsePredicate(bool expectedResult, str await That(isNotified).IsEqualTo(expectedResult); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Deleting_File_OtherEvent_ShouldNotTrigger( string path, Exception exceptionToThrow) { @@ -440,8 +440,8 @@ public async Task Deleting_File_OtherEvent_ShouldNotTrigger( await That(isNotified).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Deleting_File_ShouldConsiderBasePath(string path1, string path2, Exception exceptionToThrow) { @@ -458,13 +458,13 @@ public async Task Deleting_File_ShouldConsiderBasePath(string path1, string path await That(isNotified).IsFalse(); } - [Theory] - [InlineAutoData(".", "foo", "f*o", true)] - [InlineAutoData(".", "foo", "*fo", false)] - [InlineAutoData("bar", "foo", "f*o", true)] - [InlineAutoData("bar", "foo", "baz/f*o", false)] - [InlineAutoData("bar", "foo", "/f*o", false)] - [InlineAutoData("bar", "foo", "**/f*o", true)] + [Test] + [AutoArguments(".", "foo", "f*o", true)] + [AutoArguments(".", "foo", "*fo", false)] + [AutoArguments("bar", "foo", "f*o", true)] + [AutoArguments("bar", "foo", "baz/f*o", false)] + [AutoArguments("bar", "foo", "/f*o", false)] + [AutoArguments("bar", "foo", "**/f*o", true)] public async Task Deleting_File_ShouldConsiderGlobPattern( string basePath, string fileName, string globPattern, bool expectedResult, Exception exceptionToThrow) @@ -496,9 +496,9 @@ public async Task Deleting_File_ShouldConsiderGlobPattern( await That(isNotified).IsEqualTo(expectedResult); } - [Theory] - [InlineAutoData(false)] - [InlineAutoData(true)] + [Test] + [AutoArguments(false)] + [AutoArguments(true)] public async Task Deleting_File_ShouldUsePredicate(bool expectedResult, string path, Exception exceptionToThrow) { diff --git a/Tests/Testably.Abstractions.Testing.Tests/MockFileSystemExtensionsTests.cs b/Tests/Testably.Abstractions.Testing.Tests/MockFileSystemExtensionsTests.cs index 2211e1ff1..4b9d12ec8 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/MockFileSystemExtensionsTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/MockFileSystemExtensionsTests.cs @@ -5,7 +5,7 @@ namespace Testably.Abstractions.Testing.Tests; public class MockFileSystemExtensionsTests { - [Fact] + [Test] public async Task GetDefaultDrive_WithoutDrives_ShouldThrowInvalidOperationException() { MockFileSystem fileSystem = new(); diff --git a/Tests/Testably.Abstractions.Testing.Tests/MockFileSystemInitializationTests.cs b/Tests/Testably.Abstractions.Testing.Tests/MockFileSystemInitializationTests.cs index 75b66718b..d7436b977 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/MockFileSystemInitializationTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/MockFileSystemInitializationTests.cs @@ -7,7 +7,7 @@ namespace Testably.Abstractions.Testing.Tests; public class MockFileSystemInitializationTests { #if CAN_SIMULATE_OTHER_OS - [Fact] + [Test] public async Task MockFileSystem_WhenSimulatingLinux_ShouldBeLinux() { MockFileSystem sut = new(o => o @@ -21,7 +21,7 @@ public async Task MockFileSystem_WhenSimulatingLinux_ShouldBeLinux() #endif #if CAN_SIMULATE_OTHER_OS - [Fact] + [Test] public async Task MockFileSystem_WhenSimulatingMacOS_ShouldBeMac() { MockFileSystem sut = new(o => o @@ -35,7 +35,7 @@ public async Task MockFileSystem_WhenSimulatingMacOS_ShouldBeMac() #endif #if CAN_SIMULATE_OTHER_OS - [Fact] + [Test] public async Task MockFileSystem_WhenSimulatingWindows_ShouldBeWindows() { MockFileSystem sut = new(o => o @@ -48,7 +48,7 @@ public async Task MockFileSystem_WhenSimulatingWindows_ShouldBeWindows() } #endif - [Fact] + [Test] public async Task MockFileSystem_WithCurrentDirectory_ShouldInitializeCurrentDirectory() { string expected = Directory.GetCurrentDirectory(); @@ -59,8 +59,8 @@ public async Task MockFileSystem_WithCurrentDirectory_ShouldInitializeCurrentDir await That(result).IsEqualTo(expected); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task MockFileSystem_WithExplicitCurrentDirectory_ShouldInitializeCurrentDirectory( string path) { @@ -72,7 +72,7 @@ public async Task MockFileSystem_WithExplicitCurrentDirectory_ShouldInitializeCu await That(result).IsEqualTo(expected); } - [Fact] + [Test] public async Task MockFileSystem_WithoutCurrentDirectory_ShouldUseDefaultDriveAsCurrentDirectory() { @@ -85,8 +85,8 @@ public async Task } #if CAN_SIMULATE_OTHER_OS - [Theory] - [MemberData(nameof(ValidOperatingSystems))] + [Test] + [MethodDataSource(nameof(ValidOperatingSystems))] public async Task SimulatingOperatingSystem_ValidOSPlatform_ShouldSetOperatingSystem( SimulationMode simulationMode) { @@ -99,7 +99,7 @@ public async Task SimulatingOperatingSystem_ValidOSPlatform_ShouldSetOperatingSy } #endif - [Fact] + [Test] public async Task UseCurrentDirectory_Empty_ShouldUseCurrentDirectory() { string expected = Directory.GetCurrentDirectory(); @@ -111,8 +111,8 @@ public async Task UseCurrentDirectory_Empty_ShouldUseCurrentDirectory() await That(sut.CurrentDirectory).IsEqualTo(expected); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task UseCurrentDirectory_WithPath_ShouldUsePathCurrentDirectory(string path) { MockFileSystem.MockFileSystemOptions sut = new(); @@ -123,8 +123,8 @@ public async Task UseCurrentDirectory_WithPath_ShouldUsePathCurrentDirectory(str await That(sut.CurrentDirectory).IsEqualTo(path); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task UseRandomProvider_ShouldUseFixedRandomValue(int fixedRandomValue) { MockFileSystem fileSystem = new(options => options @@ -139,8 +139,8 @@ public async Task UseRandomProvider_ShouldUseFixedRandomValue(int fixedRandomVal await That(results).All().AreEqualTo(fixedRandomValue); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task UseTimeSystem_ShouldUseProvidedTimeSystem(int offsetSeconds) { DateTime simulatedNow = DateTime.Now.AddSeconds(offsetSeconds); @@ -154,12 +154,12 @@ public async Task UseTimeSystem_ShouldUseProvidedTimeSystem(int offsetSeconds) await That(result).IsEqualTo(simulatedNow); } - #region Helpers - #if CAN_SIMULATE_OTHER_OS - public static TheoryData ValidOperatingSystems() - => new(SimulationMode.Linux, SimulationMode.MacOS, SimulationMode.Windows); + public static IEnumerable ValidOperatingSystems() + { + yield return SimulationMode.Linux; + yield return SimulationMode.MacOS; + yield return SimulationMode.Windows; + } #endif - - #endregion } diff --git a/Tests/Testably.Abstractions.Testing.Tests/MockFileSystemTests.cs b/Tests/Testably.Abstractions.Testing.Tests/MockFileSystemTests.cs index caf3c0831..f8294fce1 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/MockFileSystemTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/MockFileSystemTests.cs @@ -12,8 +12,8 @@ namespace Testably.Abstractions.Testing.Tests; public class MockFileSystemTests { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task FileSystemMock_File_Decrypt(string path, string contents) { MockFileSystem sut = new(); @@ -29,8 +29,8 @@ public async Task FileSystemMock_File_Decrypt(string path, string contents) await That(sut.File.ReadAllText(path)).IsEqualTo(contents); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task FileSystemMock_File_Encrypt(string path, string contents) { MockFileSystem sut = new(); @@ -43,8 +43,8 @@ public async Task FileSystemMock_File_Encrypt(string path, string contents) await That(sut.File.ReadAllText(path)).IsNotEqualTo(contents); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task FileSystemMock_FileInfo_Decrypt(string path, string contents) { MockFileSystem sut = new(); @@ -60,8 +60,8 @@ public async Task FileSystemMock_FileInfo_Decrypt(string path, string contents) await That(sut.File.ReadAllText(path)).IsEqualTo(contents); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task FileSystemMock_FileInfo_Encrypt(string path, string contents) { MockFileSystem sut = new(); @@ -74,7 +74,7 @@ public async Task FileSystemMock_FileInfo_Encrypt(string path, string contents) await That(sut.File.ReadAllText(path)).IsNotEqualTo(contents); } - [Fact] + [Test] public async Task FileSystemMock_ShouldBeInitializedWithADefaultDrive() { MockFileSystem sut = new(); @@ -91,10 +91,10 @@ public async Task FileSystemMock_ShouldBeInitializedWithADefaultDrive() await That(drive.VolumeLabel).IsNotNullOrEmpty(); } - [Theory] - [InlineData("A:\\")] - [InlineData("G:\\")] - [InlineData("z:\\")] + [Test] + [Arguments("A:\\")] + [Arguments("G:\\")] + [Arguments("z:\\")] public async Task FileSystemMock_ShouldInitializeDriveFromCurrentDirectory(string driveName) { Skip.If(!Test.RunsOnWindows); @@ -108,7 +108,7 @@ await That(drives) .Contains(d => string.Equals(d.Name, driveName, StringComparison.Ordinal)); } - [Fact] + [Test] public async Task ToString_ShouldContainStorageInformation() { MockFileSystem sut = new(); @@ -119,8 +119,8 @@ public async Task ToString_ShouldContainStorageInformation() await That(result).Contains("directories: 1, files: 1"); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WithAccessControl_Denied_CreateDirectoryShouldThrowUnauthorizedAccessException( string path) @@ -139,8 +139,8 @@ public async Task await That(exception).IsExactly(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WithAccessControl_ShouldConsiderPath( string allowedPath, string deniedPath) { @@ -160,7 +160,7 @@ public async Task WithAccessControl_ShouldConsiderPath( await That(exception).IsExactly(); } - [Fact] + [Test] public async Task WithAccessControlStrategy_OutsideWindows_ShouldThrowPlatformNotSupportedException() { @@ -177,8 +177,8 @@ await That(Act).Throws() .WithMessage("Access control lists are only supported on Windows."); } - [Theory] - [InlineData("D:\\")] + [Test] + [Arguments("D:\\")] public async Task WithDrive_Duplicate_ShouldUpdateExistingDrive(string driveName) { Skip.IfNot(Test.RunsOnWindows, "Linux does not support different drives."); @@ -195,7 +195,7 @@ public async Task WithDrive_Duplicate_ShouldUpdateExistingDrive(string driveName await That(drive.TotalSize).IsEqualTo(200); } - [Fact] + [Test] public async Task WithDrive_ExistingName_ShouldUpdateDrive() { MockFileSystem sut = new(); @@ -209,8 +209,8 @@ await That(drives).HasSingle() .Matching(d => string.Equals(d.Name, driveName, StringComparison.Ordinal)); } - [Theory] - [InlineData("D:\\")] + [Test] + [Arguments("D:\\")] public async Task WithDrive_NewName_ShouldCreateNewDrives(string driveName) { Skip.IfNot(Test.RunsOnWindows, "Linux does not support different drives."); @@ -225,9 +225,9 @@ await That(drives).HasSingle() .Matching(d => string.Equals(d.Name, driveName, StringComparison.Ordinal)); } - [Theory] - [InlineData("D")] - [InlineData("D:")] + [Test] + [Arguments("D")] + [Arguments("D:")] public async Task WithDrive_ShouldHavePathSeparatorSuffix(string driveName) { Skip.IfNot(Test.RunsOnWindows, "Linux does not support different drives."); @@ -243,7 +243,7 @@ await That(drives).HasSingle().Matching(d => string.Equals(d.Name, expectedDriveName, StringComparison.Ordinal)); } - [Fact] + [Test] public async Task WithDrive_ShouldInitializeDrivesWithRootDirectory() { Skip.IfNot(Test.RunsOnWindows, "Linux does not support different drives."); @@ -257,8 +257,8 @@ public async Task WithDrive_ShouldInitializeDrivesWithRootDirectory() await That(fileSystemInfos).HasCount(0); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WithDrive_WithCallback_ShouldUpdateDrive(long totalSize) { MockFileSystem sut = new(); @@ -272,8 +272,8 @@ public async Task WithDrive_WithCallback_ShouldUpdateDrive(long totalSize) } #if NET6_0_OR_GREATER - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WithSafeFileHandleStrategy_DefaultStrategy_ShouldUseMappedSafeFileHandleMock( string path, string contents) { @@ -292,8 +292,8 @@ public async Task WithSafeFileHandleStrategy_DefaultStrategy_ShouldUseMappedSafe #endif #if NET6_0_OR_GREATER - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WithSafeFileHandleStrategy_NullStrategy_ShouldThrowException( string path, string contents) { @@ -307,8 +307,8 @@ void Act() } #endif - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WithUncDrive_ShouldCreateUncDrive( string path, string contents) { @@ -321,7 +321,7 @@ public async Task WithUncDrive_ShouldCreateUncDrive( await That(result).IsEqualTo(contents); } - [Fact] + [Test] public async Task WithUncDrive_ShouldInitializeDrivesWithRootDirectory() { MockFileSystem sut = new(); @@ -337,8 +337,8 @@ public async Task WithUncDrive_ShouldInitializeDrivesWithRootDirectory() await That(fileSystemInfos).HasCount(0); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WithUncDrive_ShouldNotBeIncludedInGetDrives( string server) { @@ -354,8 +354,8 @@ public async Task WithUncDrive_ShouldNotBeIncludedInGetDrives( await That(sut.DriveInfo.GetDrives().Length).IsEqualTo(expectedDrives); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WithUncDrive_WriteBytes_ShouldReduceAvailableFreeSpace( string server, string path, byte[] bytes) { @@ -372,7 +372,7 @@ public async Task WithUncDrive_WriteBytes_ShouldReduceAvailableFreeSpace( } #if FEATURE_FILESYSTEM_UNIXFILEMODE - [Fact] + [Test] public async Task WithUnixFileModeStrategy_OnWindows_ShouldThrowPlatformNotSupportedException() { @@ -391,8 +391,8 @@ await That(Act).Throws() #endif #if FEATURE_FILESYSTEM_UNIXFILEMODE - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WithUnixFileModeStrategy_ShouldConsiderPath( string allowedPath, string deniedPath) { @@ -413,8 +413,8 @@ public async Task WithUnixFileModeStrategy_ShouldConsiderPath( } #endif - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllText_OnUncPath_ShouldThrowDirectoryNotFoundException( string path, string contents) { diff --git a/Tests/Testably.Abstractions.Testing.Tests/MockRandomSystemTests.cs b/Tests/Testably.Abstractions.Testing.Tests/MockRandomSystemTests.cs index ad99ffcd0..360f846b2 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/MockRandomSystemTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/MockRandomSystemTests.cs @@ -2,7 +2,7 @@ public class MockRandomSystemTests { - [Fact] + [Test] public async Task ToString_ShouldContainMockRandomSystem() { MockRandomSystem randomSystem = new(); diff --git a/Tests/Testably.Abstractions.Testing.Tests/MockTimeSystemTests.cs b/Tests/Testably.Abstractions.Testing.Tests/MockTimeSystemTests.cs index b9d6f7146..0af1aca69 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/MockTimeSystemTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/MockTimeSystemTests.cs @@ -5,57 +5,57 @@ namespace Testably.Abstractions.Testing.Tests; public class MockTimeSystemTests { - [Fact] + [Test] public async Task Delay_Infinite_ShouldNotThrowException() { MockTimeSystem timeSystem = new(); Exception? exception = await Record.ExceptionAsync(() - => timeSystem.Task.Delay(Timeout.Infinite, TestContext.Current.CancellationToken)); + => timeSystem.Task.Delay(Timeout.Infinite, TestContext.Current!.Execution.CancellationToken)); await That(exception).IsNull(); } - [Fact] + [Test] public async Task Delay_InfiniteTimeSpan_ShouldNotThrowException() { MockTimeSystem timeSystem = new(); Exception? exception = await Record.ExceptionAsync(() => timeSystem.Task.Delay(Timeout.InfiniteTimeSpan, - TestContext.Current.CancellationToken)); + TestContext.Current!.Execution.CancellationToken)); await That(exception).IsNull(); } - [Fact] + [Test] public async Task Delay_LessThanInfinite_ShouldNotThrowException() { MockTimeSystem timeSystem = new(); async Task Act() - => await timeSystem.Task.Delay(-2, TestContext.Current.CancellationToken); + => await timeSystem.Task.Delay(-2, TestContext.Current!.Execution.CancellationToken); await That(Act).ThrowsExactly() .WithParamName("millisecondsDelay"); } - [Fact] + [Test] public async Task Delay_LessThanInfiniteTimeSpan_ShouldNotThrowException() { MockTimeSystem timeSystem = new(); async Task Act() => await timeSystem.Task.Delay(TimeSpan.FromMilliseconds(-2), - TestContext.Current.CancellationToken); + TestContext.Current!.Execution.CancellationToken); await That(Act).ThrowsExactly().WithParamName("delay"); } - [Theory] - [InlineData(DateTimeKind.Local)] - [InlineData(DateTimeKind.Unspecified)] - [InlineData(DateTimeKind.Utc)] + [Test] + [Arguments(DateTimeKind.Local)] + [Arguments(DateTimeKind.Unspecified)] + [Arguments(DateTimeKind.Utc)] public async Task DifferenceBetweenDateTimeNowAndDateTimeUtcNow_ShouldBeLocalTimeZoneOffsetFromUtc(DateTimeKind dateTimeKind) { DateTime now = TimeTestHelper.GetRandomTime(DateTimeKind.Local); @@ -68,7 +68,7 @@ public async Task DifferenceBetweenDateTimeNowAndDateTimeUtcNow_ShouldBeLocalTim await That(actualDifference).IsEqualTo(expectedDifference); } - [Fact] + [Test] public async Task Sleep_Infinite_ShouldNotThrowException() { MockTimeSystem timeSystem = new(); @@ -78,7 +78,7 @@ public async Task Sleep_Infinite_ShouldNotThrowException() await That(exception).IsNull(); } - [Fact] + [Test] public async Task Sleep_InfiniteTimeSpan_ShouldNotThrowException() { MockTimeSystem timeSystem = new(); @@ -88,7 +88,7 @@ public async Task Sleep_InfiniteTimeSpan_ShouldNotThrowException() await That(exception).IsNull(); } - [Fact] + [Test] public async Task Sleep_LessThanInfinite_ShouldThrowArgumentOutOfRangeException() { MockTimeSystem timeSystem = new(); @@ -98,7 +98,7 @@ public async Task Sleep_LessThanInfinite_ShouldThrowArgumentOutOfRangeException( await That(exception).IsExactly(); } - [Fact] + [Test] public async Task Sleep_LessThanInfiniteTimeSpan_ShouldThrowArgumentOutOfRangeException() { MockTimeSystem timeSystem = new(); @@ -109,7 +109,7 @@ public async Task Sleep_LessThanInfiniteTimeSpan_ShouldThrowArgumentOutOfRangeEx await That(exception).IsExactly(); } - [Fact] + [Test] public async Task ToString_WithFixedContainer_ShouldContainTimeProvider() { DateTime now = TimeTestHelper.GetRandomTime(); @@ -121,7 +121,7 @@ public async Task ToString_WithFixedContainer_ShouldContainTimeProvider() await That(result).Contains($"{now}Z"); } - [Fact] + [Test] public async Task ToString_WithNowContainer_ShouldContainTimeProvider() { MockTimeSystem timeSystem = new(TimeProvider.Now()); @@ -132,7 +132,7 @@ public async Task ToString_WithNowContainer_ShouldContainTimeProvider() await That(result).Contains($"{timeSystem.DateTime.UtcNow}Z"); } - [Fact] + [Test] public async Task ToString_WithRandomContainer_ShouldContainTimeProvider() { MockTimeSystem timeSystem = new(TimeProvider.Random()); diff --git a/Tests/Testably.Abstractions.Testing.Tests/NotificationHandlerExtensionsTests.WithExecuteWhileWaiting.cs b/Tests/Testably.Abstractions.Testing.Tests/NotificationHandlerExtensionsTests.WithExecuteWhileWaiting.cs index e01554622..81875189b 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/NotificationHandlerExtensionsTests.WithExecuteWhileWaiting.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/NotificationHandlerExtensionsTests.WithExecuteWhileWaiting.cs @@ -2,8 +2,8 @@ namespace Testably.Abstractions.Testing.Tests; public partial class NotificationHandlerExtensionsTests { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WithExecuteWhileWaiting_OnChanged_File_OtherEvent_ShouldNotTrigger( string path) { @@ -24,8 +24,8 @@ public async Task WithExecuteWhileWaiting_OnChanged_File_OtherEvent_ShouldNotTri await That(isNotified).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WithExecuteWhileWaiting_OnChanged_File_ShouldConsiderBasePath(string path1, string path2) { @@ -48,13 +48,13 @@ public async Task WithExecuteWhileWaiting_OnChanged_File_ShouldConsiderBasePath( await That(isNotified).IsFalse(); } - [Theory] - [InlineData(".", "foo", "f*o", true)] - [InlineData(".", "foo", "*fo", false)] - [InlineData("bar", "foo", "f*o", true)] - [InlineData("bar", "foo", "baz/f*o", false)] - [InlineData("bar", "foo", "/f*o", false)] - [InlineData("bar", "foo", "**/f*o", true)] + [Test] + [Arguments(".", "foo", "f*o", true)] + [Arguments(".", "foo", "*fo", false)] + [Arguments("bar", "foo", "f*o", true)] + [Arguments("bar", "foo", "baz/f*o", false)] + [Arguments("bar", "foo", "/f*o", false)] + [Arguments("bar", "foo", "**/f*o", true)] public async Task WithExecuteWhileWaiting_OnChanged_File_ShouldConsiderGlobPattern( string directoryPath, string fileName, string globPattern, bool expectedResult) { @@ -86,8 +86,8 @@ public async Task WithExecuteWhileWaiting_OnChanged_File_ShouldConsiderGlobPatte await That(isNotified).IsEqualTo(expectedResult); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WithExecuteWhileWaiting_OnChanged_File_ShouldNotifyWhenFileIsChanged( string path) { @@ -105,9 +105,9 @@ public async Task WithExecuteWhileWaiting_OnChanged_File_ShouldNotifyWhenFileIsC await That(isNotified).IsTrue(); } - [Theory] - [InlineAutoData(false)] - [InlineAutoData(true)] + [Test] + [AutoArguments(false)] + [AutoArguments(true)] public async Task WithExecuteWhileWaiting_OnChanged_File_ShouldUsePredicate(bool expectedResult, string path) { @@ -138,8 +138,8 @@ public async Task WithExecuteWhileWaiting_OnChanged_File_ShouldUsePredicate(bool await That(isNotified).IsEqualTo(expectedResult); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WithExecuteWhileWaiting_OnCreated_Directory_OtherEvent_ShouldNotTrigger( string path) { @@ -161,8 +161,8 @@ public async Task WithExecuteWhileWaiting_OnCreated_Directory_OtherEvent_ShouldN await That(isNotified).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WithExecuteWhileWaiting_OnCreated_Directory_ShouldConsiderBasePath( string path1, string path2) { @@ -183,13 +183,13 @@ public async Task WithExecuteWhileWaiting_OnCreated_Directory_ShouldConsiderBase await That(isNotified).IsFalse(); } - [Theory] - [InlineData(".", "foo", "f*o", true)] - [InlineData(".", "foo", "*fo", false)] - [InlineData("bar", "foo", "f*o", true)] - [InlineData("bar", "foo", "baz/f*o", false)] - [InlineData("bar", "foo", "/f*o", false)] - [InlineData("bar", "foo", "**/f*o", true)] + [Test] + [Arguments(".", "foo", "f*o", true)] + [Arguments(".", "foo", "*fo", false)] + [Arguments("bar", "foo", "f*o", true)] + [Arguments("bar", "foo", "baz/f*o", false)] + [Arguments("bar", "foo", "/f*o", false)] + [Arguments("bar", "foo", "**/f*o", true)] public async Task WithExecuteWhileWaiting_OnCreated_Directory_ShouldConsiderGlobPattern( string directoryPath, string fileName, string globPattern, bool expectedResult) { @@ -221,8 +221,8 @@ public async Task WithExecuteWhileWaiting_OnCreated_Directory_ShouldConsiderGlob await That(isNotified).IsEqualTo(expectedResult); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WithExecuteWhileWaiting_OnCreated_Directory_ShouldNotifyWhenDirectoryIsCreated(string path) { @@ -239,9 +239,9 @@ public async Task await That(isNotified).IsTrue(); } - [Theory] - [InlineAutoData(false)] - [InlineAutoData(true)] + [Test] + [AutoArguments(false)] + [AutoArguments(true)] public async Task WithExecuteWhileWaiting_OnCreated_Directory_ShouldUsePredicate( bool expectedResult, string path) { @@ -271,8 +271,8 @@ public async Task WithExecuteWhileWaiting_OnCreated_Directory_ShouldUsePredicate await That(isNotified).IsEqualTo(expectedResult); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WithExecuteWhileWaiting_OnCreated_File_OtherEvent_ShouldNotTrigger( string path) { @@ -294,8 +294,8 @@ public async Task WithExecuteWhileWaiting_OnCreated_File_OtherEvent_ShouldNotTri await That(isNotified).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WithExecuteWhileWaiting_OnCreated_File_ShouldConsiderBasePath(string path1, string path2) { @@ -316,13 +316,13 @@ public async Task WithExecuteWhileWaiting_OnCreated_File_ShouldConsiderBasePath( await That(isNotified).IsFalse(); } - [Theory] - [InlineData(".", "foo", "f*o", true)] - [InlineData(".", "foo", "*fo", false)] - [InlineData("bar", "foo", "f*o", true)] - [InlineData("bar", "foo", "baz/f*o", false)] - [InlineData("bar", "foo", "/f*o", false)] - [InlineData("bar", "foo", "**/f*o", true)] + [Test] + [Arguments(".", "foo", "f*o", true)] + [Arguments(".", "foo", "*fo", false)] + [Arguments("bar", "foo", "f*o", true)] + [Arguments("bar", "foo", "baz/f*o", false)] + [Arguments("bar", "foo", "/f*o", false)] + [Arguments("bar", "foo", "**/f*o", true)] public async Task WithExecuteWhileWaiting_OnCreated_File_ShouldConsiderGlobPattern( string directoryPath, string fileName, string globPattern, bool expectedResult) { @@ -354,8 +354,8 @@ public async Task WithExecuteWhileWaiting_OnCreated_File_ShouldConsiderGlobPatte await That(isNotified).IsEqualTo(expectedResult); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WithExecuteWhileWaiting_OnCreated_File_ShouldNotifyWhenFileIsCreated( string path) { @@ -372,9 +372,9 @@ public async Task WithExecuteWhileWaiting_OnCreated_File_ShouldNotifyWhenFileIsC await That(isNotified).IsTrue(); } - [Theory] - [InlineAutoData(false)] - [InlineAutoData(true)] + [Test] + [AutoArguments(false)] + [AutoArguments(true)] public async Task WithExecuteWhileWaiting_OnCreated_File_ShouldUsePredicate(bool expectedResult, string path) { @@ -404,8 +404,8 @@ public async Task WithExecuteWhileWaiting_OnCreated_File_ShouldUsePredicate(bool await That(isNotified).IsEqualTo(expectedResult); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WithExecuteWhileWaiting_OnDeleted_Directory_OtherEvent_ShouldNotTrigger( string path) { @@ -426,8 +426,8 @@ public async Task WithExecuteWhileWaiting_OnDeleted_Directory_OtherEvent_ShouldN await That(isNotified).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WithExecuteWhileWaiting_OnDeleted_Directory_ShouldConsiderBasePath( string path1, string path2) { @@ -450,13 +450,13 @@ public async Task WithExecuteWhileWaiting_OnDeleted_Directory_ShouldConsiderBase await That(isNotified).IsFalse(); } - [Theory] - [InlineData(".", "foo", "f*o", true)] - [InlineData(".", "foo", "*fo", false)] - [InlineData("bar", "foo", "f*o", true)] - [InlineData("bar", "foo", "baz/f*o", false)] - [InlineData("bar", "foo", "/f*o", false)] - [InlineData("bar", "foo", "**/f*o", true)] + [Test] + [Arguments(".", "foo", "f*o", true)] + [Arguments(".", "foo", "*fo", false)] + [Arguments("bar", "foo", "f*o", true)] + [Arguments("bar", "foo", "baz/f*o", false)] + [Arguments("bar", "foo", "/f*o", false)] + [Arguments("bar", "foo", "**/f*o", true)] public async Task WithExecuteWhileWaiting_OnDeleted_Directory_ShouldConsiderGlobPattern( string basePath, string directoryName, string globPattern, bool expectedResult) { @@ -489,8 +489,8 @@ public async Task WithExecuteWhileWaiting_OnDeleted_Directory_ShouldConsiderGlob await That(isNotified).IsEqualTo(expectedResult); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WithExecuteWhileWaiting_OnDeleted_Directory_ShouldNotifyWhenDirectoryIsDeleted(string path) { @@ -508,9 +508,9 @@ public async Task await That(isNotified).IsTrue(); } - [Theory] - [InlineAutoData(false)] - [InlineAutoData(true)] + [Test] + [AutoArguments(false)] + [AutoArguments(true)] public async Task WithExecuteWhileWaiting_OnDeleted_Directory_ShouldUsePredicate( bool expectedResult, string path) { @@ -541,8 +541,8 @@ public async Task WithExecuteWhileWaiting_OnDeleted_Directory_ShouldUsePredicate await That(isNotified).IsEqualTo(expectedResult); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WithExecuteWhileWaiting_OnDeleted_File_OtherEvent_ShouldNotTrigger( string path) { @@ -563,8 +563,8 @@ public async Task WithExecuteWhileWaiting_OnDeleted_File_OtherEvent_ShouldNotTri await That(isNotified).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WithExecuteWhileWaiting_OnDeleted_File_ShouldConsiderBasePath(string path1, string path2) { @@ -587,13 +587,13 @@ public async Task WithExecuteWhileWaiting_OnDeleted_File_ShouldConsiderBasePath( await That(isNotified).IsFalse(); } - [Theory] - [InlineData(".", "foo", "f*o", true)] - [InlineData(".", "foo", "*fo", false)] - [InlineData("bar", "foo", "f*o", true)] - [InlineData("bar", "foo", "baz/f*o", false)] - [InlineData("bar", "foo", "/f*o", false)] - [InlineData("bar", "foo", "**/f*o", true)] + [Test] + [Arguments(".", "foo", "f*o", true)] + [Arguments(".", "foo", "*fo", false)] + [Arguments("bar", "foo", "f*o", true)] + [Arguments("bar", "foo", "baz/f*o", false)] + [Arguments("bar", "foo", "/f*o", false)] + [Arguments("bar", "foo", "**/f*o", true)] public async Task WithExecuteWhileWaiting_OnDeleted_File_ShouldConsiderGlobPattern( string directoryPath, string fileName, string globPattern, bool expectedResult) { @@ -626,8 +626,8 @@ public async Task WithExecuteWhileWaiting_OnDeleted_File_ShouldConsiderGlobPatte await That(isNotified).IsEqualTo(expectedResult); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WithExecuteWhileWaiting_OnDeleted_File_ShouldNotifyWhenFileIsDeleted( string path) { @@ -645,9 +645,9 @@ public async Task WithExecuteWhileWaiting_OnDeleted_File_ShouldNotifyWhenFileIsD await That(isNotified).IsTrue(); } - [Theory] - [InlineAutoData(false)] - [InlineAutoData(true)] + [Test] + [AutoArguments(false)] + [AutoArguments(true)] public async Task WithExecuteWhileWaiting_OnDeleted_File_ShouldUsePredicate(bool expectedResult, string path) { diff --git a/Tests/Testably.Abstractions.Testing.Tests/NotificationHandlerExtensionsTests.cs b/Tests/Testably.Abstractions.Testing.Tests/NotificationHandlerExtensionsTests.cs index 5d553fedd..4c307f851 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/NotificationHandlerExtensionsTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/NotificationHandlerExtensionsTests.cs @@ -10,8 +10,8 @@ public partial class NotificationHandlerExtensionsTests #endregion - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task OnChanged_File_OtherEvent_ShouldNotTrigger(string path) { bool isNotified = false; @@ -31,8 +31,8 @@ public async Task OnChanged_File_OtherEvent_ShouldNotTrigger(string path) await That(isNotified).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task OnChanged_File_ShouldConsiderBasePath(string path1, string path2) { bool isNotified = false; @@ -52,13 +52,13 @@ public async Task OnChanged_File_ShouldConsiderBasePath(string path1, string pat await That(isNotified).IsFalse(); } - [Theory] - [InlineData(".", "foo", "f*o", true)] - [InlineData(".", "foo", "*fo", false)] - [InlineData("bar", "foo", "f*o", true)] - [InlineData("bar", "foo", "baz/f*o", false)] - [InlineData("bar", "foo", "/f*o", false)] - [InlineData("bar", "foo", "**/f*o", true)] + [Test] + [Arguments(".", "foo", "f*o", true)] + [Arguments(".", "foo", "*fo", false)] + [Arguments("bar", "foo", "f*o", true)] + [Arguments("bar", "foo", "baz/f*o", false)] + [Arguments("bar", "foo", "/f*o", false)] + [Arguments("bar", "foo", "**/f*o", true)] public async Task OnChanged_File_ShouldConsiderGlobPattern( string directoryPath, string fileName, string globPattern, bool expectedResult) { @@ -88,8 +88,8 @@ public async Task OnChanged_File_ShouldConsiderGlobPattern( await That(isNotified).IsEqualTo(expectedResult); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task OnChanged_File_ShouldNotifyWhenFileIsChanged(string path) { bool isNotified = false; @@ -105,9 +105,9 @@ public async Task OnChanged_File_ShouldNotifyWhenFileIsChanged(string path) await That(isNotified).IsTrue(); } - [Theory] - [InlineAutoData(false)] - [InlineAutoData(true)] + [Test] + [AutoArguments(false)] + [AutoArguments(true)] public async Task OnChanged_File_ShouldUsePredicate(bool expectedResult, string path) { bool isNotified = false; @@ -136,8 +136,8 @@ public async Task OnChanged_File_ShouldUsePredicate(bool expectedResult, string await That(isNotified).IsEqualTo(expectedResult); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task OnCreated_Directory_OtherEvent_ShouldNotTrigger(string path) { bool isNotified = false; @@ -157,8 +157,8 @@ public async Task OnCreated_Directory_OtherEvent_ShouldNotTrigger(string path) await That(isNotified).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task OnCreated_Directory_ShouldConsiderBasePath(string path1, string path2) { bool isNotified = false; @@ -177,13 +177,13 @@ public async Task OnCreated_Directory_ShouldConsiderBasePath(string path1, strin await That(isNotified).IsFalse(); } - [Theory] - [InlineData(".", "foo", "f*o", true)] - [InlineData(".", "foo", "*fo", false)] - [InlineData("bar", "foo", "f*o", true)] - [InlineData("bar", "foo", "baz/f*o", false)] - [InlineData("bar", "foo", "/f*o", false)] - [InlineData("bar", "foo", "**/f*o", true)] + [Test] + [Arguments(".", "foo", "f*o", true)] + [Arguments(".", "foo", "*fo", false)] + [Arguments("bar", "foo", "f*o", true)] + [Arguments("bar", "foo", "baz/f*o", false)] + [Arguments("bar", "foo", "/f*o", false)] + [Arguments("bar", "foo", "**/f*o", true)] public async Task OnCreated_Directory_ShouldConsiderGlobPattern( string directoryPath, string fileName, string globPattern, bool expectedResult) { @@ -214,8 +214,8 @@ public async Task OnCreated_Directory_ShouldConsiderGlobPattern( await That(isNotified).IsEqualTo(expectedResult); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task OnCreated_Directory_ShouldNotifyWhenDirectoryIsCreated(string path) { bool isNotified = false; @@ -229,9 +229,9 @@ public async Task OnCreated_Directory_ShouldNotifyWhenDirectoryIsCreated(string await That(isNotified).IsTrue(); } - [Theory] - [InlineAutoData(false)] - [InlineAutoData(true)] + [Test] + [AutoArguments(false)] + [AutoArguments(true)] public async Task OnCreated_Directory_ShouldUsePredicate(bool expectedResult, string path) { bool isNotified = false; @@ -259,8 +259,8 @@ public async Task OnCreated_Directory_ShouldUsePredicate(bool expectedResult, st await That(isNotified).IsEqualTo(expectedResult); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task OnCreated_File_OtherEvent_ShouldNotTrigger(string path) { bool isNotified = false; @@ -280,8 +280,8 @@ public async Task OnCreated_File_OtherEvent_ShouldNotTrigger(string path) await That(isNotified).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task OnCreated_File_ShouldConsiderBasePath(string path1, string path2) { bool isNotified = false; @@ -300,13 +300,13 @@ public async Task OnCreated_File_ShouldConsiderBasePath(string path1, string pat await That(isNotified).IsFalse(); } - [Theory] - [InlineData(".", "foo", "f*o", true)] - [InlineData(".", "foo", "*fo", false)] - [InlineData("bar", "foo", "f*o", true)] - [InlineData("bar", "foo", "baz/f*o", false)] - [InlineData("bar", "foo", "/f*o", false)] - [InlineData("bar", "foo", "**/f*o", true)] + [Test] + [Arguments(".", "foo", "f*o", true)] + [Arguments(".", "foo", "*fo", false)] + [Arguments("bar", "foo", "f*o", true)] + [Arguments("bar", "foo", "baz/f*o", false)] + [Arguments("bar", "foo", "/f*o", false)] + [Arguments("bar", "foo", "**/f*o", true)] public async Task OnCreated_File_ShouldConsiderGlobPattern( string directoryPath, string fileName, string globPattern, bool expectedResult) { @@ -337,8 +337,8 @@ public async Task OnCreated_File_ShouldConsiderGlobPattern( await That(isNotified).IsEqualTo(expectedResult); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task OnCreated_File_ShouldNotifyWhenFileIsCreated(string path) { bool isNotified = false; @@ -352,9 +352,9 @@ public async Task OnCreated_File_ShouldNotifyWhenFileIsCreated(string path) await That(isNotified).IsTrue(); } - [Theory] - [InlineAutoData(false)] - [InlineAutoData(true)] + [Test] + [AutoArguments(false)] + [AutoArguments(true)] public async Task OnCreated_File_ShouldUsePredicate(bool expectedResult, string path) { bool isNotified = false; @@ -382,8 +382,8 @@ public async Task OnCreated_File_ShouldUsePredicate(bool expectedResult, string await That(isNotified).IsEqualTo(expectedResult); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task OnDeleted_Directory_OtherEvent_ShouldNotTrigger(string path) { bool isNotified = false; @@ -402,8 +402,8 @@ public async Task OnDeleted_Directory_OtherEvent_ShouldNotTrigger(string path) await That(isNotified).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task OnDeleted_Directory_ShouldConsiderBasePath(string path1, string path2) { bool isNotified = false; @@ -424,13 +424,13 @@ public async Task OnDeleted_Directory_ShouldConsiderBasePath(string path1, strin await That(isNotified).IsFalse(); } - [Theory] - [InlineData(".", "foo", "f*o", true)] - [InlineData(".", "foo", "*fo", false)] - [InlineData("bar", "foo", "f*o", true)] - [InlineData("bar", "foo", "baz/f*o", false)] - [InlineData("bar", "foo", "/f*o", false)] - [InlineData("bar", "foo", "**/f*o", true)] + [Test] + [Arguments(".", "foo", "f*o", true)] + [Arguments(".", "foo", "*fo", false)] + [Arguments("bar", "foo", "f*o", true)] + [Arguments("bar", "foo", "baz/f*o", false)] + [Arguments("bar", "foo", "/f*o", false)] + [Arguments("bar", "foo", "**/f*o", true)] public async Task OnDeleted_Directory_ShouldConsiderGlobPattern( string basePath, string directoryName, string globPattern, bool expectedResult) { @@ -462,8 +462,8 @@ public async Task OnDeleted_Directory_ShouldConsiderGlobPattern( await That(isNotified).IsEqualTo(expectedResult); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task OnDeleted_Directory_ShouldNotifyWhenDirectoryIsDeleted(string path) { bool isNotified = false; @@ -478,9 +478,9 @@ public async Task OnDeleted_Directory_ShouldNotifyWhenDirectoryIsDeleted(string await That(isNotified).IsTrue(); } - [Theory] - [InlineAutoData(false)] - [InlineAutoData(true)] + [Test] + [AutoArguments(false)] + [AutoArguments(true)] public async Task OnDeleted_Directory_ShouldUsePredicate(bool expectedResult, string path) { bool isNotified = false; @@ -509,8 +509,8 @@ public async Task OnDeleted_Directory_ShouldUsePredicate(bool expectedResult, st await That(isNotified).IsEqualTo(expectedResult); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task OnDeleted_File_OtherEvent_ShouldNotTrigger(string path) { bool isNotified = false; @@ -529,8 +529,8 @@ public async Task OnDeleted_File_OtherEvent_ShouldNotTrigger(string path) await That(isNotified).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task OnDeleted_File_ShouldConsiderBasePath(string path1, string path2) { bool isNotified = false; @@ -551,13 +551,13 @@ public async Task OnDeleted_File_ShouldConsiderBasePath(string path1, string pat await That(isNotified).IsFalse(); } - [Theory] - [InlineData(".", "foo", "f*o", true)] - [InlineData(".", "foo", "*fo", false)] - [InlineData("bar", "foo", "f*o", true)] - [InlineData("bar", "foo", "baz/f*o", false)] - [InlineData("bar", "foo", "/f*o", false)] - [InlineData("bar", "foo", "**/f*o", true)] + [Test] + [Arguments(".", "foo", "f*o", true)] + [Arguments(".", "foo", "*fo", false)] + [Arguments("bar", "foo", "f*o", true)] + [Arguments("bar", "foo", "baz/f*o", false)] + [Arguments("bar", "foo", "/f*o", false)] + [Arguments("bar", "foo", "**/f*o", true)] public async Task OnDeleted_File_ShouldConsiderGlobPattern( string directoryPath, string fileName, string globPattern, bool expectedResult) { @@ -589,8 +589,8 @@ public async Task OnDeleted_File_ShouldConsiderGlobPattern( await That(isNotified).IsEqualTo(expectedResult); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task OnDeleted_File_ShouldNotifyWhenFileIsDeleted(string path) { bool isNotified = false; @@ -605,9 +605,9 @@ public async Task OnDeleted_File_ShouldNotifyWhenFileIsDeleted(string path) await That(isNotified).IsTrue(); } - [Theory] - [InlineAutoData(false)] - [InlineAutoData(true)] + [Test] + [AutoArguments(false)] + [AutoArguments(true)] public async Task OnDeleted_File_ShouldUsePredicate(bool expectedResult, string path) { bool isNotified = false; diff --git a/Tests/Testably.Abstractions.Testing.Tests/NotificationTests.WaitAsync.cs b/Tests/Testably.Abstractions.Testing.Tests/NotificationTests.WaitAsync.cs index 53f9f383c..f17af2ae1 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/NotificationTests.WaitAsync.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/NotificationTests.WaitAsync.cs @@ -6,7 +6,7 @@ public partial class NotificationTests { public sealed class WaitAsync { - [Fact] + [Test] public async Task AwaitableCallback_Amount_ShouldOnlyReturnAfterNumberOfCallbacks() { MockTimeSystem timeSystem = new(); @@ -22,21 +22,21 @@ public async Task AwaitableCallback_Amount_ShouldOnlyReturnAfterNumberOfCallback _ = Task.Run(async () => { - await Task.Delay(10, TestContext.Current.CancellationToken); + await Task.Delay(10, TestContext.Current!.Execution.CancellationToken); for (int i = 1; i <= 10; i++) { timeSystem.Thread.Sleep(i); - await Task.Delay(1, TestContext.Current.CancellationToken); + await Task.Delay(1, TestContext.Current!.Execution.CancellationToken); } - }, TestContext.Current.CancellationToken); + }, TestContext.Current!.Execution.CancellationToken); TimeSpan[] result = await onThreadSleep.WaitAsync(count: 7, - cancellationToken: TestContext.Current.CancellationToken); + cancellationToken: TestContext.Current!.Execution.CancellationToken); await That(receivedCount).IsGreaterThanOrEqualTo(7); await That(result.Length).IsEqualTo(7); } - [Fact] + [Test] public async Task AwaitableCallback_CancellationTokenCancelled_ShouldThrowOperationCancelledException() { @@ -54,7 +54,7 @@ public async Task try { // Delay larger than cancellation after 10ms - ms.Wait(TestContext.Current.CancellationToken); + ms.Wait(TestContext.Current!.Execution.CancellationToken); timeSystem.Thread.Sleep(1); } catch (ObjectDisposedException) @@ -75,7 +75,7 @@ public async Task ms.Set(); } - [Fact] + [Test] public async Task AwaitableCallback_ShouldWaitForCallbackExecution() { using ManualResetEventSlim ms = new(); @@ -97,17 +97,17 @@ public async Task AwaitableCallback_ShouldWaitForCallbackExecution() while (!ms.IsSet) { timeSystem.Thread.Sleep(1); - await Task.Delay(1, TestContext.Current.CancellationToken); + await Task.Delay(1, TestContext.Current!.Execution.CancellationToken); } } catch (ObjectDisposedException) { // Ignore any ObjectDisposedException } - }, TestContext.Current.CancellationToken); + }, TestContext.Current!.Execution.CancellationToken); await onThreadSleep.WaitAsync( - cancellationToken: TestContext.Current.CancellationToken); + cancellationToken: TestContext.Current!.Execution.CancellationToken); await That(isCalled).IsTrue(); } finally @@ -116,7 +116,7 @@ await onThreadSleep.WaitAsync( } } - [Fact] + [Test] public async Task AwaitableCallback_TimeoutExpired_ShouldThrowOperationCancelledException() { @@ -134,7 +134,7 @@ public async Task try { // Delay larger than timeout of 10ms - ms.Wait(TestContext.Current.CancellationToken); + ms.Wait(TestContext.Current!.Execution.CancellationToken); timeSystem.Thread.Sleep(1); } catch (ObjectDisposedException) @@ -146,7 +146,7 @@ public async Task Exception? exception = await Record.ExceptionAsync(async () => { await onThreadSleep.WaitAsync(1, TimeSpan.FromMilliseconds(10), - TestContext.Current.CancellationToken); + TestContext.Current!.Execution.CancellationToken); }); await That(exception).IsExactly(); @@ -154,7 +154,7 @@ await onThreadSleep.WaitAsync(1, TimeSpan.FromMilliseconds(10), ms.Set(); } - [Fact] + [Test] public async Task AwaitableCallback_WaitAsync_AfterDispose_ShouldThrowObjectDisposedException() { @@ -167,14 +167,14 @@ public async Task async Task Act() { await onThreadSleep.WaitAsync(timeout: 20000, - cancellationToken: TestContext.Current.CancellationToken); + cancellationToken: TestContext.Current!.Execution.CancellationToken); } await That(Act).ThrowsExactly() .WithMessage("The awaitable callback is already disposed."); } - [Fact] + [Test] public async Task AwaitableCallback_WaitedPreviously_ShouldWaitAgainForCallbackExecution() { int secondThreadMilliseconds = 42; @@ -185,29 +185,29 @@ public async Task AwaitableCallback_WaitedPreviously_ShouldWaitAgainForCallbackE using IAwaitableCallback onThreadSleep = timeSystem.On.ThreadSleep(); - _ = Task.Delay(50, TestContext.Current.CancellationToken) + _ = Task.Delay(50, TestContext.Current!.Execution.CancellationToken) .ContinueWith(_ => timeSystem.Thread.Sleep(firstThreadMilliseconds), - TestContext.Current.CancellationToken) + TestContext.Current!.Execution.CancellationToken) .ContinueWith( - async _ => await Task.Delay(20, TestContext.Current.CancellationToken), - TestContext.Current.CancellationToken) + async _ => await Task.Delay(20, TestContext.Current!.Execution.CancellationToken), + TestContext.Current!.Execution.CancellationToken) .ContinueWith(_ => timeSystem.Thread.Sleep(secondThreadMilliseconds), - TestContext.Current.CancellationToken); + TestContext.Current!.Execution.CancellationToken); TimeSpan[] result1 = await onThreadSleep.WaitAsync( - cancellationToken: TestContext.Current.CancellationToken); + cancellationToken: TestContext.Current!.Execution.CancellationToken); TimeSpan[] result2 = await onThreadSleep.WaitAsync( - cancellationToken: TestContext.Current.CancellationToken); + cancellationToken: TestContext.Current!.Execution.CancellationToken); await That(result1).HasSingle().Which .Satisfies(f => f.Milliseconds == firstThreadMilliseconds); await That(result2).HasSingle().Which .Satisfies(f => f.Milliseconds == secondThreadMilliseconds); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Execute_ShouldBeExecutedBeforeWait(int milliseconds) { MockTimeSystem timeSystem = new(); @@ -219,11 +219,11 @@ public async Task Execute_ShouldBeExecutedBeforeWait(int milliseconds) receivedMilliseconds = (int)t.TotalMilliseconds; }); timeSystem.Thread.Sleep(milliseconds); - await onThreadSleep.WaitAsync(cancellationToken: TestContext.Current.CancellationToken); + await onThreadSleep.WaitAsync(cancellationToken: TestContext.Current!.Execution.CancellationToken); await That(receivedMilliseconds).IsEqualTo(milliseconds); } - [Fact] + [Test] public async Task ExecuteWhileWaiting_ShouldExecuteCallback() { MockTimeSystem timeSystem = new(); @@ -234,7 +234,7 @@ public async Task ExecuteWhileWaiting_ShouldExecuteCallback() timeSystem.Thread.Sleep(10); TimeSpan[] result = await onThreadSleep.WaitAsync( - cancellationToken: TestContext.Current.CancellationToken); + cancellationToken: TestContext.Current!.Execution.CancellationToken); await That(result).HasSingle().Which.Satisfies(f => f.Milliseconds == 10); } } diff --git a/Tests/Testably.Abstractions.Testing.Tests/NotificationTests.cs b/Tests/Testably.Abstractions.Testing.Tests/NotificationTests.cs index a066814b5..0f08fbcb9 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/NotificationTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/NotificationTests.cs @@ -4,7 +4,7 @@ namespace Testably.Abstractions.Testing.Tests; public partial class NotificationTests { - [Fact] + [Test] public async Task AwaitableCallback_Amount_ShouldOnlyReturnAfterNumberOfCallbacks() { MockTimeSystem timeSystem = new(); @@ -20,19 +20,19 @@ public async Task AwaitableCallback_Amount_ShouldOnlyReturnAfterNumberOfCallback _ = Task.Run(async () => { - await Task.Delay(10, TestContext.Current.CancellationToken); + await Task.Delay(10, TestContext.Current!.Execution.CancellationToken); for (int i = 1; i <= 10; i++) { timeSystem.Thread.Sleep(i); - await Task.Delay(1, TestContext.Current.CancellationToken); + await Task.Delay(1, TestContext.Current!.Execution.CancellationToken); } - }, TestContext.Current.CancellationToken); + }, TestContext.Current!.Execution.CancellationToken); wait.Wait(7); await That(receivedCount).IsGreaterThanOrEqualTo(7); } - [Fact] + [Test] public async Task AwaitableCallback_Dispose_ShouldStopListening() { MockTimeSystem timeSystem = new(); @@ -46,11 +46,11 @@ public async Task AwaitableCallback_Dispose_ShouldStopListening() wait.Dispose(); timeSystem.Thread.Sleep(1); - await Task.Delay(10, TestContext.Current.CancellationToken); + await Task.Delay(10, TestContext.Current!.Execution.CancellationToken); await That(isCalled).IsFalse(); } - [Fact] + [Test] public async Task AwaitableCallback_DisposeFromExecuteWhileWaiting_ShouldStopListening() { MockTimeSystem timeSystem = new(); @@ -65,11 +65,11 @@ public async Task AwaitableCallback_DisposeFromExecuteWhileWaiting_ShouldStopLis wait.Dispose(); timeSystem.Thread.Sleep(1); - await Task.Delay(10, TestContext.Current.CancellationToken); + await Task.Delay(10, TestContext.Current!.Execution.CancellationToken); await That(isCalled).IsFalse(); } - [Fact] + [Test] #if MarkExecuteWhileWaitingNotificationObsolete [Obsolete("TODO: Remove once the obsolete filter overload is removed from the public API.")] #endif @@ -85,19 +85,19 @@ public async Task AwaitableCallback_Filter_ShouldOnlyUpdateAfterFilteredValue() _ = Task.Run(async () => { - await Task.Delay(10, TestContext.Current.CancellationToken); + await Task.Delay(10, TestContext.Current!.Execution.CancellationToken); for (int i = 1; i <= 10; i++) { timeSystem.Thread.Sleep(i); - await Task.Delay(1, TestContext.Current.CancellationToken); + await Task.Delay(1, TestContext.Current!.Execution.CancellationToken); } - }, TestContext.Current.CancellationToken); + }, TestContext.Current!.Execution.CancellationToken); wait.Wait(t => t.TotalMilliseconds > 6); await That(receivedCount).IsGreaterThanOrEqualTo(6); } - [Fact] + [Test] public async Task AwaitableCallback_Predicate_ShouldOnlyUpdateAfterFilteredValue() { MockTimeSystem timeSystem = new(); @@ -113,11 +113,11 @@ public async Task AwaitableCallback_Predicate_ShouldOnlyUpdateAfterFilteredValue // ReSharper disable once AccessToDisposedClosure try { - await Task.Delay(10, TestContext.Current.CancellationToken); + await Task.Delay(10, TestContext.Current!.Execution.CancellationToken); for (int i = 1; i <= 10; i++) { timeSystem.Thread.Sleep(i); - await Task.Delay(1, TestContext.Current.CancellationToken); + await Task.Delay(1, TestContext.Current!.Execution.CancellationToken); } ms.Set(); @@ -126,13 +126,13 @@ public async Task AwaitableCallback_Predicate_ShouldOnlyUpdateAfterFilteredValue { // Ignore any ObjectDisposedException } - }, TestContext.Current.CancellationToken); + }, TestContext.Current!.Execution.CancellationToken); - ms.Wait(30000, TestContext.Current.CancellationToken); + ms.Wait(30000, TestContext.Current!.Execution.CancellationToken); await That(receivedCount).IsLessThanOrEqualTo(4); } - [Fact] + [Test] public async Task AwaitableCallback_ShouldWaitForCallbackExecution() { using ManualResetEventSlim ms = new(); @@ -154,14 +154,14 @@ public async Task AwaitableCallback_ShouldWaitForCallbackExecution() while (!ms.IsSet) { timeSystem.Thread.Sleep(1); - await Task.Delay(1, TestContext.Current.CancellationToken); + await Task.Delay(1, TestContext.Current!.Execution.CancellationToken); } } catch (ObjectDisposedException) { // Ignore any ObjectDisposedException } - }, TestContext.Current.CancellationToken); + }, TestContext.Current!.Execution.CancellationToken); wait.Wait(); await That(isCalled).IsTrue(); @@ -172,7 +172,7 @@ public async Task AwaitableCallback_ShouldWaitForCallbackExecution() } } - [Fact] + [Test] public async Task AwaitableCallback_TimeoutExpired_ShouldThrowTimeoutException() { MockTimeSystem timeSystem = new(); @@ -189,7 +189,7 @@ public async Task AwaitableCallback_TimeoutExpired_ShouldThrowTimeoutException() try { // Delay larger than timeout of 10ms - ms.Wait(TestContext.Current.CancellationToken); + ms.Wait(TestContext.Current!.Execution.CancellationToken); timeSystem.Thread.Sleep(1); } catch (ObjectDisposedException) @@ -208,7 +208,7 @@ public async Task AwaitableCallback_TimeoutExpired_ShouldThrowTimeoutException() ms.Set(); } - [Fact] + [Test] public async Task AwaitableCallback_Wait_AfterDispose_ShouldThrowObjectDisposedException() { @@ -227,7 +227,7 @@ await That(Act).ThrowsExactly() .WithMessage("The awaitable callback is already disposed."); } - [Fact] + [Test] public async Task AwaitableCallback_Wait_WithCount_AfterDispose_ShouldThrowObjectDisposedException() { @@ -246,7 +246,7 @@ await That(Act).ThrowsExactly() .WithMessage("The awaitable callback is already disposed."); } - [Fact] + [Test] public async Task AwaitableCallback_WaitedPreviously_ShouldWaitAgainForCallbackExecution() { int secondThreadMilliseconds = 42; @@ -269,7 +269,7 @@ public async Task AwaitableCallback_WaitedPreviously_ShouldWaitAgainForCallbackE // ReSharper disable once AccessToDisposedClosure try { - listening.Wait(1000, TestContext.Current.CancellationToken); + listening.Wait(1000, TestContext.Current!.Execution.CancellationToken); timeSystem.Thread.Sleep(firstThreadMilliseconds); } catch (ObjectDisposedException) @@ -286,7 +286,7 @@ public async Task AwaitableCallback_WaitedPreviously_ShouldWaitAgainForCallbackE // ReSharper disable once AccessToDisposedClosure try { - listening.Wait(1000, TestContext.Current.CancellationToken); + listening.Wait(1000, TestContext.Current!.Execution.CancellationToken); // ReSharper disable once AccessToDisposedClosure if (!ms.IsSet) { @@ -305,8 +305,8 @@ public async Task AwaitableCallback_WaitedPreviously_ShouldWaitAgainForCallbackE await That(isCalledFromSecondThread).IsTrue(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] #if MarkExecuteWhileWaitingNotificationObsolete [Obsolete("TODO: Remove once the obsolete ExecuteWhileWaiting method is removed from the public API.")] #endif @@ -334,8 +334,8 @@ public async Task Execute_ShouldBeExecutedBeforeWait(int milliseconds) await That(isExecuted).IsTrue(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] #if MarkExecuteWhileWaitingNotificationObsolete [Obsolete("TODO: Remove once the obsolete ExecuteWhileWaiting method is removed from the public API.")] #endif @@ -366,7 +366,7 @@ public async Task Execute_WithReturnValue_ShouldBeExecutedAndReturnValue( await That(isExecuted).IsTrue(); } - [Fact] + [Test] #if MarkExecuteWhileWaitingNotificationObsolete [Obsolete("TODO: Remove once the obsolete ExecuteWhileWaiting method is removed from the public API.")] #endif @@ -387,8 +387,8 @@ public async Task ExecuteWhileWaiting_ShouldExecuteCallback() await That(isExecuted).IsTrue(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] #if MarkExecuteWhileWaitingNotificationObsolete [Obsolete("TODO: Remove once the obsolete ExecuteWhileWaiting method is removed from the public API.")] #endif diff --git a/Tests/Testably.Abstractions.Testing.Tests/RandomProvider.GeneratorTests.cs b/Tests/Testably.Abstractions.Testing.Tests/RandomProvider.GeneratorTests.cs index ac472e519..f8ed1af63 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/RandomProvider.GeneratorTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/RandomProvider.GeneratorTests.cs @@ -8,7 +8,7 @@ public partial class RandomProviderTests { public class GeneratorTests { - [Fact] + [Test] public async Task Dispose_ShouldThrowObjectDisposedExceptionOnGetNext() { int maxRange = 100; @@ -26,8 +26,8 @@ public async Task Dispose_ShouldThrowObjectDisposedExceptionOnGetNext() await That(exception).IsExactly(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task FromArray_Overflow_ShouldStartAgain(Guid[] values) { RandomProvider.Generator sut = RandomProvider.Generator.FromArray(values); @@ -41,8 +41,8 @@ public async Task FromArray_Overflow_ShouldStartAgain(Guid[] values) await That(results).IsEqualTo([.. values, .. values]).InAnyOrder(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task FromArray_ShouldIterateThroughArrayValue(Guid[] values) { RandomProvider.Generator sut = RandomProvider.Generator.FromArray(values); @@ -56,7 +56,7 @@ public async Task FromArray_ShouldIterateThroughArrayValue(Guid[] values) await That(results).IsEqualTo(values).InAnyOrder(); } - [Fact] + [Test] public async Task FromCallback_ShouldExecuteCallback() { int iterations = 30; @@ -75,7 +75,7 @@ public async Task FromCallback_ShouldExecuteCallback() await That(results).IsEqualTo(Enumerable.Range(startValue, iterations)).InAnyOrder(); } - [Fact] + [Test] public async Task FromEnumerable_Dispose_ShouldDisposeEnumerator() { EnumerableMock enumerable = new(); @@ -87,7 +87,7 @@ public async Task FromEnumerable_Dispose_ShouldDisposeEnumerator() await That(enumerable.Enumerator.IsDisposed).IsTrue(); } - [Fact] + [Test] public async Task FromEnumerable_Overflow_List_ShouldResetEnumerator() { int maxRange = 100; @@ -106,7 +106,7 @@ public async Task FromEnumerable_Overflow_List_ShouldResetEnumerator() await That(results).IsEqualTo([.. values, .. values]).InAnyOrder(); } - [Fact] + [Test] public async Task FromEnumerable_Overflow_ShouldResetEnumerator() { int maxRange = 100; @@ -128,7 +128,7 @@ public async Task FromEnumerable_Overflow_ShouldResetEnumerator() await That(exception).IsExactly(); } - [Fact] + [Test] public async Task FromEnumerable_ShouldReturnEnumerableValues() { int maxRange = 100; @@ -145,8 +145,8 @@ public async Task FromEnumerable_ShouldReturnEnumerableValues() await That(results).IsEqualTo(Enumerable.Range(0, maxRange)).InAnyOrder(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task FromValue_ShouldReturnFixedValue(Guid value) { int maxRange = 100; @@ -161,8 +161,8 @@ public async Task FromValue_ShouldReturnFixedValue(Guid value) await That(results).All().AreEquivalentTo(value); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Operator_FromArray(Guid[] values) { RandomProvider.Generator sut = values; @@ -176,8 +176,8 @@ public async Task Operator_FromArray(Guid[] values) await That(results).IsEqualTo(values).InAnyOrder(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Operator_FromCallback(Guid value) { int maxRange = 100; @@ -194,8 +194,8 @@ public async Task Operator_FromCallback(Guid value) await That(results).All().AreEquivalentTo(value); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Operator_FromValue(Guid value) { int maxRange = 100; diff --git a/Tests/Testably.Abstractions.Testing.Tests/RandomProviderTests.cs b/Tests/Testably.Abstractions.Testing.Tests/RandomProviderTests.cs index b44f554ba..7649408ac 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/RandomProviderTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/RandomProviderTests.cs @@ -7,7 +7,7 @@ namespace Testably.Abstractions.Testing.Tests; public partial class RandomProviderTests { - [Fact] + [Test] public async Task Default_ShouldReturnRandomGuid() { List results = []; @@ -22,7 +22,7 @@ public async Task Default_ShouldReturnRandomGuid() await That(results).AreAllUnique(); } - [Fact] + [Test] public async Task Default_ShouldReturnRandomNumbers() { List results = []; @@ -37,8 +37,8 @@ public async Task Default_ShouldReturnRandomNumbers() await That(results).AreAllUnique(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GenerateGuid_ShouldReturnSpecifiedGuid(Guid guid) { List results = []; @@ -53,8 +53,8 @@ public async Task GenerateGuid_ShouldReturnSpecifiedGuid(Guid guid) await That(results).All().AreEqualTo(guid); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GenerateGuid_ShouldReturnSpecifiedGuids(Guid[] guids) { List results = []; @@ -69,8 +69,8 @@ public async Task GenerateGuid_ShouldReturnSpecifiedGuids(Guid[] guids) await That(results).Contains(guids).IgnoringInterspersedItems(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GenerateRandom_Next_ShouldReturnSpecifiedValue(int seed, int value) { List results = []; @@ -86,8 +86,8 @@ public async Task GenerateRandom_Next_ShouldReturnSpecifiedValue(int seed, int v await That(results).All().AreEqualTo(value); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GenerateRandom_Next_ShouldReturnSpecifiedValues(int seed, int[] values) { List results = []; @@ -103,8 +103,8 @@ public async Task GenerateRandom_Next_ShouldReturnSpecifiedValues(int seed, int[ await That(results).Contains(values).IgnoringInterspersedItems(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GenerateRandom_Next_WithMaxValue_ShouldReturnSpecifiedValue( int seed, int value) { @@ -123,8 +123,8 @@ public async Task GenerateRandom_Next_WithMaxValue_ShouldReturnSpecifiedValue( await That(results).All().AreEqualTo(expectedValue); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GenerateRandom_Next_WithMinAndMaxValue_Larger_ShouldReturnSpecifiedValue( int seed, int value) { @@ -144,8 +144,8 @@ public async Task GenerateRandom_Next_WithMinAndMaxValue_Larger_ShouldReturnSpec await That(results).All().AreEqualTo(expectedValue); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GenerateRandom_Next_WithMinAndMaxValue_Smaller_ShouldReturnSpecifiedValue( int seed, int value) { @@ -164,8 +164,8 @@ public async Task GenerateRandom_Next_WithMinAndMaxValue_Smaller_ShouldReturnSpe await That(results).All().AreEqualTo(minValue); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GenerateRandom_Next_WithoutGenerator_ShouldReturnRandomValues(int seed) { List results = []; @@ -181,8 +181,8 @@ public async Task GenerateRandom_Next_WithoutGenerator_ShouldReturnRandomValues( await That(results).AreAllUnique(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GenerateRandom_NextBytes_ShouldReturnSpecifiedValue( int seed, byte[] value) { @@ -202,8 +202,8 @@ public async Task GenerateRandom_NextBytes_ShouldReturnSpecifiedValue( } #if FEATURE_SPAN - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GenerateRandom_NextBytes_Span_ShouldReturnSpecifiedValue( int seed, byte[] value) { @@ -224,8 +224,8 @@ public async Task GenerateRandom_NextBytes_Span_ShouldReturnSpecifiedValue( #endif #if FEATURE_SPAN - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GenerateRandom_NextBytes_Span_WithoutGenerator_ShouldReturnRandomValues( int seed) { @@ -246,8 +246,8 @@ public async Task GenerateRandom_NextBytes_Span_WithoutGenerator_ShouldReturnRan #endif #if FEATURE_SPAN - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GenerateRandom_NextBytes_Span_WithSmallerBuffer_ShouldReturnPartlyInitializedBytes( int seed, byte[] value) { @@ -271,8 +271,8 @@ public async Task GenerateRandom_NextBytes_Span_WithSmallerBuffer_ShouldReturnPa } #endif - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GenerateRandom_NextBytes_WithoutGenerator_ShouldReturnRandomValues( int seed) { @@ -291,8 +291,8 @@ public async Task GenerateRandom_NextBytes_WithoutGenerator_ShouldReturnRandomVa await That(results).AreAllUnique(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GenerateRandom_NextBytes_WithSmallerBuffer_ShouldReturnPartlyInitializedBytes( int seed, byte[] value) { @@ -316,8 +316,8 @@ public async Task GenerateRandom_NextBytes_WithSmallerBuffer_ShouldReturnPartlyI await That(results).All().ComplyWith(v => v.IsEqualTo(expected)); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GenerateRandom_NextDouble_ShouldReturnSpecifiedValue( int seed, double value) { @@ -334,8 +334,8 @@ public async Task GenerateRandom_NextDouble_ShouldReturnSpecifiedValue( await That(results).All().AreEqualTo(value); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GenerateRandom_NextDouble_WithoutGenerator_ShouldReturnRandomValues( int seed) { @@ -353,8 +353,8 @@ public async Task GenerateRandom_NextDouble_WithoutGenerator_ShouldReturnRandomV } #if FEATURE_RANDOM_ADVANCED - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GenerateRandom_NextInt64_ShouldReturnSpecifiedValue(int seed, long value) { List results = []; @@ -372,8 +372,8 @@ public async Task GenerateRandom_NextInt64_ShouldReturnSpecifiedValue(int seed, #endif #if FEATURE_RANDOM_ADVANCED - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GenerateRandom_NextInt64_WithMaxValue_ShouldReturnSpecifiedValue( int seed, long value) { @@ -394,8 +394,8 @@ public async Task GenerateRandom_NextInt64_WithMaxValue_ShouldReturnSpecifiedVal #endif #if FEATURE_RANDOM_ADVANCED - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GenerateRandom_NextInt64_WithMinAndMaxValue_Larger_ShouldReturnSpecifiedValue( int seed, long value) { @@ -417,8 +417,8 @@ public async Task GenerateRandom_NextInt64_WithMinAndMaxValue_Larger_ShouldRetur #endif #if FEATURE_RANDOM_ADVANCED - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GenerateRandom_NextInt64_WithMinAndMaxValue_Smaller_ShouldReturnSpecifiedValue( int seed, long value) { @@ -440,8 +440,8 @@ public async Task GenerateRandom_NextInt64_WithMinAndMaxValue_Smaller_ShouldRetu #endif #if FEATURE_RANDOM_ADVANCED - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GenerateRandom_NextInt64_WithoutGenerator_ShouldReturnRandomValues( int seed) { @@ -460,8 +460,8 @@ public async Task GenerateRandom_NextInt64_WithoutGenerator_ShouldReturnRandomVa #endif #if FEATURE_RANDOM_ADVANCED - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GenerateRandom_NextSingle_ShouldReturnSpecifiedValue( int seed, float value) { @@ -480,8 +480,8 @@ public async Task GenerateRandom_NextSingle_ShouldReturnSpecifiedValue( #endif #if FEATURE_RANDOM_ADVANCED - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GenerateRandom_NextSingle_WithoutGenerator_ShouldReturnRandomValues( int seed) { @@ -499,7 +499,7 @@ public async Task GenerateRandom_NextSingle_WithoutGenerator_ShouldReturnRandomV } #endif - [Fact] + [Test] public async Task GetRandom_DefaultValue_ShouldReturnSharedRandom() { RandomProviderMock randomProvider = new(); @@ -516,8 +516,8 @@ public async Task GetRandom_DefaultValue_ShouldReturnSharedRandom() await That(result1).IsNotEqualTo(result2).InAnyOrder(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetRandom_FixedSeed_ShouldReturnSeparateRandomInstances(int seed) { RandomProviderMock randomProvider = new(); @@ -535,8 +535,8 @@ public async Task GetRandom_FixedSeed_ShouldReturnSeparateRandomInstances(int se } #if FEATURE_SPAN - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task NextBytes_Span_WithoutByteGenerator_ShouldUseRealRandomValuesFromSeed( int seed) { @@ -552,8 +552,8 @@ public async Task NextBytes_Span_WithoutByteGenerator_ShouldUseRealRandomValuesF } #endif - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task NextBytes_WithoutByteGenerator_ShouldUseRealRandomValuesFromSeed( int seed) { diff --git a/Tests/Testably.Abstractions.Testing.Tests/RandomSystem/RandomSystemExtensibilityTests.cs b/Tests/Testably.Abstractions.Testing.Tests/RandomSystem/RandomSystemExtensibilityTests.cs index 0dea7dc3d..504dba40f 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/RandomSystem/RandomSystemExtensibilityTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/RandomSystem/RandomSystemExtensibilityTests.cs @@ -1,22 +1,18 @@ +using System.Collections.Generic; using Testably.Abstractions.RandomSystem; namespace Testably.Abstractions.Testing.Tests.RandomSystem; public class RandomSystemExtensibilityTests { - #region Test Setup - - public static TheoryData GetRandomSystems - => new() - { - (IRandomSystem)new RealRandomSystem(), - (IRandomSystem)new MockRandomSystem(), - }; - - #endregion + public static IEnumerable> GetRandomSystems() + { + yield return () => new RealRandomSystem(); + yield return () => new MockRandomSystem(); + } - [Theory] - [MemberData(nameof(GetRandomSystems))] + [Test] + [MethodDataSource(nameof(GetRandomSystems))] public async Task Guid_ShouldSetExtensionPoint(IRandomSystem randomSystem) { IGuid sut = randomSystem.Guid; @@ -26,8 +22,8 @@ public async Task Guid_ShouldSetExtensionPoint(IRandomSystem randomSystem) await That(result).IsEqualTo(randomSystem); } - [Theory] - [MemberData(nameof(GetRandomSystems))] + [Test] + [MethodDataSource(nameof(GetRandomSystems))] public async Task RandomFactory_ShouldSetExtensionPoint(IRandomSystem randomSystem) { IRandomFactory sut = randomSystem.Random; diff --git a/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/DirectoryInfoFactoryStatisticsTests.cs b/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/DirectoryInfoFactoryStatisticsTests.cs index c9c2805b7..4f5e65938 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/DirectoryInfoFactoryStatisticsTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/DirectoryInfoFactoryStatisticsTests.cs @@ -6,7 +6,7 @@ namespace Testably.Abstractions.Testing.Tests.Statistics.FileSystem; public sealed class DirectoryInfoFactoryStatisticsTests { - [Fact] + [Test] public async Task Method_New_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -20,7 +20,7 @@ await That(sut.Statistics.DirectoryInfo).OnlyContainsMethodCall( path); } - [Fact] + [Test] public async Task Method_Wrap_DirectoryInfo_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -34,7 +34,7 @@ await That(sut.Statistics.DirectoryInfo).OnlyContainsMethodCall( directoryInfo); } - [Fact] + [Test] public async Task ToString_ShouldBeDirectoryInfo() { IPathStatistics sut diff --git a/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/DirectoryInfoStatisticsTests.cs b/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/DirectoryInfoStatisticsTests.cs index 6bb94e644..8cc1b6f5e 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/DirectoryInfoStatisticsTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/DirectoryInfoStatisticsTests.cs @@ -6,7 +6,7 @@ namespace Testably.Abstractions.Testing.Tests.Statistics.FileSystem; public sealed class DirectoryInfoStatisticsTests { - [Fact] + [Test] public async Task Method_Create_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -19,7 +19,7 @@ await That(sut.Statistics.DirectoryInfo["foo"]) } #if FEATURE_FILESYSTEM_LINK - [Fact] + [Test] public async Task Method_CreateAsSymbolicLink_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -34,7 +34,7 @@ await That(sut.Statistics.DirectoryInfo["foo"]) } #endif - [Fact] + [Test] public async Task Method_CreateSubdirectory_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -48,7 +48,7 @@ await That(sut.Statistics.DirectoryInfo["foo"]) path); } - [Fact] + [Test] public async Task Method_Delete_Bool_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -63,7 +63,7 @@ await That(sut.Statistics.DirectoryInfo["foo"]) recursive); } - [Fact] + [Test] public async Task Method_Delete_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -76,7 +76,7 @@ await That(sut.Statistics.DirectoryInfo["foo"]) .OnlyContainsMethodCall(nameof(IDirectoryInfo.Delete)); } - [Fact] + [Test] public async Task Method_EnumerateDirectories_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -90,7 +90,7 @@ await That(sut.Statistics.DirectoryInfo["foo"]) } #if FEATURE_FILESYSTEM_ENUMERATION_OPTIONS - [Fact] + [Test] public async Task Method_EnumerateDirectories_String_EnumerationOptions_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -107,7 +107,7 @@ await That(sut.Statistics.DirectoryInfo["foo"]) } #endif - [Fact] + [Test] public async Task Method_EnumerateDirectories_String_SearchOption_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -123,7 +123,7 @@ await That(sut.Statistics.DirectoryInfo["foo"]) searchPattern, searchOption); } - [Fact] + [Test] public async Task Method_EnumerateDirectories_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -138,7 +138,7 @@ await That(sut.Statistics.DirectoryInfo["foo"]) searchPattern); } - [Fact] + [Test] public async Task Method_EnumerateFiles_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -152,7 +152,7 @@ await That(sut.Statistics.DirectoryInfo["foo"]) } #if FEATURE_FILESYSTEM_ENUMERATION_OPTIONS - [Fact] + [Test] public async Task Method_EnumerateFiles_String_EnumerationOptions_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -169,7 +169,7 @@ await That(sut.Statistics.DirectoryInfo["foo"]) } #endif - [Fact] + [Test] public async Task Method_EnumerateFiles_String_SearchOption_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -185,7 +185,7 @@ await That(sut.Statistics.DirectoryInfo["foo"]) searchPattern, searchOption); } - [Fact] + [Test] public async Task Method_EnumerateFiles_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -200,7 +200,7 @@ await That(sut.Statistics.DirectoryInfo["foo"]) searchPattern); } - [Fact] + [Test] public async Task Method_EnumerateFileSystemInfos_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -214,7 +214,7 @@ await That(sut.Statistics.DirectoryInfo["foo"]) } #if FEATURE_FILESYSTEM_ENUMERATION_OPTIONS - [Fact] + [Test] public async Task Method_EnumerateFileSystemInfos_String_EnumerationOptions_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -231,7 +231,7 @@ await That(sut.Statistics.DirectoryInfo["foo"]) } #endif - [Fact] + [Test] public async Task Method_EnumerateFileSystemInfos_String_SearchOption_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -247,7 +247,7 @@ await That(sut.Statistics.DirectoryInfo["foo"]) searchPattern, searchOption); } - [Fact] + [Test] public async Task Method_EnumerateFileSystemInfos_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -262,7 +262,7 @@ await That(sut.Statistics.DirectoryInfo["foo"]) searchPattern); } - [Fact] + [Test] public async Task Method_GetDirectories_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -276,7 +276,7 @@ await That(sut.Statistics.DirectoryInfo["foo"]) } #if FEATURE_FILESYSTEM_ENUMERATION_OPTIONS - [Fact] + [Test] public async Task Method_GetDirectories_String_EnumerationOptions_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -293,7 +293,7 @@ await That(sut.Statistics.DirectoryInfo["foo"]) } #endif - [Fact] + [Test] public async Task Method_GetDirectories_String_SearchOption_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -309,7 +309,7 @@ await That(sut.Statistics.DirectoryInfo["foo"]) searchPattern, searchOption); } - [Fact] + [Test] public async Task Method_GetDirectories_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -324,7 +324,7 @@ await That(sut.Statistics.DirectoryInfo["foo"]) searchPattern); } - [Fact] + [Test] public async Task Method_GetFiles_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -338,7 +338,7 @@ await That(sut.Statistics.DirectoryInfo["foo"]) } #if FEATURE_FILESYSTEM_ENUMERATION_OPTIONS - [Fact] + [Test] public async Task Method_GetFiles_String_EnumerationOptions_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -355,7 +355,7 @@ await That(sut.Statistics.DirectoryInfo["foo"]) } #endif - [Fact] + [Test] public async Task Method_GetFiles_String_SearchOption_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -371,7 +371,7 @@ await That(sut.Statistics.DirectoryInfo["foo"]) searchPattern, searchOption); } - [Fact] + [Test] public async Task Method_GetFiles_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -386,7 +386,7 @@ await That(sut.Statistics.DirectoryInfo["foo"]) searchPattern); } - [Fact] + [Test] public async Task Method_GetFileSystemInfos_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -400,7 +400,7 @@ await That(sut.Statistics.DirectoryInfo["foo"]) } #if FEATURE_FILESYSTEM_ENUMERATION_OPTIONS - [Fact] + [Test] public async Task Method_GetFileSystemInfos_String_EnumerationOptions_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -417,7 +417,7 @@ await That(sut.Statistics.DirectoryInfo["foo"]) } #endif - [Fact] + [Test] public async Task Method_GetFileSystemInfos_String_SearchOption_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -433,7 +433,7 @@ await That(sut.Statistics.DirectoryInfo["foo"]) searchPattern, searchOption); } - [Fact] + [Test] public async Task Method_GetFileSystemInfos_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -448,7 +448,7 @@ await That(sut.Statistics.DirectoryInfo["foo"]) searchPattern); } - [Fact] + [Test] public async Task Method_MoveTo_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -463,7 +463,7 @@ await That(sut.Statistics.DirectoryInfo["foo"]) destDirName); } - [Fact] + [Test] public async Task Method_Refresh_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -476,7 +476,7 @@ await That(sut.Statistics.DirectoryInfo["foo"]) } #if FEATURE_FILESYSTEM_LINK - [Fact] + [Test] public async Task Method_ResolveLinkTarget_Bool_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -490,7 +490,7 @@ await That(sut.Statistics.DirectoryInfo["foo"]) returnFinalTarget); } #endif - [Fact] + [Test] public async Task Property_Attributes_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -503,7 +503,7 @@ await That(sut.Statistics.DirectoryInfo["foo"]) .OnlyContainsPropertyGetAccess(nameof(IDirectoryInfo.Attributes)); } - [Fact] + [Test] public async Task Property_Attributes_Set_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -517,7 +517,7 @@ await That(sut.Statistics.DirectoryInfo["foo"]) .OnlyContainsPropertySetAccess(nameof(IDirectoryInfo.Attributes)); } - [Fact] + [Test] public async Task Property_CreationTime_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -530,7 +530,7 @@ await That(sut.Statistics.DirectoryInfo["foo"]) .OnlyContainsPropertyGetAccess(nameof(IDirectoryInfo.CreationTime)); } - [Fact] + [Test] public async Task Property_CreationTime_Set_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -544,7 +544,7 @@ await That(sut.Statistics.DirectoryInfo["foo"]) .OnlyContainsPropertySetAccess(nameof(IDirectoryInfo.CreationTime)); } - [Fact] + [Test] public async Task Property_CreationTimeUtc_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -557,7 +557,7 @@ await That(sut.Statistics.DirectoryInfo["foo"]) .OnlyContainsPropertyGetAccess(nameof(IDirectoryInfo.CreationTimeUtc)); } - [Fact] + [Test] public async Task Property_CreationTimeUtc_Set_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -571,7 +571,7 @@ await That(sut.Statistics.DirectoryInfo["foo"]) .OnlyContainsPropertySetAccess(nameof(IDirectoryInfo.CreationTimeUtc)); } - [Fact] + [Test] public async Task Property_Exists_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -584,7 +584,7 @@ await That(sut.Statistics.DirectoryInfo["foo"]) .OnlyContainsPropertyGetAccess(nameof(IDirectoryInfo.Exists)); } - [Fact] + [Test] public async Task Property_Extension_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -597,7 +597,7 @@ await That(sut.Statistics.DirectoryInfo["foo"]) .OnlyContainsPropertyGetAccess(nameof(IDirectoryInfo.Extension)); } - [Fact] + [Test] public async Task Property_FullName_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -610,7 +610,7 @@ await That(sut.Statistics.DirectoryInfo["foo"]) .OnlyContainsPropertyGetAccess(nameof(IDirectoryInfo.FullName)); } - [Fact] + [Test] public async Task Property_LastAccessTime_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -623,7 +623,7 @@ await That(sut.Statistics.DirectoryInfo["foo"]) .OnlyContainsPropertyGetAccess(nameof(IDirectoryInfo.LastAccessTime)); } - [Fact] + [Test] public async Task Property_LastAccessTime_Set_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -637,7 +637,7 @@ await That(sut.Statistics.DirectoryInfo["foo"]) .OnlyContainsPropertySetAccess(nameof(IDirectoryInfo.LastAccessTime)); } - [Fact] + [Test] public async Task Property_LastAccessTimeUtc_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -650,7 +650,7 @@ await That(sut.Statistics.DirectoryInfo["foo"]) .OnlyContainsPropertyGetAccess(nameof(IDirectoryInfo.LastAccessTimeUtc)); } - [Fact] + [Test] public async Task Property_LastAccessTimeUtc_Set_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -664,7 +664,7 @@ await That(sut.Statistics.DirectoryInfo["foo"]) .OnlyContainsPropertySetAccess(nameof(IDirectoryInfo.LastAccessTimeUtc)); } - [Fact] + [Test] public async Task Property_LastWriteTime_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -677,7 +677,7 @@ await That(sut.Statistics.DirectoryInfo["foo"]) .OnlyContainsPropertyGetAccess(nameof(IDirectoryInfo.LastWriteTime)); } - [Fact] + [Test] public async Task Property_LastWriteTime_Set_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -691,7 +691,7 @@ await That(sut.Statistics.DirectoryInfo["foo"]) .OnlyContainsPropertySetAccess(nameof(IDirectoryInfo.LastWriteTime)); } - [Fact] + [Test] public async Task Property_LastWriteTimeUtc_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -704,7 +704,7 @@ await That(sut.Statistics.DirectoryInfo["foo"]) .OnlyContainsPropertyGetAccess(nameof(IDirectoryInfo.LastWriteTimeUtc)); } - [Fact] + [Test] public async Task Property_LastWriteTimeUtc_Set_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -719,7 +719,7 @@ await That(sut.Statistics.DirectoryInfo["foo"]) } #if FEATURE_FILESYSTEM_LINK - [Fact] + [Test] public async Task Property_LinkTarget_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -733,7 +733,7 @@ await That(sut.Statistics.DirectoryInfo["foo"]) } #endif - [Fact] + [Test] public async Task Property_Name_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -746,7 +746,7 @@ await That(sut.Statistics.DirectoryInfo["foo"]) .OnlyContainsPropertyGetAccess(nameof(IDirectoryInfo.Name)); } - [Fact] + [Test] public async Task Property_Parent_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -759,7 +759,7 @@ await That(sut.Statistics.DirectoryInfo["foo"]) .OnlyContainsPropertyGetAccess(nameof(IDirectoryInfo.Parent)); } - [Fact] + [Test] public async Task Property_Root_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -773,7 +773,7 @@ await That(sut.Statistics.DirectoryInfo["foo"]) } #if FEATURE_FILESYSTEM_UNIXFILEMODE - [Fact] + [Test] public async Task Property_UnixFileMode_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -788,7 +788,7 @@ await That(sut.Statistics.DirectoryInfo["foo"]) #endif #if FEATURE_FILESYSTEM_UNIXFILEMODE - [Fact] + [Test] public async Task Property_UnixFileMode_Set_ShouldRegisterPropertyAccess() { Skip.If(Test.RunsOnWindows); @@ -807,7 +807,7 @@ await That(sut.Statistics.DirectoryInfo["foo"]) } #endif - [Fact] + [Test] public async Task ToString_ShouldBeDirectoryInfoWithPath() { IStatistics sut = new MockFileSystem().Statistics.DirectoryInfo[@"\\some\path"]; diff --git a/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/DirectoryStatisticsTests.cs b/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/DirectoryStatisticsTests.cs index a84f1fc7c..948ee221c 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/DirectoryStatisticsTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/DirectoryStatisticsTests.cs @@ -6,7 +6,7 @@ namespace Testably.Abstractions.Testing.Tests.Statistics.FileSystem; public sealed class DirectoryStatisticsTests { - [Fact] + [Test] public async Task Method_CreateDirectory_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -21,7 +21,7 @@ await That(sut.Statistics.Directory).OnlyContainsMethodCall( } #if FEATURE_FILESYSTEM_UNIXFILEMODE - [Fact] + [Test] public async Task Method_CreateDirectory_String_UnixFileMode_ShouldRegisterCall() { Skip.If(!Test.RunsOnLinux); @@ -39,7 +39,7 @@ await That(sut.Statistics.Directory).OnlyContainsMethodCall(nameof(IDirectory.Cr #endif #if FEATURE_FILESYSTEM_LINK - [Fact] + [Test] public async Task Method_CreateSymbolicLink_String_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -55,7 +55,7 @@ await That(sut.Statistics.Directory).OnlyContainsMethodCall(nameof(IDirectory.Cr #endif #if FEATURE_FILESYSTEM_NET_7_OR_GREATER - [Fact] + [Test] public async Task Method_CreateTempSubdirectory_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -70,7 +70,7 @@ await That(sut.Statistics.Directory).OnlyContainsMethodCall( } #endif - [Fact] + [Test] public async Task Method_Delete_String_Bool_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -85,7 +85,7 @@ await That(sut.Statistics.Directory).OnlyContainsMethodCall(nameof(IDirectory.De path, recursive); } - [Fact] + [Test] public async Task Method_Delete_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -99,7 +99,7 @@ await That(sut.Statistics.Directory).OnlyContainsMethodCall(nameof(IDirectory.De path); } - [Fact] + [Test] public async Task Method_EnumerateDirectories_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -115,7 +115,7 @@ await That(sut.Statistics.Directory).OnlyContainsMethodCall( } #if FEATURE_FILESYSTEM_ENUMERATION_OPTIONS - [Fact] + [Test] public async Task Method_EnumerateDirectories_String_String_EnumerationOptions_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -133,7 +133,7 @@ await That(sut.Statistics.Directory).OnlyContainsMethodCall( } #endif - [Fact] + [Test] public async Task Method_EnumerateDirectories_String_String_SearchOption_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -150,7 +150,7 @@ await That(sut.Statistics.Directory).OnlyContainsMethodCall( path, searchPattern, searchOption); } - [Fact] + [Test] public async Task Method_EnumerateDirectories_String_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -166,7 +166,7 @@ await That(sut.Statistics.Directory).OnlyContainsMethodCall( path, searchPattern); } - [Fact] + [Test] public async Task Method_EnumerateFiles_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -182,7 +182,7 @@ await That(sut.Statistics.Directory).OnlyContainsMethodCall( } #if FEATURE_FILESYSTEM_ENUMERATION_OPTIONS - [Fact] + [Test] public async Task Method_EnumerateFiles_String_String_EnumerationOptions_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -199,7 +199,7 @@ await That(sut.Statistics.Directory).OnlyContainsMethodCall(nameof(IDirectory.En } #endif - [Fact] + [Test] public async Task Method_EnumerateFiles_String_String_SearchOption_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -216,7 +216,7 @@ await That(sut.Statistics.Directory).OnlyContainsMethodCall( path, searchPattern, searchOption); } - [Fact] + [Test] public async Task Method_EnumerateFiles_String_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -232,7 +232,7 @@ await That(sut.Statistics.Directory).OnlyContainsMethodCall( path, searchPattern); } - [Fact] + [Test] public async Task Method_EnumerateFileSystemEntries_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -248,7 +248,7 @@ await That(sut.Statistics.Directory).OnlyContainsMethodCall( } #if FEATURE_FILESYSTEM_ENUMERATION_OPTIONS - [Fact] + [Test] public async Task Method_EnumerateFileSystemEntries_String_String_EnumerationOptions_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -266,7 +266,7 @@ await That(sut.Statistics.Directory).OnlyContainsMethodCall( } #endif - [Fact] + [Test] public async Task Method_EnumerateFileSystemEntries_String_String_SearchOption_ShouldRegisterCall() { @@ -284,7 +284,7 @@ await That(sut.Statistics.Directory).OnlyContainsMethodCall( path, searchPattern, searchOption); } - [Fact] + [Test] public async Task Method_EnumerateFileSystemEntries_String_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -300,7 +300,7 @@ await That(sut.Statistics.Directory).OnlyContainsMethodCall( path, searchPattern); } - [Fact] + [Test] public async Task Method_Exists_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -313,7 +313,7 @@ await That(sut.Statistics.Directory).OnlyContainsMethodCall(nameof(IDirectory.Ex path); } - [Fact] + [Test] public async Task Method_GetCreationTime_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -327,7 +327,7 @@ await That(sut.Statistics.Directory).OnlyContainsMethodCall( path); } - [Fact] + [Test] public async Task Method_GetCreationTimeUtc_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -341,7 +341,7 @@ await That(sut.Statistics.Directory).OnlyContainsMethodCall( path); } - [Fact] + [Test] public async Task Method_GetCurrentDirectory_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -353,7 +353,7 @@ await That(sut.Statistics.Directory).OnlyContainsMethodCall( nameof(IDirectory.GetCurrentDirectory)); } - [Fact] + [Test] public async Task Method_GetDirectories_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -369,7 +369,7 @@ await That(sut.Statistics.Directory).OnlyContainsMethodCall( } #if FEATURE_FILESYSTEM_ENUMERATION_OPTIONS - [Fact] + [Test] public async Task Method_GetDirectories_String_String_EnumerationOptions_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -386,7 +386,7 @@ await That(sut.Statistics.Directory).OnlyContainsMethodCall(nameof(IDirectory.Ge } #endif - [Fact] + [Test] public async Task Method_GetDirectories_String_String_SearchOption_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -403,7 +403,7 @@ await That(sut.Statistics.Directory).OnlyContainsMethodCall( path, searchPattern, searchOption); } - [Fact] + [Test] public async Task Method_GetDirectories_String_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -419,7 +419,7 @@ await That(sut.Statistics.Directory).OnlyContainsMethodCall( path, searchPattern); } - [Fact] + [Test] public async Task Method_GetDirectoryRoot_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -433,7 +433,7 @@ await That(sut.Statistics.Directory).OnlyContainsMethodCall( path); } - [Fact] + [Test] public async Task Method_GetFiles_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -448,7 +448,7 @@ await That(sut.Statistics.Directory).OnlyContainsMethodCall(nameof(IDirectory.Ge } #if FEATURE_FILESYSTEM_ENUMERATION_OPTIONS - [Fact] + [Test] public async Task Method_GetFiles_String_String_EnumerationOptions_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -465,7 +465,7 @@ await That(sut.Statistics.Directory).OnlyContainsMethodCall(nameof(IDirectory.Ge } #endif - [Fact] + [Test] public async Task Method_GetFiles_String_String_SearchOption_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -481,7 +481,7 @@ await That(sut.Statistics.Directory).OnlyContainsMethodCall(nameof(IDirectory.Ge path, searchPattern, searchOption); } - [Fact] + [Test] public async Task Method_GetFiles_String_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -496,7 +496,7 @@ await That(sut.Statistics.Directory).OnlyContainsMethodCall(nameof(IDirectory.Ge path, searchPattern); } - [Fact] + [Test] public async Task Method_GetFileSystemEntries_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -512,7 +512,7 @@ await That(sut.Statistics.Directory).OnlyContainsMethodCall( } #if FEATURE_FILESYSTEM_ENUMERATION_OPTIONS - [Fact] + [Test] public async Task Method_GetFileSystemEntries_String_String_EnumerationOptions_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -530,7 +530,7 @@ await That(sut.Statistics.Directory).OnlyContainsMethodCall( } #endif - [Fact] + [Test] public async Task Method_GetFileSystemEntries_String_String_SearchOption_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -547,7 +547,7 @@ await That(sut.Statistics.Directory).OnlyContainsMethodCall( path, searchPattern, searchOption); } - [Fact] + [Test] public async Task Method_GetFileSystemEntries_String_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -563,7 +563,7 @@ await That(sut.Statistics.Directory).OnlyContainsMethodCall( path, searchPattern); } - [Fact] + [Test] public async Task Method_GetLastAccessTime_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -577,7 +577,7 @@ await That(sut.Statistics.Directory).OnlyContainsMethodCall( path); } - [Fact] + [Test] public async Task Method_GetLastAccessTimeUtc_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -591,7 +591,7 @@ await That(sut.Statistics.Directory).OnlyContainsMethodCall( path); } - [Fact] + [Test] public async Task Method_GetLastWriteTime_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -605,7 +605,7 @@ await That(sut.Statistics.Directory).OnlyContainsMethodCall( path); } - [Fact] + [Test] public async Task Method_GetLastWriteTimeUtc_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -619,7 +619,7 @@ await That(sut.Statistics.Directory).OnlyContainsMethodCall( path); } - [Fact] + [Test] public async Task Method_GetLogicalDrives_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -631,7 +631,7 @@ await That(sut.Statistics.Directory) .OnlyContainsMethodCall(nameof(IDirectory.GetLogicalDrives)); } - [Fact] + [Test] public async Task Method_GetParent_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -644,7 +644,7 @@ await That(sut.Statistics.Directory).OnlyContainsMethodCall(nameof(IDirectory.Ge path); } - [Fact] + [Test] public async Task Method_Move_String_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -660,7 +660,7 @@ await That(sut.Statistics.Directory).OnlyContainsMethodCall(nameof(IDirectory.Mo } #if FEATURE_FILESYSTEM_LINK - [Fact] + [Test] public async Task Method_ResolveLinkTarget_String_Bool_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -675,7 +675,7 @@ await That(sut.Statistics.Directory).OnlyContainsMethodCall(nameof(IDirectory.Re } #endif - [Fact] + [Test] public async Task Method_SetCreationTime_String_DateTime_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -691,7 +691,7 @@ await That(sut.Statistics.Directory).OnlyContainsMethodCall( path, creationTime); } - [Fact] + [Test] public async Task Method_SetCreationTimeUtc_String_DateTime_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -707,7 +707,7 @@ await That(sut.Statistics.Directory).OnlyContainsMethodCall( path, creationTimeUtc); } - [Fact] + [Test] public async Task Method_SetCurrentDirectory_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -722,7 +722,7 @@ await That(sut.Statistics.Directory).OnlyContainsMethodCall( path); } - [Fact] + [Test] public async Task Method_SetLastAccessTime_String_DateTime_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -738,7 +738,7 @@ await That(sut.Statistics.Directory).OnlyContainsMethodCall( path, lastAccessTime); } - [Fact] + [Test] public async Task Method_SetLastAccessTimeUtc_String_DateTime_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -754,7 +754,7 @@ await That(sut.Statistics.Directory).OnlyContainsMethodCall( path, lastAccessTimeUtc); } - [Fact] + [Test] public async Task Method_SetLastWriteTime_String_DateTime_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -770,7 +770,7 @@ await That(sut.Statistics.Directory).OnlyContainsMethodCall( path, lastWriteTime); } - [Fact] + [Test] public async Task Method_SetLastWriteTimeUtc_String_DateTime_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -786,7 +786,7 @@ await That(sut.Statistics.Directory).OnlyContainsMethodCall( path, lastWriteTimeUtc); } - [Fact] + [Test] public async Task ToString_ShouldBeDirectory() { IStatistics sut = new MockFileSystem().Statistics.Directory; diff --git a/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/DriveInfoFactoryStatisticsTests.cs b/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/DriveInfoFactoryStatisticsTests.cs index 4ad49a678..7fc808204 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/DriveInfoFactoryStatisticsTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/DriveInfoFactoryStatisticsTests.cs @@ -6,7 +6,7 @@ namespace Testably.Abstractions.Testing.Tests.Statistics.FileSystem; public sealed class DriveInfoFactoryStatisticsTests { - [Fact] + [Test] public async Task Method_GetDrives_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -18,7 +18,7 @@ await That(sut.Statistics.DriveInfo) .OnlyContainsMethodCall(nameof(IDriveInfoFactory.GetDrives)); } - [Fact] + [Test] public async Task Method_New_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -31,7 +31,7 @@ await That(sut.Statistics.DriveInfo).OnlyContainsMethodCall(nameof(IDriveInfoFac driveName); } - [Fact] + [Test] public async Task Method_Wrap_DriveInfo_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -44,7 +44,7 @@ await That(sut.Statistics.DriveInfo).OnlyContainsMethodCall(nameof(IDriveInfoFac driveInfo); } - [Fact] + [Test] public async Task ToString_ShouldBeDriveInfo() { IPathStatistics sut diff --git a/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/DriveInfoStatisticsTests.cs b/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/DriveInfoStatisticsTests.cs index c3f9b56d2..593d1a311 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/DriveInfoStatisticsTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/DriveInfoStatisticsTests.cs @@ -5,7 +5,7 @@ namespace Testably.Abstractions.Testing.Tests.Statistics.FileSystem; public sealed class DriveInfoStatisticsTests { - [Fact] + [Test] public async Task Property_AvailableFreeSpace_Get_ShouldRegisterPropertyAccess() { Skip.IfNot(Test.RunsOnWindows); @@ -19,7 +19,7 @@ await That(sut.Statistics.DriveInfo["F:"]) .OnlyContainsPropertyGetAccess(nameof(IDriveInfo.AvailableFreeSpace)); } - [Fact] + [Test] public async Task Property_DriveFormat_Get_ShouldRegisterPropertyAccess() { Skip.IfNot(Test.RunsOnWindows); @@ -33,7 +33,7 @@ await That(sut.Statistics.DriveInfo["F:"]) .OnlyContainsPropertyGetAccess(nameof(IDriveInfo.DriveFormat)); } - [Fact] + [Test] public async Task Property_DriveType_Get_ShouldRegisterPropertyAccess() { Skip.IfNot(Test.RunsOnWindows); @@ -47,7 +47,7 @@ await That(sut.Statistics.DriveInfo["F:"]) .OnlyContainsPropertyGetAccess(nameof(IDriveInfo.DriveType)); } - [Fact] + [Test] public async Task Property_IsReady_Get_ShouldRegisterPropertyAccess() { Skip.IfNot(Test.RunsOnWindows); @@ -61,7 +61,7 @@ await That(sut.Statistics.DriveInfo["F:"]) .OnlyContainsPropertyGetAccess(nameof(IDriveInfo.IsReady)); } - [Fact] + [Test] public async Task Property_Name_Get_ShouldRegisterPropertyAccess() { Skip.IfNot(Test.RunsOnWindows); @@ -75,7 +75,7 @@ await That(sut.Statistics.DriveInfo["F:"]) .OnlyContainsPropertyGetAccess(nameof(IDriveInfo.Name)); } - [Fact] + [Test] public async Task Property_RootDirectory_Get_ShouldRegisterPropertyAccess() { Skip.IfNot(Test.RunsOnWindows); @@ -89,7 +89,7 @@ await That(sut.Statistics.DriveInfo["F:"]) .OnlyContainsPropertyGetAccess(nameof(IDriveInfo.RootDirectory)); } - [Fact] + [Test] public async Task Property_TotalFreeSpace_Get_ShouldRegisterPropertyAccess() { Skip.IfNot(Test.RunsOnWindows); @@ -103,7 +103,7 @@ await That(sut.Statistics.DriveInfo["F:"]) .OnlyContainsPropertyGetAccess(nameof(IDriveInfo.TotalFreeSpace)); } - [Fact] + [Test] public async Task Property_TotalSize_Get_ShouldRegisterPropertyAccess() { Skip.IfNot(Test.RunsOnWindows); @@ -117,7 +117,7 @@ await That(sut.Statistics.DriveInfo["F:"]) .OnlyContainsPropertyGetAccess(nameof(IDriveInfo.TotalSize)); } - [Fact] + [Test] public async Task Property_VolumeLabel_Get_ShouldRegisterPropertyAccess() { Skip.IfNot(Test.RunsOnWindows); @@ -131,7 +131,7 @@ await That(sut.Statistics.DriveInfo["F:"]) .OnlyContainsPropertyGetAccess(nameof(IDriveInfo.VolumeLabel)); } - [Fact] + [Test] public async Task Property_VolumeLabel_Set_ShouldRegisterPropertyAccess() { Skip.IfNot(Test.RunsOnWindows); @@ -148,7 +148,7 @@ await That(sut.Statistics.DriveInfo["F:"]) .OnlyContainsPropertySetAccess(nameof(IDriveInfo.VolumeLabel)); } - [Fact] + [Test] public async Task ToString_ShouldBeDriveInfoWithPath() { IStatistics sut = new MockFileSystem().Statistics.DriveInfo[@"x:"]; diff --git a/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/FileInfoFactoryStatisticsTests.cs b/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/FileInfoFactoryStatisticsTests.cs index 46b7da961..7739018bb 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/FileInfoFactoryStatisticsTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/FileInfoFactoryStatisticsTests.cs @@ -6,7 +6,7 @@ namespace Testably.Abstractions.Testing.Tests.Statistics.FileSystem; public class FileInfoFactoryStatisticsTests { - [Fact] + [Test] public async Task Method_New_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -19,7 +19,7 @@ await That(sut.Statistics.FileInfo).OnlyContainsMethodCall(nameof(IFileInfoFacto fileName); } - [Fact] + [Test] public async Task Method_Wrap_FileInfo_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -32,7 +32,7 @@ await That(sut.Statistics.FileInfo).OnlyContainsMethodCall(nameof(IFileInfoFacto fileInfo); } - [Fact] + [Test] public async Task ToString_ShouldBeFileInfo() { IPathStatistics sut diff --git a/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/FileInfoStatisticsTests.cs b/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/FileInfoStatisticsTests.cs index dd4f330ae..61a86d3f7 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/FileInfoStatisticsTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/FileInfoStatisticsTests.cs @@ -6,7 +6,7 @@ namespace Testably.Abstractions.Testing.Tests.Statistics.FileSystem; public class FileInfoStatisticsTests { - [Fact] + [Test] public async Task Method_AppendText_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -18,7 +18,7 @@ await That(sut.Statistics.FileInfo["foo"]) .OnlyContainsMethodCall(nameof(IFileInfo.AppendText)); } - [Fact] + [Test] public async Task Method_CopyTo_String_Bool_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -34,7 +34,7 @@ await That(sut.Statistics.FileInfo["foo"]) destFileName, overwrite); } - [Fact] + [Test] public async Task Method_CopyTo_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -49,7 +49,7 @@ await That(sut.Statistics.FileInfo["foo"]) destFileName); } - [Fact] + [Test] public async Task Method_Create_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -62,7 +62,7 @@ await That(sut.Statistics.FileInfo["foo"]) } #if FEATURE_FILESYSTEM_LINK - [Fact] + [Test] public async Task Method_CreateAsSymbolicLink_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -77,7 +77,7 @@ await That(sut.Statistics.FileInfo["foo"]) } #endif - [Fact] + [Test] public async Task Method_CreateText_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -89,7 +89,7 @@ await That(sut.Statistics.FileInfo["foo"]) .OnlyContainsMethodCall(nameof(IFileInfo.CreateText)); } - [Fact] + [Test] public async Task Method_Decrypt_ShouldRegisterCall() { Skip.If(!Test.RunsOnWindows); @@ -105,7 +105,7 @@ await That(sut.Statistics.FileInfo["foo"]) .OnlyContainsMethodCall(nameof(IFileInfo.Decrypt)); } - [Fact] + [Test] public async Task Method_Delete_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -118,7 +118,7 @@ await That(sut.Statistics.FileInfo["foo"]) .OnlyContainsMethodCall(nameof(IFileInfo.Delete)); } - [Fact] + [Test] public async Task Method_Encrypt_ShouldRegisterCall() { Skip.If(!Test.RunsOnWindows); @@ -135,7 +135,7 @@ await That(sut.Statistics.FileInfo["foo"]) } #if FEATURE_FILE_MOVETO_OVERWRITE - [Fact] + [Test] public async Task Method_MoveTo_String_Bool_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -152,7 +152,7 @@ await That(sut.Statistics.FileInfo["foo"]) } #endif - [Fact] + [Test] public async Task Method_MoveTo_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -167,7 +167,7 @@ await That(sut.Statistics.FileInfo["foo"]) destFileName); } - [Fact] + [Test] public async Task Method_Open_FileMode_FileAccess_FileShare_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -183,7 +183,7 @@ await That(sut.Statistics.FileInfo["foo"]) mode, access, share); } - [Fact] + [Test] public async Task Method_Open_FileMode_FileAccess_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -198,7 +198,7 @@ await That(sut.Statistics.FileInfo["foo"]) mode, access); } - [Fact] + [Test] public async Task Method_Open_FileMode_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -213,7 +213,7 @@ await That(sut.Statistics.FileInfo["foo"]) } #if FEATURE_FILESYSTEM_STREAM_OPTIONS - [Fact] + [Test] public async Task Method_Open_FileStreamOptions_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -229,7 +229,7 @@ await That(sut.Statistics.FileInfo["foo"]) } #endif - [Fact] + [Test] public async Task Method_OpenRead_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -242,7 +242,7 @@ await That(sut.Statistics.FileInfo["foo"]) .OnlyContainsMethodCall(nameof(IFileInfo.OpenRead)); } - [Fact] + [Test] public async Task Method_OpenText_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -255,7 +255,7 @@ await That(sut.Statistics.FileInfo["foo"]) .OnlyContainsMethodCall(nameof(IFileInfo.OpenText)); } - [Fact] + [Test] public async Task Method_OpenWrite_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -267,7 +267,7 @@ await That(sut.Statistics.FileInfo["foo"]) .OnlyContainsMethodCall(nameof(IFileInfo.OpenWrite)); } - [Fact] + [Test] public async Task Method_Refresh_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -279,7 +279,7 @@ await That(sut.Statistics.FileInfo["foo"]) .OnlyContainsMethodCall(nameof(IFileInfo.Refresh)); } - [Fact] + [Test] public async Task Method_Replace_String_String_Bool_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -297,7 +297,7 @@ await That(sut.Statistics.FileInfo["foo"]) destinationFileName, destinationBackupFileName, ignoreMetadataErrors); } - [Fact] + [Test] public async Task Method_Replace_String_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -314,7 +314,7 @@ await That(sut.Statistics.FileInfo["foo"]) } #if FEATURE_FILESYSTEM_LINK - [Fact] + [Test] public async Task Method_ResolveLinkTarget_Bool_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -330,7 +330,7 @@ await That(sut.Statistics.FileInfo["foo"]) } #endif - [Fact] + [Test] public async Task Property_Attributes_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -343,7 +343,7 @@ await That(sut.Statistics.FileInfo["foo"]) .OnlyContainsPropertyGetAccess(nameof(IFileInfo.Attributes)); } - [Fact] + [Test] public async Task Property_Attributes_Set_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -357,7 +357,7 @@ await That(sut.Statistics.FileInfo["foo"]) .OnlyContainsPropertySetAccess(nameof(IFileInfo.Attributes)); } - [Fact] + [Test] public async Task Property_CreationTime_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -370,7 +370,7 @@ await That(sut.Statistics.FileInfo["foo"]) .OnlyContainsPropertyGetAccess(nameof(IFileInfo.CreationTime)); } - [Fact] + [Test] public async Task Property_CreationTime_Set_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -384,7 +384,7 @@ await That(sut.Statistics.FileInfo["foo"]) .OnlyContainsPropertySetAccess(nameof(IFileInfo.CreationTime)); } - [Fact] + [Test] public async Task Property_CreationTimeUtc_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -397,7 +397,7 @@ await That(sut.Statistics.FileInfo["foo"]) .OnlyContainsPropertyGetAccess(nameof(IFileInfo.CreationTimeUtc)); } - [Fact] + [Test] public async Task Property_CreationTimeUtc_Set_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -411,7 +411,7 @@ await That(sut.Statistics.FileInfo["foo"]) .OnlyContainsPropertySetAccess(nameof(IFileInfo.CreationTimeUtc)); } - [Fact] + [Test] public async Task Property_Directory_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -424,7 +424,7 @@ await That(sut.Statistics.FileInfo["foo"]) .OnlyContainsPropertyGetAccess(nameof(IFileInfo.Directory)); } - [Fact] + [Test] public async Task Property_DirectoryName_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -437,7 +437,7 @@ await That(sut.Statistics.FileInfo["foo"]) .OnlyContainsPropertyGetAccess(nameof(IFileInfo.DirectoryName)); } - [Fact] + [Test] public async Task Property_Exists_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -450,7 +450,7 @@ await That(sut.Statistics.FileInfo["foo"]) .OnlyContainsPropertyGetAccess(nameof(IFileInfo.Exists)); } - [Fact] + [Test] public async Task Property_Extension_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -463,7 +463,7 @@ await That(sut.Statistics.FileInfo["foo"]) .OnlyContainsPropertyGetAccess(nameof(IFileInfo.Extension)); } - [Fact] + [Test] public async Task Property_FullName_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -476,7 +476,7 @@ await That(sut.Statistics.FileInfo["foo"]) .OnlyContainsPropertyGetAccess(nameof(IFileInfo.FullName)); } - [Fact] + [Test] public async Task Property_IsReadOnly_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -489,7 +489,7 @@ await That(sut.Statistics.FileInfo["foo"]) .OnlyContainsPropertyGetAccess(nameof(IFileInfo.IsReadOnly)); } - [Fact] + [Test] public async Task Property_IsReadOnly_Set_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -503,7 +503,7 @@ await That(sut.Statistics.FileInfo["foo"]) .OnlyContainsPropertySetAccess(nameof(IFileInfo.IsReadOnly)); } - [Fact] + [Test] public async Task Property_LastAccessTime_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -516,7 +516,7 @@ await That(sut.Statistics.FileInfo["foo"]) .OnlyContainsPropertyGetAccess(nameof(IFileInfo.LastAccessTime)); } - [Fact] + [Test] public async Task Property_LastAccessTime_Set_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -530,7 +530,7 @@ await That(sut.Statistics.FileInfo["foo"]) .OnlyContainsPropertySetAccess(nameof(IFileInfo.LastAccessTime)); } - [Fact] + [Test] public async Task Property_LastAccessTimeUtc_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -543,7 +543,7 @@ await That(sut.Statistics.FileInfo["foo"]) .OnlyContainsPropertyGetAccess(nameof(IFileInfo.LastAccessTimeUtc)); } - [Fact] + [Test] public async Task Property_LastAccessTimeUtc_Set_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -557,7 +557,7 @@ await That(sut.Statistics.FileInfo["foo"]) .OnlyContainsPropertySetAccess(nameof(IFileInfo.LastAccessTimeUtc)); } - [Fact] + [Test] public async Task Property_LastWriteTime_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -570,7 +570,7 @@ await That(sut.Statistics.FileInfo["foo"]) .OnlyContainsPropertyGetAccess(nameof(IFileInfo.LastWriteTime)); } - [Fact] + [Test] public async Task Property_LastWriteTime_Set_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -584,7 +584,7 @@ await That(sut.Statistics.FileInfo["foo"]) .OnlyContainsPropertySetAccess(nameof(IFileInfo.LastWriteTime)); } - [Fact] + [Test] public async Task Property_LastWriteTimeUtc_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -597,7 +597,7 @@ await That(sut.Statistics.FileInfo["foo"]) .OnlyContainsPropertyGetAccess(nameof(IFileInfo.LastWriteTimeUtc)); } - [Fact] + [Test] public async Task Property_LastWriteTimeUtc_Set_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -611,7 +611,7 @@ await That(sut.Statistics.FileInfo["foo"]) .OnlyContainsPropertySetAccess(nameof(IFileInfo.LastWriteTimeUtc)); } - [Fact] + [Test] public async Task Property_Length_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -625,7 +625,7 @@ await That(sut.Statistics.FileInfo["foo"]) } #if FEATURE_FILESYSTEM_LINK - [Fact] + [Test] public async Task Property_LinkTarget_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -639,7 +639,7 @@ await That(sut.Statistics.FileInfo["foo"]) } #endif - [Fact] + [Test] public async Task Property_Name_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -653,7 +653,7 @@ await That(sut.Statistics.FileInfo["foo"]) } #if FEATURE_FILESYSTEM_UNIXFILEMODE - [Fact] + [Test] public async Task Property_UnixFileMode_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -668,7 +668,7 @@ await That(sut.Statistics.FileInfo["foo"]) #endif #if FEATURE_FILESYSTEM_UNIXFILEMODE - [Fact] + [Test] public async Task Property_UnixFileMode_Set_ShouldRegisterPropertyAccess() { Skip.If(Test.RunsOnWindows); @@ -687,7 +687,7 @@ await That(sut.Statistics.FileInfo["foo"]) } #endif - [Fact] + [Test] public async Task ToString_ShouldBeFileInfoWithPath() { IStatistics sut = new MockFileSystem().Statistics.FileInfo[@"\\some\path"]; diff --git a/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/FileStatisticsTests.cs b/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/FileStatisticsTests.cs index 7b08c5bb2..3bc5812b1 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/FileStatisticsTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/FileStatisticsTests.cs @@ -18,7 +18,7 @@ namespace Testably.Abstractions.Testing.Tests.Statistics.FileSystem; public sealed class FileStatisticsTests { #if FEATURE_FILE_SPAN - [Fact] + [Test] public async Task Method_AppendAllBytes_String_ByteArray_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -33,7 +33,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.AppendAllByt #endif #if FEATURE_FILE_SPAN - [Fact] + [Test] public async Task Method_AppendAllBytes_String_ReadOnlySpanByte_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -48,7 +48,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.AppendAllByt #endif #if FEATURE_FILE_SPAN - [Fact] + [Test] public async Task Method_AppendAllBytesAsync_String_ByteArray_CancellationToken_ShouldRegisterCall() { @@ -65,7 +65,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.AppendAllByt #endif #if FEATURE_FILE_SPAN - [Fact] + [Test] public async Task Method_AppendAllBytesAsync_String_ReadOnlyMemoryByte_CancellationToken_ShouldRegisterCall() { @@ -81,7 +81,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.AppendAllByt } #endif - [Fact] + [Test] public async Task Method_AppendAllLines_String_IEnumerableString_Encoding_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -96,7 +96,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.AppendAllLin path, contents, encoding); } - [Fact] + [Test] public async Task Method_AppendAllLines_String_IEnumerableString_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -111,7 +111,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.AppendAllLin } #if FEATURE_FILESYSTEM_ASYNC - [Fact] + [Test] public async Task Method_AppendAllLinesAsync_String_IEnumerableString_CancellationToken_ShouldRegisterCall() { @@ -129,7 +129,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.AppendAllLin #endif #if FEATURE_FILESYSTEM_ASYNC - [Fact] + [Test] public async Task Method_AppendAllLinesAsync_String_IEnumerableString_Encoding_CancellationToken_ShouldRegisterCall() { @@ -148,7 +148,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.AppendAllLin #endif #if FEATURE_FILE_SPAN - [Fact] + [Test] public async Task Method_AppendAllText_String_ReadOnlySpanChar_Encoding_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -164,7 +164,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.AppendAllTex #endif #if FEATURE_FILE_SPAN - [Fact] + [Test] public async Task Method_AppendAllText_String_ReadOnlySpanChar_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -178,7 +178,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.AppendAllTex } #endif - [Fact] + [Test] public async Task Method_AppendAllText_String_String_Encoding_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -193,7 +193,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.AppendAllTex path, contents, encoding); } - [Fact] + [Test] public async Task Method_AppendAllText_String_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -208,7 +208,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.AppendAllTex } #if FEATURE_FILE_SPAN - [Fact] + [Test] public async Task Method_AppendAllTextAsync_String_ReadOnlyMemoryChar_CancellationToken_ShouldRegisterCall() { @@ -225,7 +225,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.AppendAllTex #endif #if FEATURE_FILE_SPAN - [Fact] + [Test] public async Task Method_AppendAllTextAsync_String_ReadOnlyMemoryChar_Encoding_CancellationToken_ShouldRegisterCall() { @@ -243,7 +243,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.AppendAllTex #endif #if FEATURE_FILESYSTEM_ASYNC - [Fact] + [Test] public async Task Method_AppendAllTextAsync_String_String_CancellationToken_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -260,7 +260,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.AppendAllTex #endif #if FEATURE_FILESYSTEM_ASYNC - [Fact] + [Test] public async Task Method_AppendAllTextAsync_String_String_Encoding_CancellationToken_ShouldRegisterCall() { @@ -278,7 +278,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.AppendAllTex } #endif - [Fact] + [Test] public async Task Method_AppendText_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -291,7 +291,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.AppendText), path); } - [Fact] + [Test] public async Task Method_Copy_String_String_Bool_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -307,7 +307,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.Copy), sourceFileName, destFileName, overwrite); } - [Fact] + [Test] public async Task Method_Copy_String_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -322,7 +322,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.Copy), sourceFileName, destFileName); } - [Fact] + [Test] public async Task Method_Create_String_Int_FileOptions_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -337,7 +337,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.Create), path, bufferSize, options); } - [Fact] + [Test] public async Task Method_Create_String_Int_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -351,7 +351,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.Create), path, bufferSize); } - [Fact] + [Test] public async Task Method_Create_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -365,7 +365,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.Create), } #if FEATURE_FILESYSTEM_LINK - [Fact] + [Test] public async Task Method_CreateSymbolicLink_String_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -380,7 +380,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.CreateSymbol } #endif - [Fact] + [Test] public async Task Method_CreateText_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -393,7 +393,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.CreateText), path); } - [Fact] + [Test] public async Task Method_Decrypt_String_ShouldRegisterCall() { Skip.If(!Test.RunsOnWindows); @@ -411,7 +411,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.Decrypt), path); } - [Fact] + [Test] public async Task Method_Delete_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -425,7 +425,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.Delete), path); } - [Fact] + [Test] public async Task Method_Encrypt_String_ShouldRegisterCall() { Skip.If(!Test.RunsOnWindows); @@ -443,7 +443,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.Encrypt), path); } - [Fact] + [Test] public async Task Method_Exists_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -457,7 +457,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.Exists), } #if FEATURE_FILESYSTEM_SAFEFILEHANDLE - [Fact] + [Test] public async Task Method_GetAttributes_SafeFileHandle_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -474,7 +474,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.GetAttribute } #endif - [Fact] + [Test] public async Task Method_GetAttributes_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -489,7 +489,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.GetAttribute } #if FEATURE_FILESYSTEM_SAFEFILEHANDLE - [Fact] + [Test] public async Task Method_GetCreationTime_SafeFileHandle_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -506,7 +506,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.GetCreationT } #endif - [Fact] + [Test] public async Task Method_GetCreationTime_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -521,7 +521,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.GetCreationT } #if FEATURE_FILESYSTEM_SAFEFILEHANDLE - [Fact] + [Test] public async Task Method_GetCreationTimeUtc_SafeFileHandle_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -538,7 +538,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.GetCreationT } #endif - [Fact] + [Test] public async Task Method_GetCreationTimeUtc_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -553,7 +553,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.GetCreationT } #if FEATURE_FILESYSTEM_SAFEFILEHANDLE - [Fact] + [Test] public async Task Method_GetLastAccessTime_SafeFileHandle_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -570,7 +570,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.GetLastAcces } #endif - [Fact] + [Test] public async Task Method_GetLastAccessTime_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -585,7 +585,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.GetLastAcces } #if FEATURE_FILESYSTEM_SAFEFILEHANDLE - [Fact] + [Test] public async Task Method_GetLastAccessTimeUtc_SafeFileHandle_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -602,7 +602,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.GetLastAcces } #endif - [Fact] + [Test] public async Task Method_GetLastAccessTimeUtc_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -617,7 +617,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.GetLastAcces } #if FEATURE_FILESYSTEM_SAFEFILEHANDLE - [Fact] + [Test] public async Task Method_GetLastWriteTime_SafeFileHandle_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -634,7 +634,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.GetLastWrite } #endif - [Fact] + [Test] public async Task Method_GetLastWriteTime_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -649,7 +649,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.GetLastWrite } #if FEATURE_FILESYSTEM_SAFEFILEHANDLE - [Fact] + [Test] public async Task Method_GetLastWriteTimeUtc_SafeFileHandle_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -666,7 +666,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.GetLastWrite } #endif - [Fact] + [Test] public async Task Method_GetLastWriteTimeUtc_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -681,7 +681,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.GetLastWrite } #if FEATURE_FILESYSTEM_SAFEFILEHANDLE - [Fact] + [Test] public async Task Method_GetUnixFileMode_SafeFileHandle_ShouldRegisterCall() { Skip.If(!Test.RunsOnLinux); @@ -703,7 +703,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.GetUnixFileM #endif #if FEATURE_FILESYSTEM_UNIXFILEMODE - [Fact] + [Test] public async Task Method_GetUnixFileMode_String_ShouldRegisterCall() { Skip.If(!Test.RunsOnLinux); @@ -723,7 +723,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.GetUnixFileM #endif #if FEATURE_FILE_MOVETO_OVERWRITE - [Fact] + [Test] public async Task Method_Move_String_String_Bool_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -740,7 +740,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.Move), } #endif - [Fact] + [Test] public async Task Method_Move_String_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -755,7 +755,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.Move), sourceFileName, destFileName); } - [Fact] + [Test] public async Task Method_Open_String_FileMode_FileAccess_FileShare_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -771,7 +771,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.Open), path, mode, access, share); } - [Fact] + [Test] public async Task Method_Open_String_FileMode_FileAccess_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -786,7 +786,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.Open), path, mode, access); } - [Fact] + [Test] public async Task Method_Open_String_FileMode_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -801,7 +801,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.Open), } #if FEATURE_FILESYSTEM_STREAM_OPTIONS - [Fact] + [Test] public async Task Method_Open_String_FileStreamOptions_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -817,7 +817,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.Open), } #endif - [Fact] + [Test] public async Task Method_OpenRead_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -831,7 +831,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.OpenRead), path); } - [Fact] + [Test] public async Task Method_OpenText_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -845,7 +845,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.OpenText), path); } - [Fact] + [Test] public async Task Method_OpenWrite_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -858,7 +858,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.OpenWrite), path); } - [Fact] + [Test] public async Task Method_ReadAllBytes_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -873,7 +873,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.ReadAllBytes } #if FEATURE_FILESYSTEM_ASYNC - [Fact] + [Test] public async Task Method_ReadAllBytesAsync_String_CancellationToken_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -889,7 +889,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.ReadAllBytes } #endif - [Fact] + [Test] public async Task Method_ReadAllLines_String_Encoding_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -904,7 +904,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.ReadAllLines path, encoding); } - [Fact] + [Test] public async Task Method_ReadAllLines_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -919,7 +919,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.ReadAllLines } #if FEATURE_FILESYSTEM_ASYNC - [Fact] + [Test] public async Task Method_ReadAllLinesAsync_String_CancellationToken_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -936,7 +936,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.ReadAllLines #endif #if FEATURE_FILESYSTEM_ASYNC - [Fact] + [Test] public async Task Method_ReadAllLinesAsync_String_Encoding_CancellationToken_ShouldRegisterCall() { @@ -954,7 +954,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.ReadAllLines } #endif - [Fact] + [Test] public async Task Method_ReadAllText_String_Encoding_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -969,7 +969,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.ReadAllText) path, encoding); } - [Fact] + [Test] public async Task Method_ReadAllText_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -984,7 +984,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.ReadAllText) } #if FEATURE_FILESYSTEM_ASYNC - [Fact] + [Test] public async Task Method_ReadAllTextAsync_String_CancellationToken_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -1001,7 +1001,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.ReadAllTextA #endif #if FEATURE_FILESYSTEM_ASYNC - [Fact] + [Test] public async Task Method_ReadAllTextAsync_String_Encoding_CancellationToken_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -1018,7 +1018,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.ReadAllTextA } #endif - [Fact] + [Test] public async Task Method_ReadLines_String_Encoding_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -1033,7 +1033,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.ReadLines), path, encoding); } - [Fact] + [Test] public async Task Method_ReadLines_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -1048,7 +1048,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.ReadLines), } #if FEATURE_FILESYSTEM_NET_7_OR_GREATER - [Fact] + [Test] public async Task Method_ReadLinesAsync_String_CancellationToken_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -1065,7 +1065,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.ReadLinesAsy #endif #if FEATURE_FILESYSTEM_NET_7_OR_GREATER - [Fact] + [Test] public async Task Method_ReadLinesAsync_String_Encoding_CancellationToken_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -1082,7 +1082,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.ReadLinesAsy } #endif - [Fact] + [Test] public async Task Method_Replace_String_String_String_Bool_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -1100,7 +1100,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.Replace), sourceFileName, destinationFileName, destinationBackupFileName, ignoreMetadataErrors); } - [Fact] + [Test] public async Task Method_Replace_String_String_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -1117,7 +1117,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.Replace), } #if FEATURE_FILESYSTEM_LINK - [Fact] + [Test] public async Task Method_ResolveLinkTarget_String_Bool_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -1134,7 +1134,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.ResolveLinkT #endif #if FEATURE_FILESYSTEM_SAFEFILEHANDLE - [Fact] + [Test] public async Task Method_SetAttributes_SafeFileHandle_FileAttributes_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -1152,7 +1152,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.SetAttribute } #endif - [Fact] + [Test] public async Task Method_SetAttributes_String_FileAttributes_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -1168,7 +1168,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.SetAttribute } #if FEATURE_FILESYSTEM_SAFEFILEHANDLE - [Fact] + [Test] public async Task Method_SetCreationTime_SafeFileHandle_DateTime_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -1186,7 +1186,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.SetCreationT } #endif - [Fact] + [Test] public async Task Method_SetCreationTime_String_DateTime_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -1202,7 +1202,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.SetCreationT } #if FEATURE_FILESYSTEM_SAFEFILEHANDLE - [Fact] + [Test] public async Task Method_SetCreationTimeUtc_SafeFileHandle_DateTime_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -1220,7 +1220,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.SetCreationT } #endif - [Fact] + [Test] public async Task Method_SetCreationTimeUtc_String_DateTime_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -1236,7 +1236,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.SetCreationT } #if FEATURE_FILESYSTEM_SAFEFILEHANDLE - [Fact] + [Test] public async Task Method_SetLastAccessTime_SafeFileHandle_DateTime_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -1254,7 +1254,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.SetLastAcces } #endif - [Fact] + [Test] public async Task Method_SetLastAccessTime_String_DateTime_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -1270,7 +1270,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.SetLastAcces } #if FEATURE_FILESYSTEM_SAFEFILEHANDLE - [Fact] + [Test] public async Task Method_SetLastAccessTimeUtc_SafeFileHandle_DateTime_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -1288,7 +1288,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.SetLastAcces } #endif - [Fact] + [Test] public async Task Method_SetLastAccessTimeUtc_String_DateTime_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -1304,7 +1304,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.SetLastAcces } #if FEATURE_FILESYSTEM_SAFEFILEHANDLE - [Fact] + [Test] public async Task Method_SetLastWriteTime_SafeFileHandle_DateTime_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -1322,7 +1322,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.SetLastWrite } #endif - [Fact] + [Test] public async Task Method_SetLastWriteTime_String_DateTime_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -1338,7 +1338,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.SetLastWrite } #if FEATURE_FILESYSTEM_SAFEFILEHANDLE - [Fact] + [Test] public async Task Method_SetLastWriteTimeUtc_SafeFileHandle_DateTime_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -1356,7 +1356,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.SetLastWrite } #endif - [Fact] + [Test] public async Task Method_SetLastWriteTimeUtc_String_DateTime_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -1372,7 +1372,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.SetLastWrite } #if FEATURE_FILESYSTEM_SAFEFILEHANDLE - [Fact] + [Test] public async Task Method_SetUnixFileMode_SafeFileHandle_UnixFileMode_ShouldRegisterCall() { Skip.If(!Test.RunsOnLinux); @@ -1395,7 +1395,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.SetUnixFileM #endif #if FEATURE_FILESYSTEM_UNIXFILEMODE - [Fact] + [Test] public async Task Method_SetUnixFileMode_String_UnixFileMode_ShouldRegisterCall() { Skip.If(!Test.RunsOnLinux); @@ -1415,7 +1415,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.SetUnixFileM } #endif - [Fact] + [Test] public async Task Method_WriteAllBytes_String_ByteArray_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -1430,7 +1430,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.WriteAllByte } #if FEATURE_FILE_SPAN - [Fact] + [Test] public async Task Method_WriteAllBytes_String_ReadOnlySpanByte_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -1445,7 +1445,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.WriteAllByte #endif #if FEATURE_FILESYSTEM_ASYNC - [Fact] + [Test] public async Task Method_WriteAllBytesAsync_String_ByteArray_CancellationToken_ShouldRegisterCall() { @@ -1463,7 +1463,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.WriteAllByte #endif #if FEATURE_FILE_SPAN - [Fact] + [Test] public async Task Method_WriteAllBytesAsync_String_ReadOnlyMemoryByte_CancellationToken_ShouldRegisterCall() { @@ -1479,7 +1479,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.WriteAllByte } #endif - [Fact] + [Test] public async Task Method_WriteAllLines_String_IEnumerableString_Encoding_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -1494,7 +1494,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.WriteAllLine path, contents, encoding); } - [Fact] + [Test] public async Task Method_WriteAllLines_String_IEnumerableString_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -1508,7 +1508,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.WriteAllLine path, contents); } - [Fact] + [Test] public async Task Method_WriteAllLines_String_StringArray_Encoding_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -1523,7 +1523,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.WriteAllLine path, contents, encoding); } - [Fact] + [Test] public async Task Method_WriteAllLines_String_StringArray_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -1538,7 +1538,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.WriteAllLine } #if FEATURE_FILESYSTEM_ASYNC - [Fact] + [Test] public async Task Method_WriteAllLinesAsync_String_IEnumerableString_CancellationToken_ShouldRegisterCall() { @@ -1556,7 +1556,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.WriteAllLine #endif #if FEATURE_FILESYSTEM_ASYNC - [Fact] + [Test] public async Task Method_WriteAllLinesAsync_String_IEnumerableString_Encoding_CancellationToken_ShouldRegisterCall() { @@ -1575,7 +1575,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.WriteAllLine #endif #if FEATURE_FILE_SPAN - [Fact] + [Test] public async Task Method_WriteAllText_String_ReadOnlySpanChar_Encoding_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -1591,7 +1591,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.WriteAllText #endif #if FEATURE_FILE_SPAN - [Fact] + [Test] public async Task Method_WriteAllText_String_ReadOnlySpanChar_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -1605,7 +1605,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.WriteAllText } #endif - [Fact] + [Test] public async Task Method_WriteAllText_String_String_Encoding_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -1620,7 +1620,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.WriteAllText path, contents, encoding); } - [Fact] + [Test] public async Task Method_WriteAllText_String_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -1635,7 +1635,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.WriteAllText } #if FEATURE_FILE_SPAN - [Fact] + [Test] public async Task Method_WriteAllTextAsync_String_ReadOnlyMemoryChar_CancellationToken_ShouldRegisterCall() { @@ -1652,7 +1652,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.WriteAllText #endif #if FEATURE_FILE_SPAN - [Fact] + [Test] public async Task Method_WriteAllTextAsync_String_ReadOnlyMemoryChar_Encoding_CancellationToken_ShouldRegisterCall() { @@ -1670,7 +1670,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.WriteAllText #endif #if FEATURE_FILESYSTEM_ASYNC - [Fact] + [Test] public async Task Method_WriteAllTextAsync_String_String_CancellationToken_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -1687,7 +1687,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.WriteAllText #endif #if FEATURE_FILESYSTEM_ASYNC - [Fact] + [Test] public async Task Method_WriteAllTextAsync_String_String_Encoding_CancellationToken_ShouldRegisterCall() { @@ -1705,7 +1705,7 @@ await That(sut.Statistics.File).OnlyContainsMethodCall(nameof(IFile.WriteAllText } #endif - [Fact] + [Test] public async Task ToString_ShouldBeFile() { IStatistics sut = new MockFileSystem().Statistics.File; diff --git a/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/FileStreamFactoryStatisticsTests.cs b/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/FileStreamFactoryStatisticsTests.cs index 4213ac5c5..c6ce3917b 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/FileStreamFactoryStatisticsTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/FileStreamFactoryStatisticsTests.cs @@ -11,7 +11,7 @@ namespace Testably.Abstractions.Testing.Tests.Statistics.FileSystem; public class FileStreamFactoryStatisticsTests { #if NET6_0_OR_GREATER - [Fact] + [Test] public async Task Method_New_SafeFileHandle_FileAccess_Int_Bool_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -32,7 +32,7 @@ await That(sut.Statistics.FileStream).OnlyContainsMethodCall(nameof(IFileStreamF #endif #if NET6_0_OR_GREATER - [Fact] + [Test] public async Task Method_New_SafeFileHandle_FileAccess_Int_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -51,7 +51,7 @@ await That(sut.Statistics.FileStream).OnlyContainsMethodCall(nameof(IFileStreamF } #endif #if NET6_0_OR_GREATER - [Fact] + [Test] public async Task Method_New_SafeFileHandle_FileAccess_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -69,7 +69,7 @@ await That(sut.Statistics.FileStream).OnlyContainsMethodCall(nameof(IFileStreamF } #endif - [Fact] + [Test] public async Task Method_New_String_FileMode_FileAccess_FileShare_Int_Bool_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -88,7 +88,7 @@ await That(sut.Statistics.FileStream).OnlyContainsMethodCall(nameof(IFileStreamF path, mode, access, share, bufferSize, useAsync); } - [Fact] + [Test] public async Task Method_New_String_FileMode_FileAccess_FileShare_Int_FileOptions_ShouldRegisterCall() { @@ -108,7 +108,7 @@ await That(sut.Statistics.FileStream).OnlyContainsMethodCall(nameof(IFileStreamF path, mode, access, share, bufferSize, options); } - [Fact] + [Test] public async Task Method_New_String_FileMode_FileAccess_FileShare_Int_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -125,7 +125,7 @@ await That(sut.Statistics.FileStream).OnlyContainsMethodCall(nameof(IFileStreamF path, mode, access, share, bufferSize); } - [Fact] + [Test] public async Task Method_New_String_FileMode_FileAccess_FileShare_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -141,7 +141,7 @@ await That(sut.Statistics.FileStream).OnlyContainsMethodCall(nameof(IFileStreamF path, mode, access, share); } - [Fact] + [Test] public async Task Method_New_String_FileMode_FileAccess_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -156,7 +156,7 @@ await That(sut.Statistics.FileStream).OnlyContainsMethodCall(nameof(IFileStreamF path, mode, access); } - [Fact] + [Test] public async Task Method_New_String_FileMode_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -171,7 +171,7 @@ await That(sut.Statistics.FileStream).OnlyContainsMethodCall(nameof(IFileStreamF } #if FEATURE_FILESYSTEM_STREAM_OPTIONS - [Fact] + [Test] public async Task Method_New_String_FileStreamOptions_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -187,7 +187,7 @@ await That(sut.Statistics.FileStream).OnlyContainsMethodCall(nameof(IFileStreamF } #endif - [Fact] + [Test] public async Task Method_Wrap_FileStream_ShouldRegisterCall() { string path = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString()); @@ -216,7 +216,7 @@ await That(sut.Statistics.FileStream).OnlyContainsMethodCall( } } - [Fact] + [Test] public async Task ToString_ShouldBeFileStream() { IPathStatistics sut diff --git a/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/FileStreamStatisticsTests.cs b/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/FileStreamStatisticsTests.cs index d643d4a52..d32626485 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/FileStreamStatisticsTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/FileStreamStatisticsTests.cs @@ -8,7 +8,7 @@ namespace Testably.Abstractions.Testing.Tests.Statistics.FileSystem; public class FileStreamStatisticsTests { - [Fact] + [Test] public async Task Method_BeginRead_ByteArray_Int_Int_AsyncCallback_Object_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -27,7 +27,7 @@ await That(sut.Statistics.FileStream["foo"]) buffer, offset, count, callback, state); } - [Fact] + [Test] public async Task Method_BeginWrite_ByteArray_Int_Int_AsyncCallback_Object_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -46,7 +46,7 @@ await That(sut.Statistics.FileStream["foo"]) buffer, offset, count, callback, state); } - [Fact] + [Test] public async Task Method_Close_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -58,7 +58,7 @@ await That(sut.Statistics.FileStream["foo"]) .OnlyContainsMethodCall(nameof(FileSystemStream.Close)); } - [Fact] + [Test] public async Task Method_CopyTo_Stream_Int_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -74,7 +74,7 @@ await That(sut.Statistics.FileStream["foo"]) destination, bufferSize); } - [Fact] + [Test] public async Task Method_CopyToAsync_Stream_Int_CancellationToken_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -91,7 +91,7 @@ await That(sut.Statistics.FileStream["foo"]) destination, bufferSize, cancellationToken); } - [Fact] + [Test] public async Task Method_EndRead_IAsyncResult_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -109,7 +109,7 @@ await That(sut.Statistics.FileStream["foo"].Methods).HasSingle().Matching(c => c.Parameters[0].Is(asyncResult)); } - [Fact] + [Test] public async Task Method_EndWrite_IAsyncResult_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -127,7 +127,7 @@ await That(sut.Statistics.FileStream["foo"].Methods).HasSingle().Matching(c => c.Parameters[0].Is(asyncResult)); } - [Fact] + [Test] public async Task Method_Flush_Bool_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -142,7 +142,7 @@ await That(sut.Statistics.FileStream["foo"]) flushToDisk); } - [Fact] + [Test] public async Task Method_Flush_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -155,7 +155,7 @@ await That(sut.Statistics.FileStream["foo"]) .OnlyContainsMethodCall(nameof(FileSystemStream.Flush)); } - [Fact] + [Test] public async Task Method_FlushAsync_CancellationToken_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -170,7 +170,7 @@ await That(sut.Statistics.FileStream["foo"]) cancellationToken); } - [Fact] + [Test] public async Task Method_Read_ByteArray_Int_Int_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -188,7 +188,7 @@ await That(sut.Statistics.FileStream["foo"]) } #if FEATURE_SPAN - [Fact] + [Test] public async Task Method_Read_SpanByte_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -204,7 +204,7 @@ await That(sut.Statistics.FileStream["foo"]) } #endif - [Fact] + [Test] public async Task Method_ReadAsync_ByteArray_Int_Int_CancellationToken_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -225,7 +225,7 @@ await That(sut.Statistics.FileStream["foo"]) } #if FEATURE_SPAN - [Fact] + [Test] public async Task Method_ReadAsync_MemoryByte_CancellationToken_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -242,7 +242,7 @@ await That(sut.Statistics.FileStream["foo"]) } #endif - [Fact] + [Test] public async Task Method_ReadByte_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -255,7 +255,7 @@ await That(sut.Statistics.FileStream["foo"]) .OnlyContainsMethodCall(nameof(FileSystemStream.ReadByte)); } - [Fact] + [Test] public async Task Method_Seek_Int64_SeekOrigin_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -271,7 +271,7 @@ await That(sut.Statistics.FileStream["foo"]) offset, origin); } - [Fact] + [Test] public async Task Method_SetLength_Int64_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -286,7 +286,7 @@ await That(sut.Statistics.FileStream["foo"]) value); } - [Fact] + [Test] public async Task Method_ToString_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -299,7 +299,7 @@ await That(sut.Statistics.FileStream["foo"]) .OnlyContainsMethodCall(nameof(FileSystemStream.ToString)); } - [Fact] + [Test] public async Task Method_Write_ByteArray_Int_Int_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -317,7 +317,7 @@ await That(sut.Statistics.FileStream["foo"]) } #if FEATURE_SPAN - [Fact] + [Test] public async Task Method_Write_ReadOnlySpanByte_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -333,7 +333,7 @@ await That(sut.Statistics.FileStream["foo"]) } #endif - [Fact] + [Test] public async Task Method_WriteAsync_ByteArray_Int_Int_CancellationToken_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -354,7 +354,7 @@ await That(sut.Statistics.FileStream["foo"]) } #if FEATURE_SPAN - [Fact] + [Test] public async Task Method_WriteAsync_ReadOnlyMemoryByte_CancellationToken_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -371,7 +371,7 @@ await That(sut.Statistics.FileStream["foo"]) } #endif - [Fact] + [Test] public async Task Method_WriteByte_Byte_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -386,7 +386,7 @@ await That(sut.Statistics.FileStream["foo"]) value); } - [Fact] + [Test] public async Task Property_CanRead_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -399,7 +399,7 @@ await That(sut.Statistics.FileStream["foo"]) .OnlyContainsPropertyGetAccess(nameof(FileSystemStream.CanRead)); } - [Fact] + [Test] public async Task Property_CanSeek_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -412,7 +412,7 @@ await That(sut.Statistics.FileStream["foo"]) .OnlyContainsPropertyGetAccess(nameof(FileSystemStream.CanSeek)); } - [Fact] + [Test] public async Task Property_CanTimeout_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -425,7 +425,7 @@ await That(sut.Statistics.FileStream["foo"]) .OnlyContainsPropertyGetAccess(nameof(FileSystemStream.CanTimeout)); } - [Fact] + [Test] public async Task Property_CanWrite_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -438,7 +438,7 @@ await That(sut.Statistics.FileStream["foo"]) .OnlyContainsPropertyGetAccess(nameof(FileSystemStream.CanWrite)); } - [Fact] + [Test] public async Task Property_IsAsync_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -451,7 +451,7 @@ await That(sut.Statistics.FileStream["foo"]) .OnlyContainsPropertyGetAccess(nameof(FileSystemStream.IsAsync)); } - [Fact] + [Test] public async Task Property_Length_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -464,7 +464,7 @@ await That(sut.Statistics.FileStream["foo"]) .OnlyContainsPropertyGetAccess(nameof(FileSystemStream.Length)); } - [Fact] + [Test] public async Task Property_Name_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -477,7 +477,7 @@ await That(sut.Statistics.FileStream["foo"]) .OnlyContainsPropertyGetAccess(nameof(FileSystemStream.Name)); } - [Fact] + [Test] public async Task Property_Position_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -490,7 +490,7 @@ await That(sut.Statistics.FileStream["foo"]) .OnlyContainsPropertyGetAccess(nameof(FileSystemStream.Position)); } - [Fact] + [Test] public async Task Property_Position_Set_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -504,7 +504,7 @@ await That(sut.Statistics.FileStream["foo"]) .OnlyContainsPropertySetAccess(nameof(FileSystemStream.Position)); } - [Fact] + [Test] public async Task Property_ReadTimeout_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -524,7 +524,7 @@ await That(sut.Statistics.FileStream["foo"]) .OnlyContainsPropertyGetAccess(nameof(FileSystemStream.ReadTimeout)); } - [Fact] + [Test] public async Task Property_ReadTimeout_Set_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -545,7 +545,7 @@ await That(sut.Statistics.FileStream["foo"]) .OnlyContainsPropertySetAccess(nameof(FileSystemStream.ReadTimeout)); } - [Fact] + [Test] public async Task Property_WriteTimeout_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -565,7 +565,7 @@ await That(sut.Statistics.FileStream["foo"]) .OnlyContainsPropertyGetAccess(nameof(FileSystemStream.WriteTimeout)); } - [Fact] + [Test] public async Task Property_WriteTimeout_Set_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -586,7 +586,7 @@ await That(sut.Statistics.FileStream["foo"]) .OnlyContainsPropertySetAccess(nameof(FileSystemStream.WriteTimeout)); } - [Fact] + [Test] public async Task ToString_ShouldBeFileStreamWithPath() { IStatistics sut = new MockFileSystem().Statistics.FileStream[@"\\some\path"]; diff --git a/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/FileSystemWatcherFactoryStatisticsTests.cs b/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/FileSystemWatcherFactoryStatisticsTests.cs index 9718565de..d31fca6ef 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/FileSystemWatcherFactoryStatisticsTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/FileSystemWatcherFactoryStatisticsTests.cs @@ -6,7 +6,7 @@ namespace Testably.Abstractions.Testing.Tests.Statistics.FileSystem; public class FileSystemWatcherFactoryStatisticsTests { - [Fact] + [Test] public async Task Method_New_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -18,7 +18,7 @@ await That(sut.Statistics.FileSystemWatcher).OnlyContainsMethodCall( nameof(IFileSystemWatcherFactory.New)); } - [Fact] + [Test] public async Task Method_New_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -33,7 +33,7 @@ await That(sut.Statistics.FileSystemWatcher).OnlyContainsMethodCall( path); } - [Fact] + [Test] public async Task Method_New_String_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -49,7 +49,7 @@ await That(sut.Statistics.FileSystemWatcher).OnlyContainsMethodCall( path, filter); } - [Fact] + [Test] public async Task Method_Wrap_FileSystemWatcher_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -64,7 +64,7 @@ await That(sut.Statistics.FileSystemWatcher).OnlyContainsMethodCall( fileSystemWatcher); } - [Fact] + [Test] public async Task ToString_ShouldBeFileSystemWatcher() { IPathStatistics sut diff --git a/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/FileSystemWatcherStatisticsTests.cs b/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/FileSystemWatcherStatisticsTests.cs index 488be302a..d791f39b8 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/FileSystemWatcherStatisticsTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/FileSystemWatcherStatisticsTests.cs @@ -9,7 +9,7 @@ namespace Testably.Abstractions.Testing.Tests.Statistics.FileSystem; public class FileSystemWatcherStatisticsTests { - [Fact] + [Test] public async Task Method_BeginInit_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -23,7 +23,7 @@ await That(sut.Statistics.FileSystemWatcher["foo"]) .OnlyContainsMethodCall(nameof(IFileSystemWatcher.BeginInit)); } - [Fact] + [Test] public async Task Method_EndInit_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -37,7 +37,7 @@ await That(sut.Statistics.FileSystemWatcher["foo"]) .OnlyContainsMethodCall(nameof(IFileSystemWatcher.EndInit)); } - [Fact] + [Test] public async Task Method_WaitForChanged_WatcherChangeTypes_Int_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -67,7 +67,7 @@ await That(sut.Statistics.FileSystemWatcher["foo"]) timeout); } - [Fact] + [Test] public async Task Method_WaitForChanged_WatcherChangeTypes_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -96,7 +96,7 @@ await That(sut.Statistics.FileSystemWatcher["foo"]) } #if FEATURE_FILESYSTEM_NET_7_OR_GREATER - [Fact] + [Test] public async Task Method_WaitForChanged_WatcherChangeTypes_TimeSpan_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -127,7 +127,7 @@ await That(sut.Statistics.FileSystemWatcher["foo"]) } #endif - [Fact] + [Test] public async Task Property_EnableRaisingEvents_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -140,7 +140,7 @@ await That(sut.Statistics.FileSystemWatcher["foo"]) .OnlyContainsPropertyGetAccess(nameof(IFileSystemWatcher.EnableRaisingEvents)); } - [Fact] + [Test] public async Task Property_EnableRaisingEvents_Set_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -154,7 +154,7 @@ await That(sut.Statistics.FileSystemWatcher["foo"]) .OnlyContainsPropertySetAccess(nameof(IFileSystemWatcher.EnableRaisingEvents)); } - [Fact] + [Test] public async Task Property_Filter_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -167,7 +167,7 @@ await That(sut.Statistics.FileSystemWatcher["foo"]) .OnlyContainsPropertyGetAccess(nameof(IFileSystemWatcher.Filter)); } - [Fact] + [Test] public async Task Property_Filter_Set_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -182,7 +182,7 @@ await That(sut.Statistics.FileSystemWatcher["foo"]) } #if FEATURE_FILESYSTEMWATCHER_ADVANCED - [Fact] + [Test] public async Task Property_Filters_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -196,7 +196,7 @@ await That(sut.Statistics.FileSystemWatcher["foo"]) } #endif - [Fact] + [Test] public async Task Property_IncludeSubdirectories_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -209,7 +209,7 @@ await That(sut.Statistics.FileSystemWatcher["foo"]) .OnlyContainsPropertyGetAccess(nameof(IFileSystemWatcher.IncludeSubdirectories)); } - [Fact] + [Test] public async Task Property_IncludeSubdirectories_Set_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -223,7 +223,7 @@ await That(sut.Statistics.FileSystemWatcher["foo"]) .OnlyContainsPropertySetAccess(nameof(IFileSystemWatcher.IncludeSubdirectories)); } - [Fact] + [Test] public async Task Property_InternalBufferSize_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -236,7 +236,7 @@ await That(sut.Statistics.FileSystemWatcher["foo"]) .OnlyContainsPropertyGetAccess(nameof(IFileSystemWatcher.InternalBufferSize)); } - [Fact] + [Test] public async Task Property_InternalBufferSize_Set_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -250,7 +250,7 @@ await That(sut.Statistics.FileSystemWatcher["foo"]) .OnlyContainsPropertySetAccess(nameof(IFileSystemWatcher.InternalBufferSize)); } - [Fact] + [Test] public async Task Property_NotifyFilter_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -263,7 +263,7 @@ await That(sut.Statistics.FileSystemWatcher["foo"]) .OnlyContainsPropertyGetAccess(nameof(IFileSystemWatcher.NotifyFilter)); } - [Fact] + [Test] public async Task Property_NotifyFilter_Set_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -277,7 +277,7 @@ await That(sut.Statistics.FileSystemWatcher["foo"]) .OnlyContainsPropertySetAccess(nameof(IFileSystemWatcher.NotifyFilter)); } - [Fact] + [Test] public async Task Property_Path_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -290,7 +290,7 @@ await That(sut.Statistics.FileSystemWatcher["foo"]) .OnlyContainsPropertyGetAccess(nameof(IFileSystemWatcher.Path)); } - [Fact] + [Test] public async Task Property_Path_Set_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -304,7 +304,7 @@ await That(sut.Statistics.FileSystemWatcher["foo"]) .OnlyContainsPropertySetAccess(nameof(IFileSystemWatcher.Path)); } - [Fact] + [Test] public async Task Property_Site_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -317,7 +317,7 @@ await That(sut.Statistics.FileSystemWatcher["foo"]) .OnlyContainsPropertyGetAccess(nameof(IFileSystemWatcher.Site)); } - [Fact] + [Test] public async Task Property_Site_Set_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -331,7 +331,7 @@ await That(sut.Statistics.FileSystemWatcher["foo"]) .OnlyContainsPropertySetAccess(nameof(IFileSystemWatcher.Site)); } - [Fact] + [Test] public async Task Property_SynchronizingObject_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -344,7 +344,7 @@ await That(sut.Statistics.FileSystemWatcher["foo"]) .OnlyContainsPropertyGetAccess(nameof(IFileSystemWatcher.SynchronizingObject)); } - [Fact] + [Test] public async Task Property_SynchronizingObject_Set_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -358,7 +358,7 @@ await That(sut.Statistics.FileSystemWatcher["foo"]) .OnlyContainsPropertySetAccess(nameof(IFileSystemWatcher.SynchronizingObject)); } - [Fact] + [Test] public async Task ToString_ShouldBeFileSystemWatcherWithPath() { IStatistics sut = new MockFileSystem().Statistics.FileSystemWatcher[@"\\some\path"]; diff --git a/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/FileVersionInfoFactoryStatisticsTests.cs b/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/FileVersionInfoFactoryStatisticsTests.cs index d87a332c8..21ff96b5e 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/FileVersionInfoFactoryStatisticsTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/FileVersionInfoFactoryStatisticsTests.cs @@ -4,7 +4,7 @@ namespace Testably.Abstractions.Testing.Tests.Statistics.FileSystem; public class FileVersionInfoFactoryStatisticsTests { - [Fact] + [Test] public async Task Method_GetVersionInfo_String_ShouldRegisterCall() { MockFileSystem sut = new(); diff --git a/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/FileVersionInfoStatisticsTests.cs b/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/FileVersionInfoStatisticsTests.cs index 59df8fc14..12f587339 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/FileVersionInfoStatisticsTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/FileVersionInfoStatisticsTests.cs @@ -5,7 +5,7 @@ namespace Testably.Abstractions.Testing.Tests.Statistics.FileSystem; public class FileVersionInfoStatisticsTests { - [Fact] + [Test] public async Task Property_Comments_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -17,7 +17,7 @@ await That(sut.Statistics.FileVersionInfo["foo"]) .OnlyContainsPropertyGetAccess(nameof(IFileVersionInfo.Comments)); } - [Fact] + [Test] public async Task Property_CompanyName_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -29,7 +29,7 @@ await That(sut.Statistics.FileVersionInfo["foo"]) .OnlyContainsPropertyGetAccess(nameof(IFileVersionInfo.CompanyName)); } - [Fact] + [Test] public async Task Property_FileBuildPart_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -41,7 +41,7 @@ await That(sut.Statistics.FileVersionInfo["foo"]) .OnlyContainsPropertyGetAccess(nameof(IFileVersionInfo.FileBuildPart)); } - [Fact] + [Test] public async Task Property_FileDescription_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -53,7 +53,7 @@ await That(sut.Statistics.FileVersionInfo["foo"]) .OnlyContainsPropertyGetAccess(nameof(IFileVersionInfo.FileDescription)); } - [Fact] + [Test] public async Task Property_FileMajorPart_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -65,7 +65,7 @@ await That(sut.Statistics.FileVersionInfo["foo"]) .OnlyContainsPropertyGetAccess(nameof(IFileVersionInfo.FileMajorPart)); } - [Fact] + [Test] public async Task Property_FileMinorPart_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -77,7 +77,7 @@ await That(sut.Statistics.FileVersionInfo["foo"]) .OnlyContainsPropertyGetAccess(nameof(IFileVersionInfo.FileMinorPart)); } - [Fact] + [Test] public async Task Property_FileName_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -89,7 +89,7 @@ await That(sut.Statistics.FileVersionInfo["foo"]) .OnlyContainsPropertyGetAccess(nameof(IFileVersionInfo.FileName)); } - [Fact] + [Test] public async Task Property_FilePrivatePart_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -101,7 +101,7 @@ await That(sut.Statistics.FileVersionInfo["foo"]) .OnlyContainsPropertyGetAccess(nameof(IFileVersionInfo.FilePrivatePart)); } - [Fact] + [Test] public async Task Property_FileVersion_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -113,7 +113,7 @@ await That(sut.Statistics.FileVersionInfo["foo"]) .OnlyContainsPropertyGetAccess(nameof(IFileVersionInfo.FileVersion)); } - [Fact] + [Test] public async Task Property_InternalName_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -125,7 +125,7 @@ await That(sut.Statistics.FileVersionInfo["foo"]) .OnlyContainsPropertyGetAccess(nameof(IFileVersionInfo.InternalName)); } - [Fact] + [Test] public async Task Property_IsDebug_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -137,7 +137,7 @@ await That(sut.Statistics.FileVersionInfo["foo"]) .OnlyContainsPropertyGetAccess(nameof(IFileVersionInfo.IsDebug)); } - [Fact] + [Test] public async Task Property_IsPatched_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -149,7 +149,7 @@ await That(sut.Statistics.FileVersionInfo["foo"]) .OnlyContainsPropertyGetAccess(nameof(IFileVersionInfo.IsPatched)); } - [Fact] + [Test] public async Task Property_IsPreRelease_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -161,7 +161,7 @@ await That(sut.Statistics.FileVersionInfo["foo"]) .OnlyContainsPropertyGetAccess(nameof(IFileVersionInfo.IsPreRelease)); } - [Fact] + [Test] public async Task Property_IsPrivateBuild_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -173,7 +173,7 @@ await That(sut.Statistics.FileVersionInfo["foo"]) .OnlyContainsPropertyGetAccess(nameof(IFileVersionInfo.IsPrivateBuild)); } - [Fact] + [Test] public async Task Property_IsSpecialBuild_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -185,7 +185,7 @@ await That(sut.Statistics.FileVersionInfo["foo"]) .OnlyContainsPropertyGetAccess(nameof(IFileVersionInfo.IsSpecialBuild)); } - [Fact] + [Test] public async Task Property_Language_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -197,7 +197,7 @@ await That(sut.Statistics.FileVersionInfo["foo"]) .OnlyContainsPropertyGetAccess(nameof(IFileVersionInfo.Language)); } - [Fact] + [Test] public async Task Property_LegalCopyright_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -209,7 +209,7 @@ await That(sut.Statistics.FileVersionInfo["foo"]) .OnlyContainsPropertyGetAccess(nameof(IFileVersionInfo.LegalCopyright)); } - [Fact] + [Test] public async Task Property_LegalTrademarks_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -221,7 +221,7 @@ await That(sut.Statistics.FileVersionInfo["foo"]) .OnlyContainsPropertyGetAccess(nameof(IFileVersionInfo.LegalTrademarks)); } - [Fact] + [Test] public async Task Property_OriginalFilename_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -233,7 +233,7 @@ await That(sut.Statistics.FileVersionInfo["foo"]) .OnlyContainsPropertyGetAccess(nameof(IFileVersionInfo.OriginalFilename)); } - [Fact] + [Test] public async Task Property_PrivateBuild_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -245,7 +245,7 @@ await That(sut.Statistics.FileVersionInfo["foo"]) .OnlyContainsPropertyGetAccess(nameof(IFileVersionInfo.PrivateBuild)); } - [Fact] + [Test] public async Task Property_ProductBuildPart_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -257,7 +257,7 @@ await That(sut.Statistics.FileVersionInfo["foo"]) .OnlyContainsPropertyGetAccess(nameof(IFileVersionInfo.ProductBuildPart)); } - [Fact] + [Test] public async Task Property_ProductMajorPart_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -269,7 +269,7 @@ await That(sut.Statistics.FileVersionInfo["foo"]) .OnlyContainsPropertyGetAccess(nameof(IFileVersionInfo.ProductMajorPart)); } - [Fact] + [Test] public async Task Property_ProductMinorPart_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -281,7 +281,7 @@ await That(sut.Statistics.FileVersionInfo["foo"]) .OnlyContainsPropertyGetAccess(nameof(IFileVersionInfo.ProductMinorPart)); } - [Fact] + [Test] public async Task Property_ProductName_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -293,7 +293,7 @@ await That(sut.Statistics.FileVersionInfo["foo"]) .OnlyContainsPropertyGetAccess(nameof(IFileVersionInfo.ProductName)); } - [Fact] + [Test] public async Task Property_ProductPrivatePart_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -305,7 +305,7 @@ await That(sut.Statistics.FileVersionInfo["foo"]) .OnlyContainsPropertyGetAccess(nameof(IFileVersionInfo.ProductPrivatePart)); } - [Fact] + [Test] public async Task Property_ProductVersion_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -317,7 +317,7 @@ await That(sut.Statistics.FileVersionInfo["foo"]) .OnlyContainsPropertyGetAccess(nameof(IFileVersionInfo.ProductVersion)); } - [Fact] + [Test] public async Task Property_SpecialBuild_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); diff --git a/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/PathStatisticsTests.cs b/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/PathStatisticsTests.cs index d4b35eb4d..082ba4ae8 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/PathStatisticsTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/Statistics/FileSystem/PathStatisticsTests.cs @@ -8,7 +8,7 @@ namespace Testably.Abstractions.Testing.Tests.Statistics.FileSystem; public class PathStatisticsTests { - [Fact] + [Test] public async Task Method_ChangeExtension_String_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -22,7 +22,7 @@ await That(sut.Statistics.Path).OnlyContainsMethodCall(nameof(IPath.ChangeExtens path, extension); } #if FEATURE_PATH_SPAN - [Fact] + [Test] public async Task Method_Combine_ReadOnlySpanString_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -35,7 +35,7 @@ await That(sut.Statistics.Path).OnlyContainsMethodCall(nameof(IPath.Combine), } #endif - [Fact] + [Test] public async Task Method_Combine_String_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -49,7 +49,7 @@ await That(sut.Statistics.Path).OnlyContainsMethodCall(nameof(IPath.Combine), path1, path2); } - [Fact] + [Test] public async Task Method_Combine_String_String_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -64,7 +64,7 @@ await That(sut.Statistics.Path).OnlyContainsMethodCall(nameof(IPath.Combine), path1, path2, path3); } - [Fact] + [Test] public async Task Method_Combine_String_String_String_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -80,7 +80,7 @@ await That(sut.Statistics.Path).OnlyContainsMethodCall(nameof(IPath.Combine), path1, path2, path3, path4); } - [Fact] + [Test] public async Task Method_Combine_StringArray_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -94,7 +94,7 @@ await That(sut.Statistics.Path).OnlyContainsMethodCall(nameof(IPath.Combine), } #if FEATURE_PATH_ADVANCED - [Fact] + [Test] public async Task Method_EndsInDirectorySeparator_ReadOnlySpanChar_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -109,7 +109,7 @@ await That(sut.Statistics.Path).OnlyContainsMethodCall(nameof(IPath.EndsInDirect #endif #if FEATURE_PATH_ADVANCED - [Fact] + [Test] public async Task Method_EndsInDirectorySeparator_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -124,7 +124,7 @@ await That(sut.Statistics.Path).OnlyContainsMethodCall(nameof(IPath.EndsInDirect #endif #if FEATURE_FILESYSTEM_NET_7_OR_GREATER - [Fact] + [Test] public async Task Method_Exists_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -139,7 +139,7 @@ await That(sut.Statistics.Path).OnlyContainsMethodCall(nameof(IPath.Exists), #endif #if FEATURE_SPAN - [Fact] + [Test] public async Task Method_GetDirectoryName_ReadOnlySpanChar_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -153,7 +153,7 @@ await That(sut.Statistics.Path).OnlyContainsMethodCall(nameof(IPath.GetDirectory } #endif - [Fact] + [Test] public async Task Method_GetDirectoryName_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -167,7 +167,7 @@ await That(sut.Statistics.Path).OnlyContainsMethodCall(nameof(IPath.GetDirectory } #if FEATURE_SPAN - [Fact] + [Test] public async Task Method_GetExtension_ReadOnlySpanChar_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -181,7 +181,7 @@ await That(sut.Statistics.Path).OnlyContainsMethodCall(nameof(IPath.GetExtension } #endif - [Fact] + [Test] public async Task Method_GetExtension_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -195,7 +195,7 @@ await That(sut.Statistics.Path).OnlyContainsMethodCall(nameof(IPath.GetExtension } #if FEATURE_SPAN - [Fact] + [Test] public async Task Method_GetFileName_ReadOnlySpanChar_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -209,7 +209,7 @@ await That(sut.Statistics.Path).OnlyContainsMethodCall(nameof(IPath.GetFileName) } #endif - [Fact] + [Test] public async Task Method_GetFileName_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -223,7 +223,7 @@ await That(sut.Statistics.Path).OnlyContainsMethodCall(nameof(IPath.GetFileName) } #if FEATURE_SPAN - [Fact] + [Test] public async Task Method_GetFileNameWithoutExtension_ReadOnlySpanChar_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -237,7 +237,7 @@ await That(sut.Statistics.Path).OnlyContainsMethodCall(nameof(IPath.GetFileNameW } #endif - [Fact] + [Test] public async Task Method_GetFileNameWithoutExtension_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -251,7 +251,7 @@ await That(sut.Statistics.Path).OnlyContainsMethodCall( path); } - [Fact] + [Test] public async Task Method_GetFullPath_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -265,7 +265,7 @@ await That(sut.Statistics.Path).OnlyContainsMethodCall(nameof(IPath.GetFullPath) } #if FEATURE_PATH_RELATIVE - [Fact] + [Test] public async Task Method_GetFullPath_String_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -280,7 +280,7 @@ await That(sut.Statistics.Path).OnlyContainsMethodCall(nameof(IPath.GetFullPath) } #endif - [Fact] + [Test] public async Task Method_GetInvalidFileNameChars_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -292,7 +292,7 @@ await That(sut.Statistics.Path) .OnlyContainsMethodCall(nameof(IPath.GetInvalidFileNameChars)); } - [Fact] + [Test] public async Task Method_GetInvalidPathChars_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -304,7 +304,7 @@ public async Task Method_GetInvalidPathChars_ShouldRegisterCall() } #if FEATURE_SPAN - [Fact] + [Test] public async Task Method_GetPathRoot_ReadOnlySpanChar_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -318,7 +318,7 @@ await That(sut.Statistics.Path).OnlyContainsMethodCall(nameof(IPath.GetPathRoot) } #endif - [Fact] + [Test] public async Task Method_GetPathRoot_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -331,7 +331,7 @@ await That(sut.Statistics.Path).OnlyContainsMethodCall(nameof(IPath.GetPathRoot) path); } - [Fact] + [Test] public async Task Method_GetRandomFileName_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -343,7 +343,7 @@ public async Task Method_GetRandomFileName_ShouldRegisterCall() } #if FEATURE_PATH_RELATIVE - [Fact] + [Test] public async Task Method_GetRelativePath_String_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -358,7 +358,7 @@ await That(sut.Statistics.Path).OnlyContainsMethodCall(nameof(IPath.GetRelativeP } #endif - [Fact] + [Test] public async Task Method_GetTempFileName_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -371,7 +371,7 @@ public async Task Method_GetTempFileName_ShouldRegisterCall() await That(sut.Statistics.Path).OnlyContainsMethodCall(nameof(IPath.GetTempFileName)); } - [Fact] + [Test] public async Task Method_GetTempPath_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -383,7 +383,7 @@ public async Task Method_GetTempPath_ShouldRegisterCall() } #if FEATURE_SPAN - [Fact] + [Test] public async Task Method_HasExtension_ReadOnlySpanChar_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -397,7 +397,7 @@ await That(sut.Statistics.Path).OnlyContainsMethodCall(nameof(IPath.HasExtension } #endif - [Fact] + [Test] public async Task Method_HasExtension_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -411,7 +411,7 @@ await That(sut.Statistics.Path).OnlyContainsMethodCall(nameof(IPath.HasExtension } #if FEATURE_SPAN - [Fact] + [Test] public async Task Method_IsPathFullyQualified_ReadOnlySpanChar_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -426,7 +426,7 @@ await That(sut.Statistics.Path).OnlyContainsMethodCall(nameof(IPath.IsPathFullyQ #endif #if FEATURE_PATH_RELATIVE - [Fact] + [Test] public async Task Method_IsPathFullyQualified_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -441,7 +441,7 @@ await That(sut.Statistics.Path).OnlyContainsMethodCall(nameof(IPath.IsPathFullyQ #endif #if FEATURE_SPAN - [Fact] + [Test] public async Task Method_IsPathRooted_ReadOnlySpanChar_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -455,7 +455,7 @@ await That(sut.Statistics.Path).OnlyContainsMethodCall(nameof(IPath.IsPathRooted } #endif - [Fact] + [Test] public async Task Method_IsPathRooted_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -469,7 +469,7 @@ await That(sut.Statistics.Path).OnlyContainsMethodCall(nameof(IPath.IsPathRooted } #if FEATURE_PATH_JOIN - [Fact] + [Test] public async Task Method_Join_ReadOnlySpanChar_ReadOnlySpanChar_ReadOnlySpanChar_ReadOnlySpanChar_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -487,7 +487,7 @@ await That(sut.Statistics.Path).OnlyContainsMethodCall(nameof(IPath.Join), #endif #if FEATURE_PATH_JOIN - [Fact] + [Test] public async Task Method_Join_ReadOnlySpanChar_ReadOnlySpanChar_ReadOnlySpanChar_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -504,7 +504,7 @@ await That(sut.Statistics.Path).OnlyContainsMethodCall(nameof(IPath.Join), #endif #if FEATURE_PATH_JOIN - [Fact] + [Test] public async Task Method_Join_ReadOnlySpanChar_ReadOnlySpanChar_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -520,7 +520,7 @@ await That(sut.Statistics.Path).OnlyContainsMethodCall(nameof(IPath.Join), #endif #if FEATURE_PATH_SPAN - [Fact] + [Test] public async Task Method_Join_ReadOnlySpanString_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -534,7 +534,7 @@ await That(sut.Statistics.Path).OnlyContainsMethodCall(nameof(IPath.Join), #endif #if FEATURE_PATH_JOIN - [Fact] + [Test] public async Task Method_Join_String_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -550,7 +550,7 @@ await That(sut.Statistics.Path).OnlyContainsMethodCall(nameof(IPath.Join), #endif #if FEATURE_PATH_JOIN - [Fact] + [Test] public async Task Method_Join_String_String_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -567,7 +567,7 @@ await That(sut.Statistics.Path).OnlyContainsMethodCall(nameof(IPath.Join), #endif #if FEATURE_PATH_JOIN - [Fact] + [Test] public async Task Method_Join_String_String_String_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -585,7 +585,7 @@ await That(sut.Statistics.Path).OnlyContainsMethodCall(nameof(IPath.Join), #endif #if FEATURE_PATH_JOIN - [Fact] + [Test] public async Task Method_Join_StringArray_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -600,7 +600,7 @@ await That(sut.Statistics.Path).OnlyContainsMethodCall(nameof(IPath.Join), #endif #if FEATURE_PATH_ADVANCED - [Fact] + [Test] public async Task Method_TrimEndingDirectorySeparator_ReadOnlySpanChar_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -615,7 +615,7 @@ await That(sut.Statistics.Path).OnlyContainsMethodCall(nameof(IPath.TrimEndingDi #endif #if FEATURE_PATH_ADVANCED - [Fact] + [Test] public async Task Method_TrimEndingDirectorySeparator_String_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -630,7 +630,7 @@ await That(sut.Statistics.Path).OnlyContainsMethodCall(nameof(IPath.TrimEndingDi #endif #if FEATURE_PATH_JOIN - [Fact] + [Test] public async Task Method_TryJoin_ReadOnlySpanChar_ReadOnlySpanChar_ReadOnlySpanChar_SpanChar_OutInt_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -648,7 +648,7 @@ await That(sut.Statistics.Path).OnlyContainsMethodCall(nameof(IPath.TryJoin), #endif #if FEATURE_PATH_JOIN - [Fact] + [Test] public async Task Method_TryJoin_ReadOnlySpanChar_ReadOnlySpanChar_SpanChar_OutInt_ShouldRegisterCall() { MockFileSystem sut = new(); @@ -664,7 +664,7 @@ await That(sut.Statistics.Path).OnlyContainsMethodCall(nameof(IPath.TryJoin), } #endif - [Fact] + [Test] public async Task Property_AltDirectorySeparatorChar_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -676,7 +676,7 @@ await That(sut.Statistics.Path).OnlyContainsPropertyGetAccess( nameof(IPath.AltDirectorySeparatorChar)); } - [Fact] + [Test] public async Task Property_DirectorySeparatorChar_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -688,7 +688,7 @@ await That(sut.Statistics.Path).OnlyContainsPropertyGetAccess( nameof(IPath.DirectorySeparatorChar)); } - [Fact] + [Test] public async Task Property_PathSeparator_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -699,7 +699,7 @@ public async Task Property_PathSeparator_Get_ShouldRegisterPropertyAccess() await That(sut.Statistics.Path).OnlyContainsPropertyGetAccess(nameof(IPath.PathSeparator)); } - [Fact] + [Test] public async Task Property_VolumeSeparatorChar_Get_ShouldRegisterPropertyAccess() { MockFileSystem sut = new(); @@ -711,7 +711,7 @@ await That(sut.Statistics.Path) .OnlyContainsPropertyGetAccess(nameof(IPath.VolumeSeparatorChar)); } - [Fact] + [Test] public async Task ToString_ShouldBePath() { IStatistics sut = new MockFileSystem().Statistics.Path; diff --git a/Tests/Testably.Abstractions.Testing.Tests/Statistics/MethodStatisticsTests.cs b/Tests/Testably.Abstractions.Testing.Tests/Statistics/MethodStatisticsTests.cs index 8f965dde4..4b2147025 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/Statistics/MethodStatisticsTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/Statistics/MethodStatisticsTests.cs @@ -4,7 +4,7 @@ namespace Testably.Abstractions.Testing.Tests.Statistics; public sealed class MethodStatisticsTests { - [Fact] + [Test] public async Task Counter_ShouldBeInitializedWithOne() { MockFileSystem fileSystem = new(); @@ -14,7 +14,7 @@ public async Task Counter_ShouldBeInitializedWithOne() await That(sut.Counter).IsEqualTo(1); } - [Fact] + [Test] public async Task ToString_ShouldContainName() { MockFileSystem fileSystem = new(); @@ -27,7 +27,7 @@ await That(result).Contains(nameof(IDirectory.CreateDirectory)).And.Contains("\" .DoesNotContain(","); } - [Fact] + [Test] public async Task ToString_ShouldContainParameters() { MockFileSystem fileSystem = new(); diff --git a/Tests/Testably.Abstractions.Testing.Tests/Statistics/ParameterDescriptionTests.cs b/Tests/Testably.Abstractions.Testing.Tests/Statistics/ParameterDescriptionTests.cs index f2f8d22ba..0318df3f5 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/Statistics/ParameterDescriptionTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/Statistics/ParameterDescriptionTests.cs @@ -5,8 +5,8 @@ namespace Testably.Abstractions.Testing.Tests.Statistics; public sealed class ParameterDescriptionTests { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task FromOutParameter_ShouldSetIsOutParameterToTrue(int value) { ParameterDescription sut = ParameterDescription.FromOutParameter(value); @@ -14,8 +14,8 @@ public async Task FromOutParameter_ShouldSetIsOutParameterToTrue(int value) await That(sut.IsOutParameter).IsTrue(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task FromParameter_ShouldSetIsOutParameterToFalse(int value) { ParameterDescription sut = ParameterDescription.FromParameter(value); @@ -24,8 +24,8 @@ public async Task FromParameter_ShouldSetIsOutParameterToFalse(int value) } #if FEATURE_SPAN - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task FromParameter_WithReadOnlySpan_ShouldSetIsOutParameterToFalse(string buffer) { ReadOnlySpan value = buffer.AsSpan(); @@ -37,8 +37,8 @@ public async Task FromParameter_WithReadOnlySpan_ShouldSetIsOutParameterToFalse( #endif #if FEATURE_SPAN - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task FromParameter_WithSpan_ShouldSetIsOutParameterToFalse(int[] buffer) { Span value = buffer.AsSpan(); @@ -49,9 +49,9 @@ public async Task FromParameter_WithSpan_ShouldSetIsOutParameterToFalse(int[] bu } #endif - [Theory] - [InlineAutoData(true)] - [InlineAutoData(false)] + [Test] + [AutoArguments(true)] + [AutoArguments(false)] public async Task Is_WithComparer_ShouldUseComparerResult(bool comparerResult, string value) { ParameterDescription sut = ParameterDescription.FromParameter(value); @@ -61,9 +61,9 @@ public async Task Is_WithComparer_ShouldUseComparerResult(bool comparerResult, s await That(result).IsEqualTo(comparerResult); } - [Theory] - [InlineAutoData(true)] - [InlineAutoData(false)] + [Test] + [AutoArguments(true)] + [AutoArguments(false)] public async Task Is_WithComparer_WithIncompatibleType_ShouldReturnFalse(bool comparerResult, string value) { @@ -74,8 +74,8 @@ public async Task Is_WithComparer_WithIncompatibleType_ShouldReturnFalse(bool co await That(result).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Is_WithFromOutParameter_ShouldCheckForMatchingValue(int value) { ParameterDescription sut = ParameterDescription.FromOutParameter(value); @@ -85,8 +85,8 @@ public async Task Is_WithFromOutParameter_ShouldCheckForMatchingValue(int value) await That(sut.Is("foo")).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Is_WithFromParameter_ShouldCheckForMatchingValue(string value) { ParameterDescription sut = ParameterDescription.FromParameter(value); @@ -96,8 +96,8 @@ public async Task Is_WithFromParameter_ShouldCheckForMatchingValue(string value) await That(sut.Is(42)).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ToString_ShouldReturnValue(int value) { ParameterDescription sut = ParameterDescription.FromParameter(value); @@ -108,8 +108,8 @@ public async Task ToString_ShouldReturnValue(int value) } #if FEATURE_SPAN - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ToString_WithReadOnlySpan_ShouldSetIsOutParameterToFalse(string buffer) { ReadOnlySpan value = buffer.AsSpan(); @@ -123,8 +123,8 @@ public async Task ToString_WithReadOnlySpan_ShouldSetIsOutParameterToFalse(strin #endif #if FEATURE_SPAN - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ToString_WithSpan_ShouldSetIsOutParameterToFalse(int[] buffer) { Span value = buffer.AsSpan(); @@ -137,8 +137,8 @@ public async Task ToString_WithSpan_ShouldSetIsOutParameterToFalse(int[] buffer) } #endif - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ToString_WithStringValue_ShouldReturnValueEnclosedInQuotationMarks( string value) { diff --git a/Tests/Testably.Abstractions.Testing.Tests/Statistics/PathStatisticsTests.cs b/Tests/Testably.Abstractions.Testing.Tests/Statistics/PathStatisticsTests.cs index 983cefabe..172a63edf 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/Statistics/PathStatisticsTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/Statistics/PathStatisticsTests.cs @@ -4,7 +4,7 @@ namespace Testably.Abstractions.Testing.Tests.Statistics; public sealed class PathStatisticsTests { - [Fact] + [Test] public async Task Key_AbsoluteAndRelativePathsShouldMatch() { MockFileSystem fileSystem = new(); @@ -17,7 +17,7 @@ public async Task Key_AbsoluteAndRelativePathsShouldMatch() await That(absolutPath).IsEqualTo(relativePath); } - [Fact] + [Test] public async Task Key_DifferentDrives_ShouldBeConsideredDifferent() { MockFileSystem fileSystem = new(); @@ -29,7 +29,7 @@ public async Task Key_DifferentDrives_ShouldBeConsideredDifferent() await That(result1).IsNotEqualTo(result2); } - [Fact] + [Test] public async Task Key_DifferentUncRootPaths_ShouldBeConsideredDifferent() { MockFileSystem fileSystem = new(); @@ -41,7 +41,7 @@ public async Task Key_DifferentUncRootPaths_ShouldBeConsideredDifferent() await That(result1).IsNotEqualTo(result2); } - [Fact] + [Test] public async Task Key_NullShouldBeSameAsEmptyKey() { MockFileSystem fileSystem = new(); @@ -53,7 +53,7 @@ public async Task Key_NullShouldBeSameAsEmptyKey() await That(nullKey).IsEqualTo(emptyKey); } - [Fact] + [Test] public async Task Key_ShouldSimplifyRelativePaths() { MockFileSystem fileSystem = new(o => o.UseCurrentDirectory()); @@ -66,9 +66,9 @@ public async Task Key_ShouldSimplifyRelativePaths() await That(absolutPath).IsEqualTo(relativePath); } - [Theory] - [InlineData("/")] - [InlineData("\\")] + [Test] + [Arguments("/")] + [Arguments("\\")] public async Task Key_WithDrives_ShouldIgnoreTrailingSeparator(string separator) { const string key = @"C:"; @@ -81,9 +81,9 @@ public async Task Key_WithDrives_ShouldIgnoreTrailingSeparator(string separator) await That(result1).IsEqualTo(result2); } - [Theory] - [InlineData("/")] - [InlineData("\\")] + [Test] + [Arguments("/")] + [Arguments("\\")] public async Task Key_WithFolderInDrives_ShouldIgnoreTrailingSeparator(string separator) { const string key = @"C:\foo"; @@ -96,9 +96,9 @@ public async Task Key_WithFolderInDrives_ShouldIgnoreTrailingSeparator(string se await That(result1).IsEqualTo(result2); } - [Theory] - [InlineData("/")] - [InlineData("\\")] + [Test] + [Arguments("/")] + [Arguments("\\")] public async Task Key_WithFolderInUncRootPaths_ShouldIgnoreTrailingSeparator(string separator) { const string key = @"\\server1\foo"; @@ -111,7 +111,7 @@ public async Task Key_WithFolderInUncRootPaths_ShouldIgnoreTrailingSeparator(str await That(result1).IsEqualTo(result2); } - [Fact] + [Test] public async Task Key_WithNull_ShouldNotThrow() { MockFileSystem fileSystem = new(); diff --git a/Tests/Testably.Abstractions.Testing.Tests/Statistics/PropertyStatisticsTests.cs b/Tests/Testably.Abstractions.Testing.Tests/Statistics/PropertyStatisticsTests.cs index 3b6c640e9..00623c9d5 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/Statistics/PropertyStatisticsTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/Statistics/PropertyStatisticsTests.cs @@ -4,7 +4,7 @@ namespace Testably.Abstractions.Testing.Tests.Statistics; public sealed class PropertyStatisticsTests { - [Fact] + [Test] public async Task Counter_ShouldBeInitializedWithOne() { MockFileSystem fileSystem = new(); @@ -14,7 +14,7 @@ public async Task Counter_ShouldBeInitializedWithOne() await That(sut.Counter).IsEqualTo(1); } - [Fact] + [Test] public async Task ToString_Get_ShouldContainNameAndGet() { MockFileSystem fileSystem = new(); @@ -28,7 +28,7 @@ public async Task ToString_Get_ShouldContainNameAndGet() await That(result).Contains(nameof(IFileInfo.IsReadOnly)).And.Contains("{get;}"); } - [Fact] + [Test] public async Task ToString_Set_ShouldContainNameAndSet() { MockFileSystem fileSystem = new(); diff --git a/Tests/Testably.Abstractions.Testing.Tests/Statistics/StatisticsTests.Helpers.cs b/Tests/Testably.Abstractions.Testing.Tests/Statistics/StatisticsTests.Helpers.cs index 814e7e539..b136387ab 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/Statistics/StatisticsTests.Helpers.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/Statistics/StatisticsTests.Helpers.cs @@ -35,14 +35,16 @@ private static void CheckMethodCall(StringBuilder builder, Type testType) { #pragma warning disable MA0089 // Use an overload with char instead of string + #pragma warning disable MA0001 //Use an overload of 'Replace' that has a StringComparison parameter string expectedName = $"Method_{methodInfo.Name}_{string.Join("_", methodInfo .GetParameters() .Select(x => FirstCharToUpperAsSpan(GetName(x.ParameterType, true) - .Replace("<", "", StringComparison.Ordinal) - .Replace(">", "", StringComparison.Ordinal) + .Replace("<", "") + .Replace(">", "") // ReSharper disable once StringLiteralTypo - .Replace("IEnumerablestring", "IEnumerableString", StringComparison.Ordinal) - .Replace("[]", "Array", StringComparison.Ordinal))))}{(parameters.Length > 0 ? "_" : "")}ShouldRegisterCall"; + .Replace("IEnumerablestring", "IEnumerableString") + .Replace("[]", "Array"))))}{(parameters.Length > 0 ? "_" : "")}ShouldRegisterCall"; + #pragma warning restore MA0001 #pragma warning restore MA0089 if (testType.GetMethod(expectedName) != null) { @@ -51,7 +53,7 @@ private static void CheckMethodCall(StringBuilder builder, bool isAsync = typeof(Task).IsAssignableFrom(methodInfo.ReturnType); #pragma warning disable MA0011 // IFormatProvider is missing - builder.AppendLine("\t[Fact]"); + builder.AppendLine("\t[Test]"); builder.Append(isAsync ? "\tpublic async Task " : "\tpublic void "); builder.Append(expectedName); builder.AppendLine("()"); @@ -166,7 +168,7 @@ private static void CheckPropertyGetAccess(StringBuilder builder, } #pragma warning disable MA0011 // IFormatProvider is missing - builder.AppendLine("\t[Fact]"); + builder.AppendLine("\t[Test]"); builder.Append("\tpublic void "); builder.Append(expectedName); builder.AppendLine("()"); @@ -200,7 +202,7 @@ private static void CheckPropertySetAccess(StringBuilder builder, } #pragma warning disable MA0011 // IFormatProvider is missing - builder.AppendLine("\t[Fact]"); + builder.AppendLine("\t[Test]"); builder.Append("\tpublic void "); builder.Append(expectedName); builder.AppendLine("()"); diff --git a/Tests/Testably.Abstractions.Testing.Tests/Statistics/StatisticsTests.cs b/Tests/Testably.Abstractions.Testing.Tests/Statistics/StatisticsTests.cs index 1dddf156e..85e924453 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/Statistics/StatisticsTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/Statistics/StatisticsTests.cs @@ -7,7 +7,7 @@ namespace Testably.Abstractions.Testing.Tests.Statistics; public sealed partial class StatisticsTests { - [Fact] + [Test] public async Task FileSystem_Initialize_ShouldNotRegisterStatistics() { MockFileSystem sut = new(); @@ -23,36 +23,36 @@ public async Task FileSystem_Initialize_ShouldNotRegisterStatistics() await That(sut.Statistics.File.Methods).IsEmpty(); } - [Theory] - [InlineData(nameof(MockFileSystem.Directory), false, + [Test] + [Arguments(nameof(MockFileSystem.Directory), false, typeof(IDirectory), typeof(DirectoryStatisticsTests))] - [InlineData(nameof(MockFileSystem.DirectoryInfo), false, + [Arguments(nameof(MockFileSystem.DirectoryInfo), false, typeof(IDirectoryInfoFactory), typeof(DirectoryInfoFactoryStatisticsTests))] - [InlineData(nameof(MockFileSystem.DirectoryInfo), true, + [Arguments(nameof(MockFileSystem.DirectoryInfo), true, typeof(IDirectoryInfo), typeof(DirectoryInfoStatisticsTests))] - [InlineData(nameof(MockFileSystem.DriveInfo), false, + [Arguments(nameof(MockFileSystem.DriveInfo), false, typeof(IDriveInfoFactory), typeof(DriveInfoFactoryStatisticsTests))] - [InlineData(nameof(MockFileSystem.DriveInfo), true, + [Arguments(nameof(MockFileSystem.DriveInfo), true, typeof(IDriveInfo), typeof(DriveInfoStatisticsTests))] - [InlineData(nameof(MockFileSystem.File), false, + [Arguments(nameof(MockFileSystem.File), false, typeof(IFile), typeof(FileStatisticsTests))] - [InlineData(nameof(MockFileSystem.FileInfo), false, + [Arguments(nameof(MockFileSystem.FileInfo), false, typeof(IFileInfoFactory), typeof(FileInfoFactoryStatisticsTests))] - [InlineData(nameof(MockFileSystem.FileInfo), true, + [Arguments(nameof(MockFileSystem.FileInfo), true, typeof(IFileInfo), typeof(FileInfoStatisticsTests))] - [InlineData(nameof(MockFileSystem.FileStream), false, + [Arguments(nameof(MockFileSystem.FileStream), false, typeof(IFileStreamFactory), typeof(FileStreamFactoryStatisticsTests))] - [InlineData(nameof(MockFileSystem.FileStream), true, + [Arguments(nameof(MockFileSystem.FileStream), true, typeof(FileSystemStream), typeof(FileStreamStatisticsTests))] - [InlineData(nameof(MockFileSystem.FileSystemWatcher), false, + [Arguments(nameof(MockFileSystem.FileSystemWatcher), false, typeof(IFileSystemWatcherFactory), typeof(FileSystemWatcherFactoryStatisticsTests))] - [InlineData(nameof(MockFileSystem.FileSystemWatcher), true, + [Arguments(nameof(MockFileSystem.FileSystemWatcher), true, typeof(IFileSystemWatcher), typeof(FileSystemWatcherStatisticsTests))] - [InlineData(nameof(MockFileSystem.FileVersionInfo), false, + [Arguments(nameof(MockFileSystem.FileVersionInfo), false, typeof(IFileVersionInfoFactory), typeof(FileVersionInfoFactoryStatisticsTests))] - [InlineData(nameof(MockFileSystem.FileVersionInfo), true, + [Arguments(nameof(MockFileSystem.FileVersionInfo), true, typeof(IFileVersionInfo), typeof(FileVersionInfoStatisticsTests))] - [InlineData(nameof(MockFileSystem.Path), false, + [Arguments(nameof(MockFileSystem.Path), false, typeof(IPath), typeof(FileSystem.PathStatisticsTests))] public async Task ShouldHaveTestedAllFileSystemMethods(string className, bool requireInstance, Type mockType, Type testType) @@ -63,7 +63,7 @@ public async Task ShouldHaveTestedAllFileSystemMethods(string className, bool re await That(result).IsEmpty(); } - [Fact] + [Test] public async Task Statistics_ShouldIncrementCallOrder() { MockFileSystem sut = new(); @@ -83,7 +83,7 @@ await That(sut.Statistics.Directory.Methods[i] } } - [Fact] + [Test] public async Task Statistics_ShouldKeepCallOrder() { MockFileSystem sut = new(); @@ -106,7 +106,7 @@ await That(sut.Statistics.Directory.Methods } } - [Fact] + [Test] public async Task Statistics_ShouldSupportParallelCalls() { int parallelTasks = 100; @@ -122,7 +122,7 @@ public async Task Statistics_ShouldSupportParallelCalls() tasks[taskId] = Task.Run(() => { sut.Directory.CreateDirectory(directories[taskId]); - }, TestContext.Current.CancellationToken); + }, TestContext.Current!.Execution.CancellationToken); } await Task.WhenAll(tasks); @@ -140,7 +140,7 @@ await That(sut.Statistics.Directory.Methods.Select(x => x.Counter)) .IsEqualTo(Enumerable.Range(1, directories.Length)).InAnyOrder(); } - [Fact] + [Test] public async Task Statistics_ShouldUseGlobalIncrement() { MockFileSystem sut = new(); diff --git a/Tests/Testably.Abstractions.Testing.Tests/Storage/InMemoryContainerTests.cs b/Tests/Testably.Abstractions.Testing.Tests/Storage/InMemoryContainerTests.cs index cc6c55591..f7efdf297 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/Storage/InMemoryContainerTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/Storage/InMemoryContainerTests.cs @@ -8,8 +8,8 @@ namespace Testably.Abstractions.Testing.Tests.Storage; public class InMemoryContainerTests { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AdjustAttributes_Decrypt_ShouldNotHaveEncryptedAttribute(string path) { MockFileSystem fileSystem = new(); @@ -27,8 +27,8 @@ public async Task AdjustAttributes_Decrypt_ShouldNotHaveEncryptedAttribute(strin await That(result).DoesNotHaveFlag(FileAttributes.Encrypted); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AdjustAttributes_Encrypt_ShouldHaveEncryptedAttribute(string path) { MockFileSystem fileSystem = new(); @@ -45,8 +45,8 @@ public async Task AdjustAttributes_Encrypt_ShouldHaveEncryptedAttribute(string p await That(result).HasFlag(FileAttributes.Encrypted); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AdjustAttributes_LeadingDot_ShouldBeHiddenOnUnix(string path) { path = "." + path; @@ -71,9 +71,9 @@ public async Task AdjustAttributes_LeadingDot_ShouldBeHiddenOnUnix(string path) } #if FEATURE_FILESYSTEM_LINK - [Theory] - [InlineAutoData(null, false)] - [InlineAutoData("foo", true)] + [Test] + [AutoArguments(null, false)] + [AutoArguments("foo", true)] public async Task AdjustAttributes_ShouldHaveReparsePointAttributeWhenLinkTargetIsNotNull( string? linkTarget, bool shouldHaveReparsePoint, string path) { @@ -101,8 +101,8 @@ public async Task AdjustAttributes_ShouldHaveReparsePointAttributeWhenLinkTarget } #endif - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Container_ShouldProvideCorrectTimeAndFileSystem(string path) { MockFileSystem fileSystem = new(); @@ -113,8 +113,8 @@ public async Task Container_ShouldProvideCorrectTimeAndFileSystem(string path) await That(sut.TimeSystem).IsSameAs(fileSystem.TimeSystem); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Decrypt_Encrypted_ShouldDecryptBytes( string path, byte[] bytes) { @@ -133,8 +133,8 @@ public async Task Decrypt_Encrypted_ShouldDecryptBytes( await That(fileContainer.GetBytes()).IsEqualTo(bytes); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Decrypt_Unencrypted_ShouldDoNothing( string path, byte[] bytes) { @@ -151,8 +151,8 @@ public async Task Decrypt_Unencrypted_ShouldDoNothing( await That(fileContainer.GetBytes()).IsEqualTo(bytes); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Encrypt_Encrypted_ShouldDoNothing( string path, byte[] bytes) { @@ -171,8 +171,8 @@ public async Task Encrypt_Encrypted_ShouldDoNothing( await That(fileContainer.GetBytes()).IsEqualTo(bytes); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Encrypt_ShouldEncryptBytes( string path, byte[] bytes) { @@ -190,8 +190,8 @@ public async Task Encrypt_ShouldEncryptBytes( await That(fileContainer.GetBytes()).IsNotEqualTo(bytes); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task RequestAccess_ToString_DeleteAccess_ShouldContainAccessAndShare(string path, FileAccess access, FileShare share) { @@ -208,8 +208,8 @@ public async Task RequestAccess_ToString_DeleteAccess_ShouldContainAccessAndShar await That(result.ToString()).Contains(share.ToString()); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task RequestAccess_ToString_ShouldContainAccessAndShare(string path, FileAccess access, FileShare share) @@ -226,8 +226,8 @@ public async Task RequestAccess_ToString_ShouldContainAccessAndShare(string path await That(result.ToString()).Contains(share.ToString()); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task RequestAccess_WithoutDrive_ShouldThrowDirectoryNotFoundException( string path) { @@ -243,9 +243,9 @@ public async Task RequestAccess_WithoutDrive_ShouldThrowDirectoryNotFoundExcepti await That(exception).IsExactly(); } - [Theory] - [InlineAutoData(DateTimeKind.Local)] - [InlineAutoData(DateTimeKind.Utc)] + [Test] + [AutoArguments(DateTimeKind.Local)] + [AutoArguments(DateTimeKind.Utc)] public async Task TimeContainer_Time_Set_WithUnspecifiedKind_ShouldSetToProvidedKind( DateTimeKind kind, string path, DateTime time) { @@ -262,8 +262,8 @@ public async Task TimeContainer_Time_Set_WithUnspecifiedKind_ShouldSetToProvided await That(result.Kind).IsEqualTo(kind); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task TimeContainer_ToString_ShouldReturnUtcTime( string path, DateTime time) { @@ -281,7 +281,7 @@ public async Task TimeContainer_ToString_ShouldReturnUtcTime( await That(result).IsEqualTo(expectedString); } - [Fact] + [Test] public async Task ToString_Directory_ShouldIncludePath() { MockFileSystem fileSystem = new(); @@ -296,8 +296,8 @@ public async Task ToString_Directory_ShouldIncludePath() await That(result).IsEqualTo($"{expectedPath}: Directory"); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ToString_File_ShouldIncludePathAndFileSize(byte[] bytes) { MockFileSystem fileSystem = new(); @@ -311,7 +311,7 @@ public async Task ToString_File_ShouldIncludePathAndFileSize(byte[] bytes) await That(result).IsEqualTo($"{expectedPath}: File ({bytes.Length} bytes)"); } - [Fact] + [Test] public async Task ToString_UnknownContainer_ShouldIncludePath() { MockFileSystem fileSystem = new(); diff --git a/Tests/Testably.Abstractions.Testing.Tests/Storage/InMemoryLocationTests.cs b/Tests/Testably.Abstractions.Testing.Tests/Storage/InMemoryLocationTests.cs index c14429332..2e45cd6a7 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/Storage/InMemoryLocationTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/Storage/InMemoryLocationTests.cs @@ -6,8 +6,8 @@ namespace Testably.Abstractions.Testing.Tests.Storage; public class InMemoryLocationTests { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Equals_AsObject_ForInMemoryLocation_ShouldIgnoreTrailingDirectorySeparator( string path1, string path2) { @@ -20,8 +20,8 @@ public async Task Equals_AsObject_ForInMemoryLocation_ShouldIgnoreTrailingDirect await That(result).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Equals_ForDummyLocation_ShouldCompareFullPath( string path) { @@ -34,8 +34,8 @@ public async Task Equals_ForDummyLocation_ShouldCompareFullPath( await That(result).IsTrue(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Equals_ForInMemoryLocation_ShouldIgnoreTrailingDirectorySeparator( string path) { @@ -51,8 +51,8 @@ public async Task Equals_ForInMemoryLocation_ShouldIgnoreTrailingDirectorySepara await That(result).IsTrue(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Equals_Null_ShouldReturnFalse(string path) { IStorageLocation location = InMemoryLocation.New(new MockFileSystem(), null, path); @@ -62,8 +62,8 @@ public async Task Equals_Null_ShouldReturnFalse(string path) await That(result).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Equals_Object_ForInMemoryLocation_ShouldIgnoreTrailingDirectorySeparator( string path) { @@ -79,8 +79,8 @@ public async Task Equals_Object_ForInMemoryLocation_ShouldIgnoreTrailingDirector await That(result).IsTrue(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Equals_Object_Null_ShouldReturnFalse(string path) { object location = InMemoryLocation.New(new MockFileSystem(), null, path); @@ -90,8 +90,8 @@ public async Task Equals_Object_Null_ShouldReturnFalse(string path) await That(result).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Equals_Object_SameInstance_ShouldReturnTrue(string path) { object location = InMemoryLocation.New(new MockFileSystem(), null, path); @@ -102,8 +102,8 @@ public async Task Equals_Object_SameInstance_ShouldReturnTrue(string path) await That(result).IsTrue(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Equals_SameInstance_ShouldReturnTrue(string path) { IStorageLocation location = InMemoryLocation.New(new MockFileSystem(), null, path); @@ -113,7 +113,7 @@ public async Task Equals_SameInstance_ShouldReturnTrue(string path) await That(result).IsTrue(); } - [Fact] + [Test] public async Task GetParent_Root_ShouldReturnNull() { MockFileSystem fileSystem = new(); @@ -125,7 +125,7 @@ public async Task GetParent_Root_ShouldReturnNull() await That(result).IsNull(); } - [Fact] + [Test] public async Task New_EmptyPath_ShouldThrowArgumentException() { void Act() @@ -136,8 +136,8 @@ void Act() await That(Act).ThrowsExactly().WithHResult(-2147024809); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ToString_ShouldReturnPath(string path) { IStorageLocation location = InMemoryLocation.New(new MockFileSystem(), null, path); diff --git a/Tests/Testably.Abstractions.Testing.Tests/Storage/InMemoryStorageTests.cs b/Tests/Testably.Abstractions.Testing.Tests/Storage/InMemoryStorageTests.cs index fdd950165..7edc28929 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/Storage/InMemoryStorageTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/Storage/InMemoryStorageTests.cs @@ -21,8 +21,8 @@ public InMemoryStorageTests() #endregion - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Copy_Overwrite_ShouldAdjustAvailableFreeSpace( int file1Size, int file2Size) { @@ -45,14 +45,14 @@ await That(availableFreeSpaceAfter) .IsEqualTo(availableFreeSpaceBefore + file2Size - file1Size); } - [Fact] + [Test] public async Task CurrentDirectory_ShouldBeInitializedToDefaultRoot() { string expectedRoot = string.Empty.PrefixRoot(new MockFileSystem()); await That(Storage.CurrentDirectory).IsEqualTo(expectedRoot); } - [Fact] + [Test] public async Task Delete_RaceCondition_ShouldReturnFalse() { MockFileSystem fileSystem = new(); @@ -75,11 +75,11 @@ public async Task Delete_RaceCondition_ShouldReturnFalse() await That(exception).IsExactly(); } - [Theory] - [InlineData((string?)null)] - [InlineData("")] - [InlineData(" ")] - [InlineData("\t")] + [Test] + [Arguments((string?)null)] + [Arguments("")] + [Arguments(" ")] + [Arguments("\t")] public async Task GetDrive_NullOrWhitespace_ShouldReturnNull(string? driveName) { IStorageDrive? result = Storage.GetDrive(driveName); @@ -87,7 +87,7 @@ public async Task GetDrive_NullOrWhitespace_ShouldReturnNull(string? driveName) await That(result).IsNull(); } - [Fact] + [Test] public async Task GetOrAddDrive_Null_ShouldReturnNull() { IStorageDrive? result = Storage.GetOrAddDrive(driveName: null); @@ -95,7 +95,7 @@ public async Task GetOrAddDrive_Null_ShouldReturnNull() await That(result).IsNull(); } - [Fact] + [Test] public async Task GetOrCreateContainer_WithMetadata_ShouldBeKept() { FileSystemExtensibility extensibility = new(); @@ -114,8 +114,8 @@ public async Task GetOrCreateContainer_WithMetadata_ShouldBeKept() await That(result2).IsEqualTo(42); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Move_RequestDeniedForChild_ShouldRollback( string locationPath, string destinationPath) { @@ -152,8 +152,8 @@ public async Task Move_RequestDeniedForChild_ShouldRollback( await That(exception).IsExactly(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Replace_WithBackup_ShouldChangeAvailableFreeSpace( int file1Size, int file2Size, int file3Size) { @@ -178,8 +178,8 @@ public async Task Replace_WithBackup_ShouldChangeAvailableFreeSpace( await That(availableFreeSpaceAfter).IsEqualTo(availableFreeSpaceBefore + file2Size); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Replace_WithoutBackup_ShouldNotChangeAvailableFreeSpace( int file1Size, int file2Size) { @@ -201,8 +201,8 @@ public async Task Replace_WithoutBackup_ShouldNotChangeAvailableFreeSpace( await That(availableFreeSpaceAfter).IsEqualTo(availableFreeSpaceBefore); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task TryAddContainer_ShouldNotifyWhenAdded(string path) { bool receivedNotification = false; @@ -218,8 +218,8 @@ public async Task TryAddContainer_ShouldNotifyWhenAdded(string path) await That(container!.Type).IsEqualTo(FileSystemTypes.Directory); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task TryAddContainer_ShouldNotNotifyWhenExistsPreviously(string path) { IStorageLocation location = Storage.GetLocation(path); diff --git a/Tests/Testably.Abstractions.Testing.Tests/Storage/LocationExtensionsTests.cs b/Tests/Testably.Abstractions.Testing.Tests/Storage/LocationExtensionsTests.cs index eebc09555..9e4cd1749 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/Storage/LocationExtensionsTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/Storage/LocationExtensionsTests.cs @@ -5,7 +5,7 @@ namespace Testably.Abstractions.Testing.Tests.Storage; public sealed class LocationExtensionsTests { - [Fact] + [Test] public async Task ThrowExceptionIfNotFound_MissingDirectory_ShouldThrowDirectoryNotFoundException() { @@ -20,8 +20,8 @@ public async Task await That(exception).IsExactly(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ThrowExceptionIfNotFound_MissingDirectory_WithCustomCallback_ShouldThrowExceptionFromCallback( Exception expectedException) @@ -38,7 +38,7 @@ public async Task await That(exception).IsSameAs(expectedException); } - [Fact] + [Test] public async Task ThrowExceptionIfNotFound_MissingFile_ShouldThrowFileNotFoundException() { MockFileSystem fileSystem = new(); @@ -52,8 +52,8 @@ public async Task ThrowExceptionIfNotFound_MissingFile_ShouldThrowFileNotFoundEx await That(exception).IsExactly(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ThrowExceptionIfNotFound_MissingFile_WithCustomCallback_ShouldThrowExceptionFromCallback( Exception expectedException) @@ -69,8 +69,8 @@ public async Task await That(exception).IsSameAs(expectedException); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ThrowIfNotFound_MissingDirectory_ShouldExecuteFileNotFoundAction( Exception expectedException) { @@ -86,8 +86,8 @@ public async Task ThrowIfNotFound_MissingDirectory_ShouldExecuteFileNotFoundActi await That(exception).IsSameAs(expectedException); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ThrowIfNotFound_MissingFile_ShouldExecuteFileNotFoundAction( Exception expectedException) { @@ -102,8 +102,8 @@ public async Task ThrowIfNotFound_MissingFile_ShouldExecuteFileNotFoundAction( await That(exception).IsSameAs(expectedException); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ThrowIfNotFound_Null_ShouldExecuteFileNotFoundAction( Exception expectedException) { diff --git a/Tests/Testably.Abstractions.Testing.Tests/Storage/NullContainerTests.cs b/Tests/Testably.Abstractions.Testing.Tests/Storage/NullContainerTests.cs index a6eb0e89d..f3a452a1c 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/Storage/NullContainerTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/Storage/NullContainerTests.cs @@ -5,8 +5,8 @@ namespace Testably.Abstractions.Testing.Tests.Storage; public class NullContainerTests { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendBytes_ShouldReturnEmptyArray(byte[] bytes) { MockFileSystem fileSystem = new(); @@ -17,7 +17,7 @@ public async Task AppendBytes_ShouldReturnEmptyArray(byte[] bytes) await That(sut.GetBytes()).IsEmpty(); } - [Fact] + [Test] public async Task ClearBytes_ShouldReturnEmptyArray() { MockFileSystem fileSystem = new(); @@ -28,7 +28,7 @@ public async Task ClearBytes_ShouldReturnEmptyArray() await That(sut.GetBytes()).IsEmpty(); } - [Fact] + [Test] public async Task Constructor_ShouldSetFileAndTimeSystem() { MockFileSystem fileSystem = new(); @@ -39,7 +39,7 @@ public async Task Constructor_ShouldSetFileAndTimeSystem() await That(sut.TimeSystem).IsSameAs(fileSystem.TimeSystem); } - [Fact] + [Test] public async Task CreationTime_WithUnspecifiedKind_ShouldReturnNullTime() { MockFileSystem fileSystem = new(); @@ -50,7 +50,7 @@ public async Task CreationTime_WithUnspecifiedKind_ShouldReturnNullTime() await That(result).IsEqualTo(new DateTime(1601, 1, 1, 0, 0, 0, DateTimeKind.Utc)); } - [Fact] + [Test] public async Task Decrypt_ShouldReturnEmptyArray() { MockFileSystem fileSystem = new(); @@ -61,7 +61,7 @@ public async Task Decrypt_ShouldReturnEmptyArray() await That(sut.GetBytes()).IsEmpty(); } - [Fact] + [Test] public async Task Encrypt_ShouldReturnEmptyArray() { MockFileSystem fileSystem = new(); @@ -72,7 +72,7 @@ public async Task Encrypt_ShouldReturnEmptyArray() await That(sut.GetBytes()).IsEmpty(); } - [Fact] + [Test] public async Task GetBytes_ShouldReturnEmptyArray() { MockFileSystem fileSystem = new(); @@ -81,8 +81,8 @@ public async Task GetBytes_ShouldReturnEmptyArray() await That(sut.GetBytes()).IsEmpty(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task LinkTarget_ShouldAlwaysReturnNull(string linkTarget) { MockFileSystem fileSystem = new(); @@ -94,8 +94,8 @@ public async Task LinkTarget_ShouldAlwaysReturnNull(string linkTarget) await That(sut.LinkTarget).IsNull(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task RequestAccess_Dispose_Twice_ShouldDoNothing(FileAccess access, FileShare share) { @@ -113,8 +113,8 @@ public async Task RequestAccess_Dispose_Twice_ShouldDoNothing(FileAccess access, await That(exception).IsNull(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task RequestAccess_ShouldReturnNullObject(FileAccess access, FileShare share, bool deleteAccess) { @@ -128,7 +128,7 @@ public async Task RequestAccess_ShouldReturnNullObject(FileAccess access, FileSh await That(result.DeleteAccess).IsEqualTo(deleteAccess); } - [Fact] + [Test] public async Task Type_ShouldBeDirectoryOrFile() { MockFileSystem fileSystem = new(); @@ -137,8 +137,8 @@ public async Task Type_ShouldBeDirectoryOrFile() await That(sut.Type).IsEqualTo(FileSystemTypes.DirectoryOrFile); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteBytes_ShouldReturnEmptyArray(byte[] bytes) { MockFileSystem fileSystem = new(); diff --git a/Tests/Testably.Abstractions.Testing.Tests/TestHelpers/FileSystemTestSettingsFixture.cs b/Tests/Testably.Abstractions.Testing.Tests/TestHelpers/FileSystemTestSettingsFixture.cs deleted file mode 100644 index 21e1e2e1e..000000000 --- a/Tests/Testably.Abstractions.Testing.Tests/TestHelpers/FileSystemTestSettingsFixture.cs +++ /dev/null @@ -1,11 +0,0 @@ -using Testably.Abstractions.TestHelpers.Settings; - -namespace Testably.Abstractions.Testing.Tests.TestHelpers; - -[CollectionDefinition("RealFileSystemTests")] -public class FileSystemTestSettingsFixture : ICollectionFixture -{ - // This class has no code, and is never created. Its purpose is simply - // to be the place to apply [CollectionDefinition] and all the - // ICollectionFixture<> interfaces. -} diff --git a/Tests/Testably.Abstractions.Testing.Tests/TestHelpers/Usings.cs b/Tests/Testably.Abstractions.Testing.Tests/TestHelpers/Usings.cs index d9bb8eb36..a14f370a0 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/TestHelpers/Usings.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/TestHelpers/Usings.cs @@ -1,13 +1,9 @@ -#if NET48 -global using Testably.Abstractions.Polyfills; -# endif -global using AutoFixture.Xunit3; -global using System; +global using System; global using System.IO.Abstractions; global using System.Threading.Tasks; global using Testably.Abstractions.TestHelpers; global using Test = Testably.Abstractions.Testing.Tests.TestHelpers.Test; -global using Xunit; +global using TUnit; global using aweXpect; global using static aweXpect.Expect; global using Skip = Testably.Abstractions.TestHelpers.Skip; diff --git a/Tests/Testably.Abstractions.Testing.Tests/TimeProviderTests.cs b/Tests/Testably.Abstractions.Testing.Tests/TimeProviderTests.cs index e3837748a..e9a861c9d 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/TimeProviderTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/TimeProviderTests.cs @@ -6,7 +6,7 @@ namespace Testably.Abstractions.Testing.Tests; public class TimeProviderTests { - [Fact] + [Test] public async Task Now_ShouldReturnCurrentDateTime() { DateTime begin = DateTime.UtcNow; @@ -20,7 +20,7 @@ public async Task Now_ShouldReturnCurrentDateTime() await That(result2).IsOnOrAfter(begin).And.IsOnOrBefore(end); } - [Fact] + [Test] public async Task Random_ShouldReturnRandomDateTime() { ConcurrentBag results = []; @@ -33,8 +33,8 @@ public async Task Random_ShouldReturnRandomDateTime() await That(results).AreAllUnique(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task SetTo_ShouldChangeTimeForRead(DateTime time1, DateTime time2) { ITimeProvider timeProvider = TimeProvider.Use(time1); @@ -47,7 +47,7 @@ public async Task SetTo_ShouldChangeTimeForRead(DateTime time1, DateTime time2) await That(result2).IsEqualTo(time2); } - [Fact] + [Test] public async Task Use_ShouldReturnFixedDateTime() { DateTime now = TimeTestHelper.GetRandomTime(); @@ -60,7 +60,7 @@ public async Task Use_ShouldReturnFixedDateTime() await That(result2).IsEqualTo(now); } - [Fact] + [Test] public async Task Use_UnspecifiedKind_ShouldConvertToUtcDateTime() { DateTime unspecifiedTime = TimeTestHelper.GetRandomTime(DateTimeKind.Unspecified); diff --git a/Tests/Testably.Abstractions.Testing.Tests/TimeSystem/NotificationHandlerTests.cs b/Tests/Testably.Abstractions.Testing.Tests/TimeSystem/NotificationHandlerTests.cs index f3d64ea2c..ffbb23112 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/TimeSystem/NotificationHandlerTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/TimeSystem/NotificationHandlerTests.cs @@ -5,7 +5,7 @@ namespace Testably.Abstractions.Testing.Tests.TimeSystem; public class NotificationHandlerTests { - [Fact] + [Test] public async Task OnDateTimeRead_DisposedCallback_ShouldNotBeCalled() { DateTime expectedTime = TimeTestHelper.GetRandomTime(DateTimeKind.Local); @@ -19,7 +19,7 @@ public async Task OnDateTimeRead_DisposedCallback_ShouldNotBeCalled() await That(receivedTime).IsNull(); } - [Fact] + [Test] public async Task OnDateTimeRead_MultipleCallbacks_DisposeOne_ShouldCallOtherCallbacks() { DateTime expectedTime = TimeTestHelper.GetRandomTime(DateTimeKind.Local); @@ -37,7 +37,7 @@ public async Task OnDateTimeRead_MultipleCallbacks_DisposeOne_ShouldCallOtherCal await That(receivedTime2).IsNull(); } - [Fact] + [Test] public async Task OnDateTimeRead_MultipleCallbacks_ShouldAllBeCalled() { DateTime expectedTime = TimeTestHelper.GetRandomTime(DateTimeKind.Local); @@ -57,7 +57,7 @@ public async Task OnDateTimeRead_MultipleCallbacks_ShouldAllBeCalled() await That(receivedTime2).IsEqualTo(expectedTime); } - [Fact] + [Test] public async Task OnDateTimeRead_Today_ShouldExecuteCallbackWithCorrectParameter() { DateTime expectedTime = TimeTestHelper.GetRandomTime(DateTimeKind.Local).Date; @@ -72,7 +72,7 @@ public async Task OnDateTimeRead_Today_ShouldExecuteCallbackWithCorrectParameter await That(receivedTime).IsEqualTo(expectedTime); } - [Fact] + [Test] public async Task OnDateTimeRead_UtcNow_ShouldExecuteCallbackWithCorrectParameter() { DateTime expectedTime = TimeTestHelper.GetRandomTime(DateTimeKind.Utc); @@ -87,7 +87,7 @@ public async Task OnDateTimeRead_UtcNow_ShouldExecuteCallbackWithCorrectParamete await That(receivedTime).IsEqualTo(expectedTime); } - [Fact] + [Test] public async Task OnTaskDelay_DisposedCallback_ShouldNotBeCalled() { int millisecondsDelay = new Random().Next(); @@ -96,12 +96,12 @@ public async Task OnTaskDelay_DisposedCallback_ShouldNotBeCalled() IDisposable disposable = timeSystem.On.TaskDelay(d => receivedDelay = d); disposable.Dispose(); - _ = timeSystem.Task.Delay(millisecondsDelay, TestContext.Current.CancellationToken); + _ = timeSystem.Task.Delay(millisecondsDelay, TestContext.Current!.Execution.CancellationToken); await That(receivedDelay).IsNull(); } - [Fact] + [Test] public async Task OnTaskDelay_MultipleCallbacks_DisposeOne_ShouldCallOtherCallbacks() { TimeSpan expectedDelay = TimeTestHelper.GetRandomInterval(); @@ -112,14 +112,14 @@ public async Task OnTaskDelay_MultipleCallbacks_DisposeOne_ShouldCallOtherCallba using (timeSystem.On.TaskDelay(d => receivedDelay1 = d)) { timeSystem.On.TaskDelay(d => receivedDelay2 = d).Dispose(); - _ = timeSystem.Task.Delay(expectedDelay, TestContext.Current.CancellationToken); + _ = timeSystem.Task.Delay(expectedDelay, TestContext.Current!.Execution.CancellationToken); } await That(receivedDelay1).IsEqualTo(expectedDelay); await That(receivedDelay2).IsNull(); } - [Fact] + [Test] public async Task OnTaskDelay_MultipleCallbacks_ShouldAllBeCalled() { TimeSpan expectedDelay = TimeTestHelper.GetRandomInterval(); @@ -131,7 +131,7 @@ public async Task OnTaskDelay_MultipleCallbacks_ShouldAllBeCalled() { using (timeSystem.On.TaskDelay(d => receivedDelay2 = d)) { - _ = timeSystem.Task.Delay(expectedDelay, TestContext.Current.CancellationToken); + _ = timeSystem.Task.Delay(expectedDelay, TestContext.Current!.Execution.CancellationToken); } } @@ -139,7 +139,7 @@ public async Task OnTaskDelay_MultipleCallbacks_ShouldAllBeCalled() await That(receivedDelay2).IsEqualTo(expectedDelay); } - [Fact] + [Test] public async Task OnTaskDelay_WithMillisecondsAndWithCancellationToken_ShouldExecuteCallbackWithCorrectParameter() { @@ -155,7 +155,7 @@ public async Task await That(receivedDelay.TotalMilliseconds).IsEqualTo(millisecondsDelay); } - [Fact] + [Test] public async Task OnTaskDelay_WithMillisecondsAndWithoutCancellationToken_ShouldExecuteCallbackWithCorrectParameter() { @@ -165,13 +165,13 @@ public async Task using (timeSystem.On.TaskDelay(d => receivedDelay = d)) { - _ = timeSystem.Task.Delay(millisecondsDelay, TestContext.Current.CancellationToken); + _ = timeSystem.Task.Delay(millisecondsDelay, TestContext.Current!.Execution.CancellationToken); } await That(receivedDelay.TotalMilliseconds).IsEqualTo(millisecondsDelay); } - [Fact] + [Test] public async Task OnTaskDelay_WithTimeSpanAndWithCancellationToken_ShouldExecuteCallbackWithCorrectParameter() { @@ -187,7 +187,7 @@ public async Task await That(receivedDelay).IsEqualTo(expectedDelay); } - [Fact] + [Test] public async Task OnTaskDelay_WithTimeSpanAndWithoutCancellationToken_ShouldExecuteCallbackWithCorrectParameter() { @@ -197,13 +197,13 @@ public async Task using (timeSystem.On.TaskDelay(d => receivedDelay = d)) { - _ = timeSystem.Task.Delay(expectedDelay, TestContext.Current.CancellationToken); + _ = timeSystem.Task.Delay(expectedDelay, TestContext.Current!.Execution.CancellationToken); } await That(receivedDelay).IsEqualTo(expectedDelay); } - [Fact] + [Test] public async Task OnThreadSleep_DisposedCallback_ShouldNotBeCalled() { int millisecondsTimeout = new Random().Next(); @@ -217,7 +217,7 @@ public async Task OnThreadSleep_DisposedCallback_ShouldNotBeCalled() await That(receivedTimeout).IsNull(); } - [Fact] + [Test] public async Task OnThreadSleep_MultipleCallbacks_DisposeOne_ShouldCallOtherCallbacks() { TimeSpan expectedTimeout = TimeTestHelper.GetRandomInterval(); @@ -235,7 +235,7 @@ public async Task OnThreadSleep_MultipleCallbacks_DisposeOne_ShouldCallOtherCall await That(receivedTimeout2).IsNull(); } - [Fact] + [Test] public async Task OnThreadSleep_MultipleCallbacks_ShouldAllBeCalled() { TimeSpan expectedTimeout = TimeTestHelper.GetRandomInterval(); @@ -255,7 +255,7 @@ public async Task OnThreadSleep_MultipleCallbacks_ShouldAllBeCalled() await That(receivedTimeout2).IsEqualTo(expectedTimeout); } - [Fact] + [Test] public async Task OnThreadSleep_WithMilliseconds_ShouldExecuteCallbackWithCorrectParameter() { int millisecondsTimeout = new Random().Next(); @@ -270,7 +270,7 @@ public async Task OnThreadSleep_WithMilliseconds_ShouldExecuteCallbackWithCorrec await That(receivedTimeout.TotalMilliseconds).IsEqualTo(millisecondsTimeout); } - [Fact] + [Test] public async Task OnThreadSleep_WithTimeSpan_ShouldExecuteCallbackWithCorrectParameter() { TimeSpan expectedTimeout = TimeTestHelper.GetRandomInterval(); diff --git a/Tests/Testably.Abstractions.Testing.Tests/TimeSystem/StopwatchFactoryMockTests.cs b/Tests/Testably.Abstractions.Testing.Tests/TimeSystem/StopwatchFactoryMockTests.cs index c7f73a04c..b976a1f78 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/TimeSystem/StopwatchFactoryMockTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/TimeSystem/StopwatchFactoryMockTests.cs @@ -4,7 +4,7 @@ namespace Testably.Abstractions.Testing.Tests.TimeSystem; public class StopwatchFactoryMockTests { - [Fact] + [Test] public async Task Wrap_ShouldThrowNotSupportedException() { MockTimeSystem timeSystem = new(); diff --git a/Tests/Testably.Abstractions.Testing.Tests/TimeSystem/StopwatchMockTests.cs b/Tests/Testably.Abstractions.Testing.Tests/TimeSystem/StopwatchMockTests.cs index df76f68fc..e2176c914 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/TimeSystem/StopwatchMockTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/TimeSystem/StopwatchMockTests.cs @@ -4,17 +4,17 @@ namespace Testably.Abstractions.Testing.Tests.TimeSystem; public class StopwatchMockTests { - [Theory] - [InlineData(0)] - [InlineData(1)] - [InlineData(15)] - [InlineData(1234567890)] + [Test] + [Arguments(0)] + [Arguments(1)] + [Arguments(15)] + [Arguments(1234567890)] public async Task ShouldSupportTicksPrecision(long delayTicks) { MockTimeSystem timeSystem = new(); IStopwatch stopwatch = timeSystem.Stopwatch.StartNew(); await timeSystem.Task.Delay(TimeSpan.FromTicks(delayTicks), - TestContext.Current.CancellationToken); + TestContext.Current!.Execution.CancellationToken); long elapsedTicks = stopwatch.ElapsedTicks; diff --git a/Tests/Testably.Abstractions.Testing.Tests/TimeSystem/TimeSystemExtensibilityTests.cs b/Tests/Testably.Abstractions.Testing.Tests/TimeSystem/TimeSystemExtensibilityTests.cs index 32fbe830a..a3a9c8766 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/TimeSystem/TimeSystemExtensibilityTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/TimeSystem/TimeSystemExtensibilityTests.cs @@ -1,3 +1,4 @@ +using System.Collections.Generic; using Testably.Abstractions.TimeSystem; namespace Testably.Abstractions.Testing.Tests.TimeSystem; @@ -6,17 +7,16 @@ public class TimeSystemExtensibilityTests { #region Test Setup - public static TheoryData GetTimeSystems - => new() - { - (ITimeSystem)new RealTimeSystem(), - (ITimeSystem)new MockTimeSystem(), - }; + public static IEnumerable> GetTimeSystems() + { + yield return () => new RealTimeSystem(); + yield return () => new MockTimeSystem(); + } #endregion - [Theory] - [MemberData(nameof(GetTimeSystems))] + [Test] + [MethodDataSource(nameof(GetTimeSystems))] public async Task DateTime_ShouldSetExtensionPoint(ITimeSystem timeSystem) { IDateTime sut = timeSystem.DateTime; @@ -26,8 +26,8 @@ public async Task DateTime_ShouldSetExtensionPoint(ITimeSystem timeSystem) await That(result).IsEqualTo(timeSystem); } - [Theory] - [MemberData(nameof(GetTimeSystems))] + [Test] + [MethodDataSource(nameof(GetTimeSystems))] public async Task Task_ShouldSetExtensionPoint(ITimeSystem timeSystem) { ITask sut = timeSystem.Task; @@ -37,8 +37,8 @@ public async Task Task_ShouldSetExtensionPoint(ITimeSystem timeSystem) await That(result).IsEqualTo(timeSystem); } - [Theory] - [MemberData(nameof(GetTimeSystems))] + [Test] + [MethodDataSource(nameof(GetTimeSystems))] public async Task Thread_ShouldSetExtensionPoint(ITimeSystem timeSystem) { IThread sut = timeSystem.Thread; @@ -48,8 +48,8 @@ public async Task Thread_ShouldSetExtensionPoint(ITimeSystem timeSystem) await That(result).IsEqualTo(timeSystem); } - [Theory] - [MemberData(nameof(GetTimeSystems))] + [Test] + [MethodDataSource(nameof(GetTimeSystems))] public async Task Timer_ShouldSetExtensionPoint(ITimeSystem timeSystem) { using ITimer sut = timeSystem.Timer.New(_ => { }); @@ -59,8 +59,8 @@ public async Task Timer_ShouldSetExtensionPoint(ITimeSystem timeSystem) await That(result).IsEqualTo(timeSystem); } - [Theory] - [MemberData(nameof(GetTimeSystems))] + [Test] + [MethodDataSource(nameof(GetTimeSystems))] public async Task TimerFactory_ShouldSetExtensionPoint(ITimeSystem timeSystem) { ITimerFactory sut = timeSystem.Timer; diff --git a/Tests/Testably.Abstractions.Testing.Tests/TimeSystem/TimerFactoryMockTests.cs b/Tests/Testably.Abstractions.Testing.Tests/TimeSystem/TimerFactoryMockTests.cs index caae83d4b..6dbcb855f 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/TimeSystem/TimerFactoryMockTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/TimeSystem/TimerFactoryMockTests.cs @@ -5,7 +5,7 @@ namespace Testably.Abstractions.Testing.Tests.TimeSystem; public class TimerFactoryMockTests { - [Fact] + [Test] public async Task New_WithoutPeriod_ShouldStillBeRegistered() { MockTimeSystem timeSystem = new(); @@ -24,11 +24,11 @@ public async Task New_WithoutPeriod_ShouldStillBeRegistered() } }); - await That(ms.Wait(300, TestContext.Current.CancellationToken)).IsFalse(); + await That(ms.Wait(300, TestContext.Current!.Execution.CancellationToken)).IsFalse(); await That(timeSystem.TimerHandler[0]).IsEqualTo(timer); } - [Fact] + [Test] public async Task Wrap_ShouldThrowNotSupportedException() { MockTimeSystem timeSystem = new(); diff --git a/Tests/Testably.Abstractions.Testing.Tests/TimeSystem/TimerHandlerTests.cs b/Tests/Testably.Abstractions.Testing.Tests/TimeSystem/TimerHandlerTests.cs index 02769fc38..e44d5b6c8 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/TimeSystem/TimerHandlerTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/TimeSystem/TimerHandlerTests.cs @@ -6,7 +6,7 @@ namespace Testably.Abstractions.Testing.Tests.TimeSystem; public class TimerHandlerTests { - [Fact] + [Test] public async Task Index_AccessDisposedIndex_ShouldThrowException() { MockTimeSystem timeSystem = new MockTimeSystem() @@ -26,7 +26,7 @@ public async Task Index_AccessDisposedIndex_ShouldThrowException() await That(exception).IsExactly(); } - [Fact] + [Test] public async Task Index_MultipleTimers_ShouldIncrement() { MockTimeSystem timeSystem = new MockTimeSystem() @@ -40,7 +40,7 @@ public async Task Index_MultipleTimers_ShouldIncrement() await That(sut[1]).IsEqualTo(timer1); } - [Fact] + [Test] public async Task Index_ShouldNotReuseDisposedIndexes() { MockTimeSystem timeSystem = new MockTimeSystem() diff --git a/Tests/Testably.Abstractions.Testing.Tests/TimeSystem/TimerMockTests.cs b/Tests/Testably.Abstractions.Testing.Tests/TimeSystem/TimerMockTests.cs index 5b98340cb..e015802e3 100644 --- a/Tests/Testably.Abstractions.Testing.Tests/TimeSystem/TimerMockTests.cs +++ b/Tests/Testably.Abstractions.Testing.Tests/TimeSystem/TimerMockTests.cs @@ -5,12 +5,12 @@ namespace Testably.Abstractions.Testing.Tests.TimeSystem; // ReSharper disable UseAwaitUsing -public class TimerMockTests(ITestOutputHelper testOutputHelper) +public class TimerMockTests { - [Theory] - [InlineData(-1)] - [InlineData(0)] - [InlineData(2000)] + [Test] + [Arguments(-1)] + [Arguments(0)] + [Arguments(2000)] public async Task Change_ValidDueTimeValue_ShouldNotThrowException(int dueTime) { MockTimeSystem timeSystem = new(); @@ -27,10 +27,10 @@ public async Task Change_ValidDueTimeValue_ShouldNotThrowException(int dueTime) await That(exception).IsNull(); } - [Theory] - [InlineData(-1)] - [InlineData(0)] - [InlineData(2000)] + [Test] + [Arguments(-1)] + [Arguments(0)] + [Arguments(2000)] public async Task Change_ValidPeriodValue_ShouldNotThrowException(int period) { MockTimeSystem timeSystem = new(); @@ -47,7 +47,7 @@ public async Task Change_ValidPeriodValue_ShouldNotThrowException(int period) await That(exception).IsNull(); } - [Fact] + [Test] public async Task Dispose_ShouldDisposeTimer() { MockTimeSystem timeSystem = new(); @@ -74,7 +74,7 @@ await That(Act).Throws() #endif } - [Fact] + [Test] public async Task Dispose_WithUnknownWaitHandle_ShouldThrowNotSupportedException() { MockTimeSystem timeSystem = new(); @@ -96,7 +96,7 @@ await That(Act).ThrowsExactly() } #if FEATURE_ASYNC_DISPOSABLE - [Fact] + [Test] public async Task DisposeAsync_ShouldDisposeTimer() { MockTimeSystem timeSystem = new(); @@ -120,7 +120,7 @@ void Act() } #endif - [Fact] + [Test] public async Task Exception_WhenSwallowExceptionsIsNotSet_ShouldStopTimer() { MockTimeSystem timeSystem = new MockTimeSystem() @@ -143,12 +143,12 @@ public async Task Exception_WhenSwallowExceptionsIsNotSet_ShouldStopTimer() timeSystem.TimerHandler[0].Wait(); }); - await Task.Delay(10, TestContext.Current.CancellationToken); + await Task.Delay(10, TestContext.Current!.Execution.CancellationToken); await That(exception).IsEqualTo(expectedException); await That(count).IsEqualTo(1); } - [Fact] + [Test] public async Task Exception_WhenSwallowExceptionsIsNotSet_ShouldThrowExceptionOnWait() { MockTimeSystem timeSystem = new MockTimeSystem() @@ -167,7 +167,7 @@ public async Task Exception_WhenSwallowExceptionsIsNotSet_ShouldThrowExceptionOn await That(exception).IsEqualTo(expectedException); } - [Fact] + [Test] public async Task Exception_WhenSwallowExceptionsIsSet_ShouldContinueTimerExecution() { MockTimeSystem timeSystem = new(); @@ -197,12 +197,12 @@ public async Task Exception_WhenSwallowExceptionsIsSet_ShouldContinueTimerExecut } }, null, 0, 20); - await That(ms.Wait(10000, TestContext.Current.CancellationToken)).IsTrue(); + await That(ms.Wait(10000, TestContext.Current!.Execution.CancellationToken)).IsTrue(); await That(count).IsGreaterThanOrEqualTo(3); } - [Fact] + [Test] public async Task New_WithStartOnMockWaitMode_ShouldOnlyStartWhenCallingWait() { MockTimeSystem timeSystem = new MockTimeSystem() @@ -212,13 +212,13 @@ public async Task New_WithStartOnMockWaitMode_ShouldOnlyStartWhenCallingWait() int count = 0; using ITimer timer = timeSystem.Timer.New(_ => count++, null, 0, 100); - await Task.Delay(10, TestContext.Current.CancellationToken); + await Task.Delay(10, TestContext.Current!.Execution.CancellationToken); await That(count).IsEqualTo(0); timerHandler[0].Wait(); await That(count).IsGreaterThan(0); } - [Fact] + [Test] public async Task Wait_Infinite_ShouldBeValidTimeout() { MockTimeSystem timeSystem = new MockTimeSystem() @@ -237,7 +237,7 @@ public async Task Wait_Infinite_ShouldBeValidTimeout() await That(exception).IsNull(); } - [Fact] + [Test] public async Task Wait_InvalidExecutionCount_ShouldThrowArgumentOutOfRangeException() { MockTimeSystem timeSystem = new(); @@ -255,7 +255,7 @@ await That(Act).ThrowsExactly().WithParamName("exec .WithMessage("Execution count must be greater than zero.").AsPrefix(); } - [Fact] + [Test] public async Task Wait_InvalidTimeout_ShouldThrowArgumentOutOfRangeException() { MockTimeSystem timeSystem = new(); @@ -271,7 +271,7 @@ void Act() await That(Act).ThrowsExactly().WithParamName("timeout"); } - [Fact] + [Test] public async Task Wait_TimeoutExpired_ShouldThrowTimeoutException() { MockTimeSystem timeSystem = new(); @@ -285,7 +285,7 @@ public async Task Wait_TimeoutExpired_ShouldThrowTimeoutException() try { count++; - ms.Wait(TestContext.Current.CancellationToken); + ms.Wait(TestContext.Current!.Execution.CancellationToken); } catch (ObjectDisposedException) { @@ -303,7 +303,7 @@ public async Task Wait_TimeoutExpired_ShouldThrowTimeoutException() await That(count).IsGreaterThan(0); } - [Fact] + [Test] public async Task Wait_Twice_ShouldContinueExecutionsAfterFirstWait() { int executionCount = 10; @@ -315,24 +315,24 @@ public async Task Wait_Twice_ShouldContinueExecutionsAfterFirstWait() using ITimer timer = timeSystem.Timer.New(_ => { count++; - testOutputHelper.WriteLine($"Execute: {count}"); + Console.WriteLine($"Execute: {count}"); }, null, 0, 100); - testOutputHelper.WriteLine($"Waiting {executionCount} times..."); + Console.WriteLine($"Waiting {executionCount} times..."); timerHandler[0].Wait(executionCount, callback: _ => - testOutputHelper.WriteLine("Waiting completed.")); - testOutputHelper.WriteLine($"Waiting {executionCount} times..."); + Console.WriteLine("Waiting completed.")); + Console.WriteLine($"Waiting {executionCount} times..."); timerHandler[0].Wait(executionCount, callback: t => { - testOutputHelper.WriteLine("Waiting completed."); - testOutputHelper.WriteLine("Disposing..."); + Console.WriteLine("Waiting completed."); + Console.WriteLine("Disposing..."); t.Dispose(); - testOutputHelper.WriteLine("Disposed."); + Console.WriteLine("Disposed."); }, timeout: 10000); await That(count).IsGreaterThanOrEqualTo(2 * executionCount); } - [Fact] + [Test] public async Task Wait_WithExecutionCount_ShouldWaitForSpecifiedNumberOfExecutions() { int executionCount = 10; @@ -344,19 +344,19 @@ public async Task Wait_WithExecutionCount_ShouldWaitForSpecifiedNumberOfExecutio using ITimer timer = timeSystem.Timer.New(_ => { count++; - testOutputHelper.WriteLine($"Execute: {count}"); + Console.WriteLine($"Execute: {count}"); }, null, 0, 100); await That(count).IsEqualTo(0); timerHandler[0].Wait(executionCount, callback: t => { - testOutputHelper.WriteLine("Disposing..."); + Console.WriteLine("Disposing..."); t.Dispose(); - testOutputHelper.WriteLine("Disposed."); + Console.WriteLine("Disposed."); }, timeout: 10000); - testOutputHelper.WriteLine("Waiting 100ms..."); - await Task.Delay(1000, TestContext.Current.CancellationToken); - testOutputHelper.WriteLine("Waiting completed."); + Console.WriteLine("Waiting 100ms..."); + await Task.Delay(1000, TestContext.Current!.Execution.CancellationToken); + Console.WriteLine("Waiting completed."); await That(count).IsEqualTo(executionCount); } diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/Directory/CreateDirectoryTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/Directory/CreateDirectoryTests.cs index d80679d3e..a65001ab6 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/Directory/CreateDirectoryTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/Directory/CreateDirectoryTests.cs @@ -4,10 +4,10 @@ namespace Testably.Abstractions.Tests.FileSystem.Directory; [FileSystemTests] -public partial class CreateDirectoryTests +public class CreateDirectoryTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateDirectory_AlreadyExisting_ShouldDoNothing(string path) { FileSystem.Directory.CreateDirectory(path); @@ -21,8 +21,8 @@ void Act() await That(FileSystem.Directory.Exists(path)).IsTrue(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateDirectory_ReadOnlyParent_ShouldStillCreateDirectoryUnderWindows( string parent, string subdirectory) @@ -50,7 +50,7 @@ await That(FileSystem.DirectoryInfo.New(parent).Attributes) } } - [Fact] + [Test] public async Task CreateDirectory_ShouldSupportExtendedLengthPaths() { Skip.If(!Test.RunsOnWindows); @@ -60,8 +60,8 @@ public async Task CreateDirectory_ShouldSupportExtendedLengthPaths() await That(FileSystem.Directory.Exists(@"\\?\c:\bar")).IsTrue(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateDirectory_FileWithSameNameAlreadyExists_ShouldThrowIOException( string name) { @@ -77,7 +77,7 @@ await That(Act).Throws() await That(FileSystem.Directory.Exists(name)).IsFalse(); } - [Fact] + [Test] public async Task CreateDirectory_Root_ShouldNotThrowException() { string path = FileTestHelper.RootDrive(Test); @@ -92,8 +92,8 @@ void Act() await That(FileSystem.Directory.Exists(path)).IsTrue(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateDirectory_ShouldTrimTrailingSpaces_OnWindows(string path) { string pathWithSpaces = path + " "; @@ -110,8 +110,8 @@ public async Task CreateDirectory_ShouldTrimTrailingSpaces_OnWindows(string path } } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateDirectory_ShouldAdjustTimes(string path, string subdirectoryName) { SkipIfLongRunningTestsShouldBeSkipped(); @@ -144,8 +144,8 @@ await That(lastAccessTime).IsBetween(creationTimeStart).And(creationTimeEnd) await That(lastWriteTime).IsOnOrAfter(updateTime.ApplySystemClockTolerance()); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateDirectory_ShouldAdjustTimesOnlyForDirectParentDirectory( string rootPath) { @@ -181,8 +181,8 @@ await That(lastWriteTime).IsBetween(creationTimeStart).And(creationTimeEnd) } } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateDirectory_ShouldSetCreationTime(string path) { DateTime start = TimeSystem.DateTime.Now; @@ -195,8 +195,8 @@ public async Task CreateDirectory_ShouldSetCreationTime(string path) await That(result.Kind).IsEqualTo(DateTimeKind.Local); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateDirectory_ShouldSetCreationTimeUtc(string path) { DateTime start = TimeSystem.DateTime.UtcNow; @@ -209,7 +209,7 @@ public async Task CreateDirectory_ShouldSetCreationTimeUtc(string path) await That(result.Kind).IsEqualTo(DateTimeKind.Utc); } - [Fact] + [Test] public async Task CreateDirectory_NullCharacter_ShouldThrowArgumentException() { string path = "foo\0bar"; @@ -219,7 +219,7 @@ public async Task CreateDirectory_NullCharacter_ShouldThrowArgumentException() await That(Act).Throws().WithHResult(-2147024809); } - [Fact] + [Test] public async Task CreateDirectory_ShouldCreateDirectoryInBasePath() { IDirectoryInfo result = FileSystem.Directory.CreateDirectory("foo"); @@ -228,7 +228,7 @@ public async Task CreateDirectory_ShouldCreateDirectoryInBasePath() await That(result.FullName).StartsWith(BasePath); } - [Fact] + [Test] public async Task CreateDirectory_ShouldCreateParentDirectories() { string directoryLevel1 = "lvl1"; @@ -248,9 +248,9 @@ public async Task CreateDirectory_ShouldCreateParentDirectories() } #if NETFRAMEWORK - [Theory] - [InlineData("/")] - [InlineData("\\")] + [Test] + [Arguments("/")] + [Arguments("\\")] public async Task CreateDirectory_TrailingDirectorySeparator_ShouldNotBeTrimmed( string suffix) { @@ -271,7 +271,7 @@ await That(result.FullName).IsEqualTo(System.IO.Path.Combine(BasePath, expectedN } #endif - [Fact] + [Test] public async Task CreateDirectory_WithoutAccessRightsToParent_ShouldThrowUnauthorizedAccessException() { @@ -300,9 +300,9 @@ await That(Act).Throws() } #if NETFRAMEWORK - [Theory] - [InlineData("")] - [InlineData(" ")] + [Test] + [Arguments("")] + [Arguments(" ")] public async Task CreateDirectory_EmptyOrWhitespace_ShouldReturnEmptyString( string suffix) { @@ -322,11 +322,11 @@ await That(result.FullName).IsEqualTo(System.IO.Path.Combine(BasePath, expectedN await That(FileSystem.Directory.Exists(nameWithSuffix)).IsTrue(); } #else - [Theory] - [InlineData("")] - [InlineData(" ")] - [InlineData("/")] - [InlineData("\\")] + [Test] + [Arguments("")] + [Arguments(" ")] + [Arguments("/")] + [Arguments("\\")] public async Task CreateDirectory_TrailingDirectorySeparator_ShouldNotBeTrimmed( string suffix) { diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/Directory/CreateSymbolicLinkTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/Directory/CreateSymbolicLinkTests.cs index 227d3024c..b0ff775d7 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/Directory/CreateSymbolicLinkTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/Directory/CreateSymbolicLinkTests.cs @@ -4,10 +4,10 @@ namespace Testably.Abstractions.Tests.FileSystem.Directory; [FileSystemTests] -public partial class CreateSymbolicLinkTests +public class CreateSymbolicLinkTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateSymbolicLink_ShouldCreateSymbolicLink( string path, string pathToTarget) { @@ -19,8 +19,8 @@ await That(FileSystem.DirectoryInfo.New(path).Attributes) .HasFlag(FileAttributes.ReparsePoint); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateSymbolicLink_SourceDirectoryAlreadyExists_ShouldThrowIOException( string path, string pathToTarget) { @@ -46,8 +46,8 @@ await That(Act).Throws() } } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateSymbolicLink_TargetDirectoryMissing_ShouldNotThrowException( string path, string pathToTarget) { @@ -59,8 +59,8 @@ void Act() await That(Act).DoesNotThrow(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateSymbolicLink_WithIllegalCharactersInTarget_ShouldThrowIOException( string path) { @@ -76,8 +76,8 @@ void Act() await That(Act).Throws().WithHResult(-2147024713); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateSymbolicLink_WithIllegalPath_ShouldThrowArgumentException_OnWindows( string pathToTarget) { @@ -98,8 +98,8 @@ void Act() } } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateSymbolicLink_WithIllegalTarget_ShouldNotThrowException(string path) { void Act() diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/Directory/DeleteTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/Directory/DeleteTests.cs index 064194dd2..0c720ad5b 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/Directory/DeleteTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/Directory/DeleteTests.cs @@ -3,10 +3,10 @@ namespace Testably.Abstractions.Tests.FileSystem.Directory; [FileSystemTests] -public partial class DeleteTests +public class DeleteTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Delete_CaseDifferentPath_ShouldThrowDirectoryNotFoundException_OnLinux( string directoryName) { @@ -32,8 +32,8 @@ await That(Act).Throws() } } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Delete_FullPath_ShouldDeleteDirectory(string directoryName) { IDirectoryInfo result = @@ -45,8 +45,8 @@ public async Task Delete_FullPath_ShouldDeleteDirectory(string directoryName) await That(result.Exists).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Delete_MissingDirectory_ShouldThrowDirectoryNotFoundException( string directoryName) { @@ -62,8 +62,8 @@ await That(Act).Throws() .WithHResult(-2147024893); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Delete_ReadonlyDirectory_ShouldThrowIOExceptionOnWindows(string path) { IDirectoryInfo sut = FileSystem.Directory.CreateDirectory(path); @@ -83,8 +83,8 @@ await That(Act).Throws() .WithHResult(-2146232800); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Delete_Recursive_MissingDirectory_ShouldThrowDirectoryNotFoundException( string directoryName) { @@ -100,8 +100,8 @@ await That(Act).Throws() .WithHResult(-2147024893); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Delete_Recursive_WithFileInSubdirectory_ShouldDeleteDirectoryWithContent( string path, string subdirectory, string fileName, string fileContent) { @@ -124,8 +124,8 @@ public async Task Delete_Recursive_WithFileInSubdirectory_ShouldDeleteDirectoryW await That(FileSystem.File.Exists(subdirectoryFilePath)).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Delete_Recursive_WithOpenFile_ShouldThrowIOException_OnWindows( string path, string filename) { @@ -157,8 +157,8 @@ await That(Act).Throws() } } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Delete_Recursive_WithSimilarNamedFile_ShouldOnlyDeleteDirectoryAndItsContents( string subdirectory) @@ -176,8 +176,8 @@ public async Task await That(FileSystem.File.Exists(fileName)).IsTrue(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Delete_Recursive_WithSubdirectory_ShouldDeleteDirectoryWithContent( string path, string subdirectory) { @@ -191,8 +191,8 @@ public async Task Delete_Recursive_WithSubdirectory_ShouldDeleteDirectoryWithCon await That(FileSystem.Directory.Exists(subdirectoryPath)).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Delete_ShouldAdjustTimes(string path, string subdirectoryName) { SkipIfLongRunningTestsShouldBeSkipped(); @@ -225,8 +225,8 @@ await That(lastAccessTime).IsBetween(creationTimeStart).And(creationTimeEnd) await That(lastWriteTime).IsOnOrAfter(updateTime.ApplySystemClockTolerance()); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Delete_ShouldDeleteDirectory(string directoryName) { IDirectoryInfo result = @@ -238,8 +238,8 @@ public async Task Delete_ShouldDeleteDirectory(string directoryName) await That(result.Exists).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Delete_WhenFile_ShouldThrowIOException( string directoryName) { @@ -270,8 +270,8 @@ await That(Act).Throws() } } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Delete_WithSimilarNamedFile_ShouldOnlyDeleteDirectory( string subdirectory) { @@ -286,8 +286,8 @@ public async Task Delete_WithSimilarNamedFile_ShouldOnlyDeleteDirectory( await That(FileSystem.File.Exists(fileName)).IsTrue(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Delete_WithSubdirectory_ShouldThrowIOException_AndNotDeleteDirectory( string path, string subdirectory) { @@ -307,9 +307,9 @@ await That(Act).Throws() await That(FileSystem.Directory.Exists(path)).IsTrue(); } - [Theory] - [AutoData] - [InlineData(null)] + [Test] + [AutoArguments] + [Arguments(null)] public async Task Delete_CurrentDirectory_ShouldThrowIOException_OnWindows(string? nested) { // Arrange @@ -348,9 +348,9 @@ await That(Act).ThrowsExactly().OnlyIf(Test.RunsOnWindows).Which } } - [Theory] - [InlineData("next")] - [InlineData("next", "sub")] + [Test] + [Arguments("next")] + [Arguments("next", "sub")] public async Task Delete_DirNextToCurrentDirectory_ShouldNotThrow(params string[] paths) { // Arrange diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/Directory/EnumerateDirectoriesTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/Directory/EnumerateDirectoriesTests.cs index b6735390a..6570abf14 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/Directory/EnumerateDirectoriesTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/Directory/EnumerateDirectoriesTests.cs @@ -8,9 +8,9 @@ namespace Testably.Abstractions.Tests.FileSystem.Directory; [FileSystemTests] -public partial class EnumerateDirectoriesTests +public class EnumerateDirectoriesTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Fact] + [Test] public async Task EnumerateDirectories_AbsolutePath_ShouldNotIncludeTrailingSlash() { FileSystem.Directory.CreateDirectory("foo"); @@ -24,8 +24,8 @@ public async Task EnumerateDirectories_AbsolutePath_ShouldNotIncludeTrailingSlas await That(result).Contains(FileSystem.Path.Combine(BasePath, "bar")); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task EnumerateDirectories_MissingDirectory_ShouldThrowDirectoryNotFoundException( string path) @@ -41,8 +41,8 @@ await That(Act).Throws() await That(FileSystem.Directory.Exists(path)).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task EnumerateDirectories_MissingDirectory_ShouldThrowDirectoryNotFoundExceptionImmediately( string path) @@ -58,7 +58,7 @@ await That(Act).Throws() await That(FileSystem.Directory.Exists(path)).IsFalse(); } - [Fact] + [Test] public async Task EnumerateDirectories_RelativePath_ShouldNotIncludeTrailingSlash() { string path = "."; @@ -73,7 +73,7 @@ public async Task EnumerateDirectories_RelativePath_ShouldNotIncludeTrailingSlas await That(result).Contains(FileSystem.Path.Combine(path, "bar")); } - [Fact] + [Test] public async Task EnumerateDirectories_RelativePathToParentDirectory_ShouldNotIncludeTrailingSlash() { @@ -89,8 +89,8 @@ public async Task await That(result).Contains(FileSystem.Path.Combine(path, "bar")); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task EnumerateDirectories_SearchOptionAllDirectories_FullPath_ShouldReturnAllSubdirectoriesWithFullPath( string path) @@ -110,8 +110,8 @@ public async Task await That(result).Contains(FileSystem.Path.Combine(baseDirectory.FullName, "bar")); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task EnumerateDirectories_SearchOptionAllDirectories_ShouldReturnAllSubdirectories( string path) { @@ -129,20 +129,20 @@ public async Task EnumerateDirectories_SearchOptionAllDirectories_ShouldReturnAl await That(result).Contains(FileSystem.Path.Combine(path, "bar")); } - [Theory] + [Test] #if NETFRAMEWORK - [InlineAutoData(false, "")] + [AutoArguments(false, "")] #else - [InlineAutoData(true, "")] + [AutoArguments(true, "")] #endif - [InlineAutoData(true, "*")] - [InlineAutoData(true, ".")] - [InlineAutoData(true, "*.*")] - [InlineData(true, "a*c", "abc")] - [InlineData(true, "ab*c", "abc")] - [InlineData(true, "abc?", "abc")] - [InlineData(false, "ab?c", "abc")] - [InlineData(false, "ac", "abc")] + [AutoArguments(true, "*")] + [AutoArguments(true, ".")] + [AutoArguments(true, "*.*")] + [Arguments(true, "a*c", "abc")] + [Arguments(true, "ab*c", "abc")] + [Arguments(true, "abc?", "abc")] + [Arguments(false, "ab?c", "abc")] + [Arguments(false, "ac", "abc")] public async Task EnumerateDirectories_SearchPattern_ShouldReturnExpectedValue( bool expectToBeFound, string searchPattern, string subdirectoryName) { @@ -166,16 +166,16 @@ await That(result).IsEmpty() } } - [Theory] - [InlineAutoData(true, "*.xls", ".xls")] - [InlineAutoData(false, "*.x", ".xls")] + [Test] + [AutoArguments(true, "*.xls", ".xls")] + [AutoArguments(false, "*.x", ".xls")] #if NETFRAMEWORK - [InlineAutoData(true, "*.xls", ".xlsx")] + [AutoArguments(true, "*.xls", ".xlsx")] #else - [InlineAutoData(false, "*.xls", ".xlsx")] + [AutoArguments(false, "*.xls", ".xlsx")] #endif - [InlineAutoData(false, "foo.x", ".xls", "foo")] - [InlineAutoData(false, "?.xls", ".xlsx", "a")] + [AutoArguments(false, "foo.x", ".xls", "foo")] + [AutoArguments(false, "?.xls", ".xlsx", "a")] public async Task EnumerateDirectories_SearchPattern_WithFileExtension_ShouldReturnExpectedValue( bool expectToBeFound, string searchPattern, string extension, @@ -198,7 +198,7 @@ await That(result).HasSingle().Which.EndsWith(extension) } } - [Fact] + [Test] public async Task EnumerateDirectories_ShouldIncludeEmptyDirectoriesWithTrailingSlash() { string rootDirectory = "RootDir"; @@ -211,7 +211,7 @@ public async Task EnumerateDirectories_ShouldIncludeEmptyDirectoriesWithTrailing await That(FileSystem.Directory.EnumerateDirectories(rootDirectory)).HasCount(1); } - [Fact] + [Test] public async Task EnumerateDirectories_ShouldSupportExtendedLengthPaths1() { Skip.If(!Test.RunsOnWindows); @@ -227,7 +227,7 @@ await That(result) .InAnyOrder(); } - [Fact] + [Test] public async Task EnumerateDirectories_ShouldSupportExtendedLengthPaths2() { Skip.If(!Test.RunsOnWindows); @@ -243,9 +243,9 @@ await That(result) .InAnyOrder(); } - [Theory] - [InlineData('/')] - [InlineData('\\')] + [Test] + [Arguments('/')] + [Arguments('\\')] public async Task EnumerateDirectories_TrailingDirectorySeparator_ShouldBeTrimmed(char suffix) { Skip.IfNot(Test.RunsOnWindows || @@ -262,8 +262,8 @@ await That(result).HasSingle() } #if FEATURE_FILESYSTEM_ENUMERATION_OPTIONS - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task EnumerateDirectories_WithEnumerationOptions_ShouldConsiderAttributesToSkip( string path) { @@ -286,9 +286,9 @@ public async Task EnumerateDirectories_WithEnumerationOptions_ShouldConsiderAttr #endif #if FEATURE_FILESYSTEM_ENUMERATION_OPTIONS - [Theory] - [InlineData(true)] - [InlineData(false)] + [Test] + [Arguments(true)] + [Arguments(false)] public async Task EnumerateDirectories_WithEnumerationOptions_ShouldConsiderIgnoreInaccessible( bool ignoreInaccessible) { @@ -331,9 +331,9 @@ await That(Act).Throws() #endif #if FEATURE_FILESYSTEM_ENUMERATION_OPTIONS - [Theory] - [InlineAutoData(MatchCasing.CaseInsensitive)] - [InlineAutoData(MatchCasing.CaseSensitive)] + [Test] + [AutoArguments(MatchCasing.CaseInsensitive)] + [AutoArguments(MatchCasing.CaseSensitive)] public async Task EnumerateDirectories_WithEnumerationOptions_ShouldConsiderMatchCasing( MatchCasing matchCasing, string path) @@ -361,9 +361,9 @@ public async Task EnumerateDirectories_WithEnumerationOptions_ShouldConsiderMatc #endif #if FEATURE_FILESYSTEM_ENUMERATION_OPTIONS - [Theory] - [InlineAutoData(MatchType.Simple)] - [InlineAutoData(MatchType.Win32)] + [Test] + [AutoArguments(MatchType.Simple)] + [AutoArguments(MatchType.Win32)] public async Task EnumerateDirectories_WithEnumerationOptions_ShouldConsiderMatchType( MatchType matchType, string path) @@ -390,12 +390,12 @@ public async Task EnumerateDirectories_WithEnumerationOptions_ShouldConsiderMatc #endif #if FEATURE_FILESYSTEM_ENUMERATION_OPTIONS - [Theory] - [InlineAutoData(true, 0)] - [InlineAutoData(true, 1)] - [InlineAutoData(true, 2)] - [InlineAutoData(true, 3)] - [InlineAutoData(false, 2)] + [Test] + [AutoArguments(true, 0)] + [AutoArguments(true, 1)] + [AutoArguments(true, 2)] + [AutoArguments(true, 3)] + [AutoArguments(false, 2)] public async Task EnumerateDirectories_WithEnumerationOptions_ShouldConsiderMaxRecursionDepthWhenRecurseSubdirectoriesIsSet( bool recurseSubdirectories, @@ -443,9 +443,9 @@ public async Task #endif #if FEATURE_FILESYSTEM_ENUMERATION_OPTIONS - [Theory] - [InlineAutoData(true)] - [InlineAutoData(false)] + [Test] + [AutoArguments(true)] + [AutoArguments(false)] public async Task EnumerateDirectories_WithEnumerationOptions_ShouldConsiderRecurseSubdirectories( bool recurseSubdirectories, @@ -475,9 +475,9 @@ public async Task #endif #if FEATURE_FILESYSTEM_ENUMERATION_OPTIONS - [Theory] - [InlineAutoData(true)] - [InlineAutoData(false)] + [Test] + [AutoArguments(true)] + [AutoArguments(false)] public async Task EnumerateDirectories_WithEnumerationOptions_ShouldConsiderReturnSpecialDirectories( bool returnSpecialDirectories, @@ -507,7 +507,7 @@ public async Task #endif #if FEATURE_FILESYSTEM_ENUMERATION_OPTIONS - [Fact] + [Test] public async Task EnumerateDirectories_WithEnumerationOptions_ShouldConsiderReturnSpecialDirectoriesCorrectlyForPathRoots() { @@ -533,8 +533,8 @@ public async Task } #endif - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task EnumerateDirectories_WithNewline_ShouldThrowArgumentException( string path) { @@ -549,8 +549,8 @@ void Act() await That(Act).Throws().WithHResult(-2147024809); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task EnumerateDirectories_WithoutSearchString_ShouldReturnAllDirectSubdirectories( string path) { @@ -567,8 +567,8 @@ public async Task EnumerateDirectories_WithoutSearchString_ShouldReturnAllDirect await That(result).Contains(FileSystem.Path.Combine(path, "bar")); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task EnumerateDirectories_WithSearchPattern_ShouldReturnMatchingSubdirectory( string path) { @@ -583,8 +583,8 @@ public async Task EnumerateDirectories_WithSearchPattern_ShouldReturnMatchingSub await That(result).Contains(FileSystem.Path.Combine(path, "foo")); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task EnumerateDirectories_WithSearchPatternInSubdirectory_ShouldReturnMatchingSubdirectory( string path) @@ -600,7 +600,7 @@ public async Task await That(result).HasCount(2); } - [Fact] + [Test] public async Task EnumerateDirectories_WithTrailingSlash_ShouldEnumerateSubdirectories() { string queryPath = "foo" + FileSystem.Path.DirectorySeparatorChar; diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/Directory/EnumerateFileSystemInfosTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/Directory/EnumerateFileSystemInfosTests.cs index 6ebf8fe77..63243c45f 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/Directory/EnumerateFileSystemInfosTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/Directory/EnumerateFileSystemInfosTests.cs @@ -9,10 +9,10 @@ namespace Testably.Abstractions.Tests.FileSystem.Directory; [FileSystemTests] -public partial class EnumerateFileSystemInfosTests +public class EnumerateFileSystemInfosTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task EnumerateFileSystemEntries_MissingDirectory_ShouldThrowDirectoryNotFoundException( string path) @@ -28,8 +28,8 @@ await That(Act).Throws() await That(FileSystem.Directory.Exists(path)).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task EnumerateFileSystemEntries_MissingDirectory_ShouldThrowDirectoryNotFoundExceptionImmediately( string path) @@ -45,8 +45,8 @@ await That(Act).Throws() await That(FileSystem.Directory.Exists(path)).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task EnumerateFileSystemEntries_SearchOptionAllDirectories_FullPath_ShouldReturnAllFileSystemEntriesWithFullPath( string path) @@ -70,8 +70,8 @@ public async Task await That(result).Contains(initialized[2].FullName); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task EnumerateFileSystemEntries_SearchOptionAllDirectories_ShouldReturnAllFileSystemEntries( string path) @@ -92,20 +92,20 @@ public async Task await That(result).Contains(initialized[2].ToString()); } - [Theory] + [Test] #if NETFRAMEWORK - [InlineAutoData(false, "")] + [AutoArguments(false, "")] #else - [InlineAutoData(true, "")] + [AutoArguments(true, "")] #endif - [InlineAutoData(true, "*")] - [InlineAutoData(true, ".")] - [InlineAutoData(true, "*.*")] - [InlineData(true, "a*c", "abc")] - [InlineData(true, "ab*c", "abc")] - [InlineData(true, "abc?", "abc")] - [InlineData(false, "ab?c", "abc")] - [InlineData(false, "ac", "abc")] + [AutoArguments(true, "*")] + [AutoArguments(true, ".")] + [AutoArguments(true, "*.*")] + [Arguments(true, "a*c", "abc")] + [Arguments(true, "ab*c", "abc")] + [Arguments(true, "abc?", "abc")] + [Arguments(false, "ab?c", "abc")] + [Arguments(false, "ac", "abc")] public async Task EnumerateFileSystemEntries_SearchPattern_ShouldReturnExpectedValue( bool expectToBeFound, string searchPattern, string fileName) { @@ -126,8 +126,8 @@ await That(result).HasSingle().Which.EndsWith(fileName) } #if FEATURE_FILESYSTEM_ENUMERATION_OPTIONS - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task EnumerateFileSystemEntries_WithEnumerationOptions_ShouldConsiderSetOptions( string path) { @@ -154,8 +154,8 @@ public async Task EnumerateFileSystemEntries_WithEnumerationOptions_ShouldConsid } #endif - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task EnumerateFileSystemEntries_WithFileNameStartingWithDirectoryName_ShouldNotBeIncluded( string path) @@ -171,8 +171,8 @@ public async Task await That(result).IsEmpty(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task EnumerateFileSystemEntries_WithNewline_ShouldThrowArgumentException( string path) { @@ -191,8 +191,8 @@ await That(Act).Throws() Test.IsNetFramework ? null : $"'{searchPattern}'"); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task EnumerateFileSystemEntries_WithoutSearchString_ShouldReturnAllFileSystemEntriesInDirectSubdirectories( string path) @@ -216,8 +216,8 @@ public async Task await That(result).DoesNotContain(initialized[3].ToString()); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task EnumerateFileSystemEntries_WithSearchPattern_ShouldReturnMatchingFileSystemEntries( string path) @@ -239,7 +239,7 @@ public async Task await That(result).DoesNotContain(initialized[3].ToString()); } - [Fact] + [Test] public async Task EnumerateFileSystemEntries_WithSearchPatternInSubdirectory_ShouldReturnMatchingFileSystemEntriesInSubdirectories() { diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/Directory/EnumerateFilesTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/Directory/EnumerateFilesTests.cs index 3fe74f4fe..55a559cbe 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/Directory/EnumerateFilesTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/Directory/EnumerateFilesTests.cs @@ -6,10 +6,10 @@ namespace Testably.Abstractions.Tests.FileSystem.Directory; [FileSystemTests] -public partial class EnumerateFilesTests +public class EnumerateFilesTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task EnumerateFiles_MissingDirectory_ShouldThrowDirectoryNotFoundException( string path) @@ -25,8 +25,8 @@ await That(Act).Throws() await That(FileSystem.Directory.Exists(path)).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task EnumerateFiles_MissingDirectory_ShouldThrowDirectoryNotFoundExceptionImmediately( string path) @@ -42,8 +42,8 @@ await That(Act).Throws() await That(FileSystem.Directory.Exists(path)).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task EnumerateFiles_SearchOptionAllDirectories_FullPath_ShouldReturnAllFilesWithFullPath( string path) @@ -64,8 +64,8 @@ public async Task await That(result).Contains(initialized[2].FullName); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task EnumerateFiles_SearchOptionAllDirectories_ShouldReturnAllFiles( string path) { @@ -84,20 +84,20 @@ public async Task EnumerateFiles_SearchOptionAllDirectories_ShouldReturnAllFiles await That(result).Contains(initialized[2].ToString()); } - [Theory] + [Test] #if NETFRAMEWORK - [InlineAutoData(false, "")] + [AutoArguments(false, "")] #else - [InlineAutoData(true, "")] + [AutoArguments(true, "")] #endif - [InlineAutoData(true, "*")] - [InlineAutoData(true, ".")] - [InlineAutoData(true, "*.*")] - [InlineData(true, "a*c", "abc")] - [InlineData(true, "ab*c", "abc")] - [InlineData(true, "abc?", "abc")] - [InlineData(false, "ab?c", "abc")] - [InlineData(false, "ac", "abc")] + [AutoArguments(true, "*")] + [AutoArguments(true, ".")] + [AutoArguments(true, "*.*")] + [Arguments(true, "a*c", "abc")] + [Arguments(true, "ab*c", "abc")] + [Arguments(true, "abc?", "abc")] + [Arguments(false, "ab?c", "abc")] + [Arguments(false, "ac", "abc")] public async Task EnumerateFiles_SearchPattern_ShouldReturnExpectedValue( bool expectToBeFound, string searchPattern, string fileName) { @@ -117,16 +117,16 @@ await That(result).HasSingle().Which.EndsWith(fileName) } } - [Theory] - [InlineAutoData(true, "*.xls", ".xls")] - [InlineAutoData(false, "*.x", ".xls")] + [Test] + [AutoArguments(true, "*.xls", ".xls")] + [AutoArguments(false, "*.x", ".xls")] #if NETFRAMEWORK - [InlineAutoData(true, "*.xls", ".xlsx")] + [AutoArguments(true, "*.xls", ".xlsx")] #else - [InlineAutoData(false, "*.xls", ".xlsx")] + [AutoArguments(false, "*.xls", ".xlsx")] #endif - [InlineAutoData(false, "foo.x", ".xls", "foo")] - [InlineAutoData(false, "?.xls", ".xlsx", "a")] + [AutoArguments(false, "foo.x", ".xls", "foo")] + [AutoArguments(false, "?.xls", ".xlsx", "a")] public async Task EnumerateFiles_SearchPattern_WithFileExtension_ShouldReturnExpectedValue( bool expectToBeFound, string searchPattern, string extension, string fileNameWithoutExtension) @@ -149,8 +149,8 @@ await That(result).HasSingle().Which.EndsWith(extension) } #if FEATURE_FILESYSTEM_ENUMERATION_OPTIONS - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task EnumerateFiles_WithEnumerationOptions_ShouldConsiderAttributesToSkip( string path) { @@ -174,9 +174,9 @@ public async Task EnumerateFiles_WithEnumerationOptions_ShouldConsiderAttributes #endif #if FEATURE_FILESYSTEM_ENUMERATION_OPTIONS - [Theory] - [InlineAutoData(MatchCasing.CaseInsensitive)] - [InlineAutoData(MatchCasing.CaseSensitive)] + [Test] + [AutoArguments(MatchCasing.CaseInsensitive)] + [AutoArguments(MatchCasing.CaseSensitive)] public async Task EnumerateFiles_WithEnumerationOptions_ShouldConsiderMatchCasing( MatchCasing matchCasing, string path) @@ -203,9 +203,9 @@ public async Task EnumerateFiles_WithEnumerationOptions_ShouldConsiderMatchCasin #endif #if FEATURE_FILESYSTEM_ENUMERATION_OPTIONS - [Theory] - [InlineAutoData(MatchType.Simple)] - [InlineAutoData(MatchType.Win32)] + [Test] + [AutoArguments(MatchType.Simple)] + [AutoArguments(MatchType.Win32)] public async Task EnumerateFiles_WithEnumerationOptions_ShouldConsiderMatchType( MatchType matchType, string path) @@ -231,12 +231,12 @@ public async Task EnumerateFiles_WithEnumerationOptions_ShouldConsiderMatchType( #endif #if FEATURE_FILESYSTEM_ENUMERATION_OPTIONS - [Theory] - [InlineAutoData(true, 0)] - [InlineAutoData(true, 1)] - [InlineAutoData(true, 2)] - [InlineAutoData(true, 3)] - [InlineAutoData(false, 2)] + [Test] + [AutoArguments(true, 0)] + [AutoArguments(true, 1)] + [AutoArguments(true, 2)] + [AutoArguments(true, 3)] + [AutoArguments(false, 2)] public async Task EnumerateFiles_WithEnumerationOptions_ShouldConsiderMaxRecursionDepthWhenRecurseSubdirectoriesIsSet( bool recurseSubdirectories, int maxRecursionDepth, @@ -288,9 +288,9 @@ public async Task EnumerateFiles_WithEnumerationOptions_ShouldConsiderMaxRecursi #endif #if FEATURE_FILESYSTEM_ENUMERATION_OPTIONS - [Theory] - [InlineAutoData(true)] - [InlineAutoData(false)] + [Test] + [AutoArguments(true)] + [AutoArguments(false)] public async Task EnumerateFiles_WithEnumerationOptions_ShouldConsiderRecurseSubdirectories( bool recurseSubdirectories, string path) @@ -318,9 +318,9 @@ public async Task EnumerateFiles_WithEnumerationOptions_ShouldConsiderRecurseSub #endif #if FEATURE_FILESYSTEM_ENUMERATION_OPTIONS - [Theory] - [InlineAutoData(true)] - [InlineAutoData(false)] + [Test] + [AutoArguments(true)] + [AutoArguments(false)] public async Task EnumerateFiles_WithEnumerationOptions_ShouldIgnoreReturnSpecialDirectories( bool returnSpecialDirectories, string path) @@ -342,8 +342,8 @@ public async Task EnumerateFiles_WithEnumerationOptions_ShouldIgnoreReturnSpecia } #endif - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task EnumerateFiles_WithNewline_ShouldThrowArgumentException( string path) { @@ -362,8 +362,8 @@ await That(Act).Throws() Test.IsNetFramework ? null : $"'{searchPattern}'"); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task EnumerateFiles_WithoutSearchString_ShouldReturnAllFilesInDirectSubdirectories( string path) { @@ -384,8 +384,8 @@ public async Task EnumerateFiles_WithoutSearchString_ShouldReturnAllFilesInDirec await That(result).DoesNotContain(initialized[3].ToString()); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task EnumerateFiles_WithSearchPattern_ShouldReturnMatchingFiles( string path) { @@ -406,7 +406,7 @@ public async Task EnumerateFiles_WithSearchPattern_ShouldReturnMatchingFiles( await That(result).DoesNotContain(initialized[3].ToString()); } - [Fact] + [Test] public async Task EnumerateFiles_WithSearchPatternInSubdirectory_ShouldReturnMatchingFilesInSubdirectories() { diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/Directory/ExceptionTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/Directory/ExceptionTests.cs index 614efb3eb..2bb688d93 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/Directory/ExceptionTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/Directory/ExceptionTests.cs @@ -6,10 +6,26 @@ namespace Testably.Abstractions.Tests.FileSystem.Directory; [FileSystemTests] -public partial class ExceptionTests +public class ExceptionTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [MemberData(nameof(GetDirectoryCallbacks), "Illegal\tCharacter?InPath")] + public static IEnumerable<(Expression>, string, bool, Func)> + GetDirectoryCallbacksWithEmptyPath() + => GetDirectoryCallbacks(""); + + public static IEnumerable<(Expression>, string, bool, Func)> + GetDirectoryCallbacksWithIllegalPathCharacters() + => GetDirectoryCallbacks("Illegal\tCharacter?InPath"); + + public static IEnumerable<(Expression>, string, bool, Func)> + GetDirectoryCallbacksWithNullPath() + => GetDirectoryCallbacks(null); + + public static IEnumerable<(Expression>, string, bool, Func)> + GetDirectoryCallbacksWithWhitespacePath() + => GetDirectoryCallbacks(" "); + + [Test] + [MethodDataSource(nameof(GetDirectoryCallbacksWithIllegalPathCharacters))] public async Task Operations_WhenValueContainsIllegalPathCharacters_ShouldThrowCorrectException_OnWindows( Expression> callback, string paramName, @@ -50,8 +66,8 @@ await That(Act).Throws() } } - [Theory] - [MemberData(nameof(GetDirectoryCallbacks), "")] + [Test] + [MethodDataSource(nameof(GetDirectoryCallbacksWithEmptyPath))] public async Task Operations_WhenValueIsEmpty_ShouldThrowArgumentException( Expression> callback, string paramName, bool ignoreParamCheck, Func skipTest) @@ -70,8 +86,8 @@ await That(Act).Throws() $"\n{callback}\n has empty parameter for '{paramName}' (ignored: {ignoreParamCheck})"); } - [Theory] - [MemberData(nameof(GetDirectoryCallbacks), (string?)null)] + [Test] + [MethodDataSource(nameof(GetDirectoryCallbacksWithNullPath))] public async Task Operations_WhenValueIsNull_ShouldThrowArgumentNullException( Expression> callback, string paramName, bool ignoreParamCheck, Func skipTest) @@ -89,8 +105,8 @@ await That(Act).Throws() $"\n{callback}\n has `null` parameter for '{paramName}' (ignored: {ignoreParamCheck})"); } - [Theory] - [MemberData(nameof(GetDirectoryCallbacks), " ")] + [Test] + [MethodDataSource(nameof(GetDirectoryCallbacksWithWhitespacePath))] public async Task Operations_WhenValueIsWhitespace_ShouldThrowArgumentException( Expression> callback, string paramName, bool ignoreParamCheck, Func skipTest) @@ -111,29 +127,21 @@ await That(Act).Throws() $"\n{callback}\n has whitespace parameter for '{paramName}' (ignored: {ignoreParamCheck})"); } - #region Helpers - - #pragma warning disable MA0018 - public static TheoryData>, string, bool, Func> + private static IEnumerable<(Expression>, string, bool, Func)> GetDirectoryCallbacks(string? path) { - TheoryData>, string, bool, Func> theoryData = - new(); foreach ((ExceptionTestHelper.TestTypes TestType, string ParamName, Expression> Callback, Func? SkipTest) item in GetDirectoryCallbackTestParameters(path!) .Where(item => item.TestType.HasFlag(path.ToTestType()))) { - theoryData.Add( + yield return ( item.Callback, item.ParamName, item.TestType.HasFlag(ExceptionTestHelper.TestTypes.IgnoreParamNameCheck), item.SkipTest ?? (_ => false)); } - - return theoryData; } - #pragma warning restore MA0018 private static IEnumerable<(ExceptionTestHelper.TestTypes TestType, string ParamName, Expression> Callback, Func? SkipTest)> @@ -345,6 +353,4 @@ public static TheoryData>, string, bool, Func directory.SetLastWriteTimeUtc(value, DateTime.Now), null); } - - #endregion } diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/Directory/ExistsTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/Directory/ExistsTests.cs index 84945eaf3..edae7efe8 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/Directory/ExistsTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/Directory/ExistsTests.cs @@ -1,11 +1,11 @@ namespace Testably.Abstractions.Tests.FileSystem.Directory; [FileSystemTests] -public partial class ExistsTests +public class ExistsTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [InlineData("foo")] - [InlineData("foo/")] + [Test] + [Arguments("foo")] + [Arguments("foo/")] public async Task Exists_ExistingDirectory_ShouldReturnTrue(string path) { FileSystem.Directory.CreateDirectory(path); @@ -15,8 +15,8 @@ public async Task Exists_ExistingDirectory_ShouldReturnTrue(string path) await That(result).IsTrue(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Exists_File_ShouldReturnFalse(string path) { FileSystem.File.WriteAllText(path, null); @@ -26,7 +26,7 @@ public async Task Exists_File_ShouldReturnFalse(string path) await That(result).IsFalse(); } - [Fact] + [Test] public async Task Exists_ForwardSlash_ShouldReturnTrue() { FileSystem.InitializeIn("/"); @@ -36,7 +36,7 @@ public async Task Exists_ForwardSlash_ShouldReturnTrue() await That(result).IsTrue(); } - [Fact] + [Test] public async Task Exists_ForwardSlashWithDirectory_ShouldReturnTrue() { FileSystem.Directory.CreateDirectory("/tmp"); @@ -46,10 +46,10 @@ public async Task Exists_ForwardSlashWithDirectory_ShouldReturnTrue() await That(result).IsTrue(); } - [Theory] - [InlineData(@"\\s")] - [InlineData("<")] - [InlineData("\t")] + [Test] + [Arguments(@"\\s")] + [Arguments("<")] + [Arguments("\t")] public async Task Exists_IllegalPath_ShouldReturnFalse(string path) { Skip.If(Test.IsNetFramework); @@ -59,9 +59,9 @@ public async Task Exists_IllegalPath_ShouldReturnFalse(string path) await That(result).IsFalse(); } - [Theory] - [InlineData("foo")] - [InlineData("foo/")] + [Test] + [Arguments("foo")] + [Arguments("foo/")] public async Task Exists_MissingDirectory_ShouldReturnFalse(string path) { bool result = FileSystem.Directory.Exists(path); @@ -69,7 +69,7 @@ public async Task Exists_MissingDirectory_ShouldReturnFalse(string path) await That(result).IsFalse(); } - [Fact] + [Test] public async Task Exists_Null_ShouldReturnFalse() { bool result = FileSystem.Directory.Exists(null); @@ -77,7 +77,7 @@ public async Task Exists_Null_ShouldReturnFalse() await That(result).IsFalse(); } - [Fact] + [Test] public async Task Exists_Whitespace_ShouldReturnFalse() { bool result = FileSystem.Directory.Exists(" "); diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/Directory/GetDirectoriesTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/Directory/GetDirectoriesTests.cs index 65bfc4687..24a1e0a67 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/Directory/GetDirectoriesTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/Directory/GetDirectoriesTests.cs @@ -5,10 +5,10 @@ namespace Testably.Abstractions.Tests.FileSystem.Directory; [FileSystemTests] -public partial class GetDirectoriesTests +public class GetDirectoriesTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetDirectories_MissingDirectory_ShouldThrowDirectoryNotFoundException( string path) @@ -24,8 +24,8 @@ await That(Act).Throws() await That(FileSystem.Directory.Exists(path)).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetDirectories_SearchOptionAllDirectories_FullPath_ShouldReturnAllSubdirectoriesWithFullPath( string path) @@ -45,8 +45,8 @@ public async Task await That(result).Contains(FileSystem.Path.Combine(baseDirectory.FullName, "bar")); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetDirectories_SearchOptionAllDirectories_ShouldReturnAllSubdirectories( string path) { @@ -64,20 +64,20 @@ public async Task GetDirectories_SearchOptionAllDirectories_ShouldReturnAllSubdi await That(result).Contains(FileSystem.Path.Combine(path, "bar")); } - [Theory] + [Test] #if NETFRAMEWORK - [InlineAutoData(false, "")] + [AutoArguments(false, "")] #else - [InlineAutoData(true, "")] + [AutoArguments(true, "")] #endif - [InlineAutoData(true, "*")] - [InlineAutoData(true, ".")] - [InlineAutoData(true, "*.*")] - [InlineData(true, "a*c", "abc")] - [InlineData(true, "ab*c", "abc")] - [InlineData(true, "abc?", "abc")] - [InlineData(false, "ab?c", "abc")] - [InlineData(false, "ac", "abc")] + [AutoArguments(true, "*")] + [AutoArguments(true, ".")] + [AutoArguments(true, "*.*")] + [Arguments(true, "a*c", "abc")] + [Arguments(true, "ab*c", "abc")] + [Arguments(true, "abc?", "abc")] + [Arguments(false, "ab?c", "abc")] + [Arguments(false, "ac", "abc")] public async Task GetDirectories_SearchPattern_ShouldReturnExpectedValue( bool expectToBeFound, string searchPattern, string subdirectoryName) { @@ -101,9 +101,9 @@ await That(result).IsEmpty() } } - [Theory] - [InlineData('/')] - [InlineData('\\')] + [Test] + [Arguments('/')] + [Arguments('\\')] public async Task GetDirectories_TrailingDirectorySeparator_ShouldBeTrimmed(char suffix) { Skip.IfNot(Test.RunsOnWindows || @@ -120,8 +120,8 @@ await That(result).HasSingle() } #if FEATURE_FILESYSTEM_ENUMERATION_OPTIONS - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetDirectories_WithEnumerationOptions_ShouldConsiderSetOptions( string path) { @@ -147,8 +147,8 @@ public async Task GetDirectories_WithEnumerationOptions_ShouldConsiderSetOptions } #endif - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetDirectories_WithNewline_ShouldThrowArgumentException( string path) { @@ -163,8 +163,8 @@ void Act() await That(Act).Throws().WithHResult(-2147024809); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetDirectories_WithoutSearchString_ShouldReturnAllDirectSubdirectories( string path) { @@ -181,7 +181,7 @@ public async Task GetDirectories_WithoutSearchString_ShouldReturnAllDirectSubdir await That(result).Contains(FileSystem.Path.Combine(path, "bar")); } - [Fact] + [Test] public async Task GetDirectories_WithRelativePath_ShouldReturnRelativePaths() { string path = $"foo{FileSystem.Path.DirectorySeparatorChar}bar"; @@ -192,8 +192,8 @@ public async Task GetDirectories_WithRelativePath_ShouldReturnRelativePaths() await That(result).IsEqualTo([path]); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetDirectories_WithSearchPattern_ShouldReturnMatchingSubdirectory( string path) { @@ -208,8 +208,8 @@ public async Task GetDirectories_WithSearchPattern_ShouldReturnMatchingSubdirect await That(result).Contains(FileSystem.Path.Combine(path, "foo")); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetDirectories_WithSearchPatternInSubdirectory_ShouldReturnMatchingSubdirectory( string path) diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/Directory/GetDirectoryRootTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/Directory/GetDirectoryRootTests.cs index a258483d7..50ebb2414 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/Directory/GetDirectoryRootTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/Directory/GetDirectoryRootTests.cs @@ -1,9 +1,9 @@ namespace Testably.Abstractions.Tests.FileSystem.Directory; [FileSystemTests] -public partial class GetDirectoryRootTests +public class GetDirectoryRootTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Fact] + [Test] public async Task GetDirectoryRoot_Empty_ShouldThrowArgumentException() { void Act() @@ -14,7 +14,7 @@ void Act() await That(Act).Throws().WithHResult(-2147024809); } - [Fact] + [Test] public async Task GetDirectoryRoot_ShouldReturnDefaultRoot() { string expectedRoot = FileTestHelper.RootDrive(Test); @@ -24,10 +24,10 @@ public async Task GetDirectoryRoot_ShouldReturnDefaultRoot() await That(result).IsEqualTo(expectedRoot); } - [Theory] - [InlineData('A')] - [InlineData('C')] - [InlineData('X')] + [Test] + [Arguments('A')] + [Arguments('C')] + [Arguments('X')] public async Task GetDirectoryRoot_SpecificDrive_ShouldReturnRootWithCorrectDrive( char drive) { diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/Directory/GetFileSystemInfosTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/Directory/GetFileSystemInfosTests.cs index 94749fb00..fee47c067 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/Directory/GetFileSystemInfosTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/Directory/GetFileSystemInfosTests.cs @@ -9,10 +9,10 @@ namespace Testably.Abstractions.Tests.FileSystem.Directory; [FileSystemTests] -public partial class GetFileSystemInfosTests +public class GetFileSystemInfosTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetFileSystemEntries_MissingDirectory_ShouldThrowDirectoryNotFoundException( string path) @@ -28,8 +28,8 @@ await That(Act).Throws() await That(FileSystem.Directory.Exists(path)).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetFileSystemEntries_SearchOptionAllDirectories_FullPath_ShouldReturnAllFileSystemEntriesWithFullPath( string path) @@ -53,8 +53,8 @@ public async Task await That(result).Contains(initialized[2].FullName); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetFileSystemEntries_SearchOptionAllDirectories_ShouldReturnAllFileSystemEntries( string path) @@ -75,20 +75,20 @@ public async Task await That(result).Contains(initialized[2].ToString()); } - [Theory] + [Test] #if NETFRAMEWORK - [InlineAutoData(false, "")] + [AutoArguments(false, "")] #else - [InlineAutoData(true, "")] + [AutoArguments(true, "")] #endif - [InlineAutoData(true, "*")] - [InlineAutoData(true, ".")] - [InlineAutoData(true, "*.*")] - [InlineData(true, "a*c", "abc")] - [InlineData(true, "ab*c", "abc")] - [InlineData(true, "abc?", "abc")] - [InlineData(false, "ab?c", "abc")] - [InlineData(false, "ac", "abc")] + [AutoArguments(true, "*")] + [AutoArguments(true, ".")] + [AutoArguments(true, "*.*")] + [Arguments(true, "a*c", "abc")] + [Arguments(true, "ab*c", "abc")] + [Arguments(true, "abc?", "abc")] + [Arguments(false, "ab?c", "abc")] + [Arguments(false, "ac", "abc")] public async Task GetFileSystemEntries_SearchPattern_ShouldReturnExpectedValue( bool expectToBeFound, string searchPattern, string fileName) { @@ -109,8 +109,8 @@ await That(result).HasSingle().Which.EndsWith(fileName) } #if FEATURE_FILESYSTEM_ENUMERATION_OPTIONS - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetFileSystemEntries_WithEnumerationOptions_ShouldConsiderSetOptions( string path) { @@ -137,8 +137,8 @@ public async Task GetFileSystemEntries_WithEnumerationOptions_ShouldConsiderSetO } #endif - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetFileSystemEntries_WithNewline_ShouldThrowArgumentException( string path) { @@ -157,8 +157,8 @@ await That(Act).Throws() Test.IsNetFramework ? null : $"'{searchPattern}'"); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetFileSystemEntries_WithoutSearchString_ShouldReturnAllFileSystemEntriesInDirectSubdirectories( string path) @@ -182,8 +182,8 @@ public async Task await That(result).DoesNotContain(initialized[3].ToString()); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetFileSystemEntries_WithSearchPattern_ShouldReturnMatchingFileSystemEntries( string path) { @@ -204,7 +204,7 @@ public async Task GetFileSystemEntries_WithSearchPattern_ShouldReturnMatchingFil await That(result).DoesNotContain(initialized[3].ToString()); } - [Fact] + [Test] public async Task GetFileSystemEntries_WithSearchPatternInSubdirectory_ShouldReturnMatchingFileSystemEntriesInSubdirectories() { diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/Directory/GetFilesTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/Directory/GetFilesTests.cs index 487e68008..2146e58b8 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/Directory/GetFilesTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/Directory/GetFilesTests.cs @@ -9,10 +9,10 @@ namespace Testably.Abstractions.Tests.FileSystem.Directory; [FileSystemTests] -public partial class GetFilesTests +public class GetFilesTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetFiles_MissingDirectory_ShouldThrowDirectoryNotFoundException( string path) @@ -28,8 +28,8 @@ await That(Act).Throws() await That(FileSystem.Directory.Exists(path)).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetFiles_Path_NotOnLinux_ShouldBeCaseInsensitive(string path) { Skip.If(Test.RunsOnLinux); @@ -43,8 +43,8 @@ public async Task GetFiles_Path_NotOnLinux_ShouldBeCaseInsensitive(string path) await That(result.Length).IsEqualTo(1); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetFiles_Path_OnLinux_ShouldBeCaseSensitive(string path) { Skip.IfNot(Test.RunsOnLinux); @@ -64,8 +64,8 @@ void Act() await That(result2.Length).IsEqualTo(1); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetFiles_SearchOptionAllDirectories_FullPath_ShouldReturnAllFilesWithFullPath( string path) { @@ -85,8 +85,8 @@ public async Task GetFiles_SearchOptionAllDirectories_FullPath_ShouldReturnAllFi await That(result).Contains(initialized[2].FullName); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetFiles_SearchOptionAllDirectories_ShouldReturnAllFiles( string path) { @@ -105,20 +105,20 @@ public async Task GetFiles_SearchOptionAllDirectories_ShouldReturnAllFiles( await That(result).Contains(initialized[2].ToString()); } - [Theory] + [Test] #if NETFRAMEWORK - [InlineAutoData(false, "")] + [AutoArguments(false, "")] #else - [InlineAutoData(true, "")] + [AutoArguments(true, "")] #endif - [InlineAutoData(true, "*")] - [InlineAutoData(true, ".")] - [InlineAutoData(true, "*.*")] - [InlineData(true, "a*c", "abc")] - [InlineData(true, "ab*c", "abc")] - [InlineData(true, "abc?", "abc")] - [InlineData(false, "ab?c", "abc")] - [InlineData(false, "ac", "abc")] + [AutoArguments(true, "*")] + [AutoArguments(true, ".")] + [AutoArguments(true, "*.*")] + [Arguments(true, "a*c", "abc")] + [Arguments(true, "ab*c", "abc")] + [Arguments(true, "abc?", "abc")] + [Arguments(false, "ab?c", "abc")] + [Arguments(false, "ac", "abc")] public async Task GetFiles_SearchPattern_ShouldReturnExpectedValue( bool expectToBeFound, string searchPattern, string fileName) { @@ -138,7 +138,7 @@ await That(result).HasSingle().Which.EndsWith(fileName) } } - [Fact] + [Test] public async Task GetFiles_SearchPatternForFileWithoutExtension_ShouldWorkConsistently() { FileSystem.Initialize() @@ -150,7 +150,7 @@ public async Task GetFiles_SearchPatternForFileWithoutExtension_ShouldWorkConsis await That(result.Length).IsEqualTo(1); } - [Fact] + [Test] public async Task GetFiles_SearchPatternWithDirectorySeparator_ShouldReturnFilesInSubdirectoryOnWindows() { @@ -176,7 +176,7 @@ public async Task } } - [Fact] + [Test] public async Task GetFiles_SearchPatternWithTooManyAsterisk_ShouldWorkConsistently() { FileSystem.Initialize() @@ -188,8 +188,8 @@ public async Task GetFiles_SearchPatternWithTooManyAsterisk_ShouldWorkConsistent } #if FEATURE_FILESYSTEM_ENUMERATION_OPTIONS - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetFiles_WithEnumerationOptions_ShouldConsiderSetOptions( string path) { @@ -216,8 +216,8 @@ public async Task GetFiles_WithEnumerationOptions_ShouldConsiderSetOptions( } #endif - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetFiles_WithNewline_ShouldThrowArgumentException( string path) { @@ -236,8 +236,8 @@ await That(Act).Throws() Test.IsNetFramework ? null : $"'{searchPattern}'"); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetFiles_WithoutSearchString_ShouldReturnAllFilesInDirectSubdirectories( string path) { @@ -258,8 +258,8 @@ public async Task GetFiles_WithoutSearchString_ShouldReturnAllFilesInDirectSubdi await That(result).DoesNotContain(initialized[3].ToString()); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetFiles_WithRelativePathAndSubfolders_ShouldReturnRelativeFilePath( string subfolder1, string subfolder2, string[] files) { @@ -280,8 +280,8 @@ public async Task GetFiles_WithRelativePathAndSubfolders_ShouldReturnRelativeFil await That(result).IsEqualTo(expectation).InAnyOrder(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetFiles_WithSearchPattern_ShouldReturnMatchingFiles( string path) { @@ -302,7 +302,7 @@ public async Task GetFiles_WithSearchPattern_ShouldReturnMatchingFiles( await That(result).DoesNotContain(initialized[3].ToString()); } - [Fact] + [Test] public async Task GetFiles_WithSearchPatternInSubdirectory_ShouldReturnMatchingFilesInSubdirectories() { diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/Directory/MoveTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/Directory/MoveTests.cs index 19b62df4c..c66eb2d80 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/Directory/MoveTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/Directory/MoveTests.cs @@ -4,10 +4,10 @@ namespace Testably.Abstractions.Tests.FileSystem.Directory; [FileSystemTests] -public partial class MoveTests +public class MoveTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Move_CaseOnlyChange_ShouldMoveDirectoryWithContent(string path) { Skip.If(Test.IsNetFramework); @@ -37,8 +37,8 @@ await That(FileSystem.Directory.GetDirectories(destination, initialized[4].Name, SearchOption.AllDirectories)).HasSingle(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Move_CaseOnlyChange_ShouldThrowIOException_OnNetFramework(string path) { Skip.IfNot(Test.IsNetFramework); @@ -56,8 +56,8 @@ void Act() await That(Act).Throws().WithHResult(-2146232800); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Move_DestinationDoesNotExist_ShouldThrowDirectoryNotFoundException( string source) { @@ -73,8 +73,8 @@ void Act() await That(Act).Throws().WithHResult(-2147024893); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Move_ShouldMoveAttributes(string source, string destination) { FileSystem.Initialize() @@ -89,8 +89,8 @@ await That(FileSystem.DirectoryInfo.New(destination).Attributes) .IsEqualTo(expectedAttributes); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Move_ShouldMoveDirectoryWithContent(string source, string destination) { IFileSystemDirectoryInitializer initialized = @@ -114,8 +114,8 @@ await That(FileSystem.Directory.GetDirectories(destination, initialized[4].Name, SearchOption.AllDirectories)).HasSingle(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Move_ShouldNotAdjustTimes(string source, string destination) { SkipIfLongRunningTestsShouldBeSkipped(); @@ -148,8 +148,8 @@ await That(lastWriteTime).IsBetween(creationTimeStart).And(creationTimeEnd) .Within(TimeComparison.Tolerance); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Move_SourceAndDestinationIdentical_ShouldThrowIOException(string path) { FileSystem.Initialize() @@ -163,8 +163,8 @@ void Act() await That(Act).Throws().WithHResult(-2146232800); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Move_WithLockedFile_ShouldStillMoveDirectory_NotOnWindows( string source, string destination) { @@ -202,8 +202,8 @@ await That( .HasSingle(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Move_WithLockedFile_ShouldThrowIOException_AndNotMoveDirectoryAtAll_OnWindows( string source, string destination) { @@ -239,8 +239,8 @@ await That(sourceDirectory.GetDirectories(initialized[4].Name, SearchOption.AllD .HasSingle(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Move_WithReadOnlyFile_ShouldMoveDirectoryWithContent( string source, string destination) { @@ -269,7 +269,7 @@ await That( .HasSingle(); } - [Fact] + [Test] public async Task Move_CurrentDirectory_ShouldThrowIOException_OnWindows() { // Arrange @@ -288,8 +288,8 @@ await That(Act).ThrowsExactly().OnlyIf(Test.RunsOnWindows).Which.Ha ); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Move_NestedCurrentDirectory_ShouldThrowIOException_OnWindows(string nested) { // Arrange @@ -322,9 +322,9 @@ await That(Act).ThrowsExactly().OnlyIf(Test.RunsOnWindows).Which } } - [Theory] - [InlineData("next")] - [InlineData("next", "sub")] + [Test] + [Arguments("next")] + [Arguments("next", "sub")] public async Task Move_DirNextToCurrentDirectory_ShouldNotThrow(params string[] paths) { // Arrange diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/Directory/ResolveLinkTargetTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/Directory/ResolveLinkTargetTests.cs index 36423e401..83ea21d5c 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/Directory/ResolveLinkTargetTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/Directory/ResolveLinkTargetTests.cs @@ -5,7 +5,7 @@ namespace Testably.Abstractions.Tests.FileSystem.Directory; [FileSystemTests] -public partial class ResolveLinkTargetTests +public class ResolveLinkTargetTests(FileSystemTestData testData) : FileSystemTestBase(testData) { #region Test Setup @@ -18,8 +18,8 @@ public partial class ResolveLinkTargetTests #endregion - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ResolveLinkTarget_AbsolutePath_ShouldFollowSymbolicLink( string path, string pathToTarget) { @@ -34,8 +34,8 @@ public async Task ResolveLinkTarget_AbsolutePath_ShouldFollowSymbolicLink( await That(target.Exists).IsTrue(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ResolveLinkTarget_FileWithDifferentCase_ShouldReturnPathToMissingDirectory( string path, string pathToTarget) { @@ -60,8 +60,8 @@ public async Task ResolveLinkTarget_FileWithDifferentCase_ShouldReturnPathToMiss } } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ResolveLinkTarget_FinalTarget_ShouldFollowSymbolicLinkToFinalTarget( string path, string pathToFinalTarget) { @@ -85,8 +85,8 @@ public async Task ResolveLinkTarget_FinalTarget_ShouldFollowSymbolicLinkToFinalT await That(target!.FullName).IsEqualTo(FileSystem.Path.GetFullPath(pathToFinalTarget)); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ResolveLinkTarget_FinalTargetWithTooManyLevels_ShouldThrowIOException( string path, string pathToFinalTarget) { @@ -113,8 +113,8 @@ await That(Act).Throws() .WithHResult(Test.RunsOnWindows ? -2147022975 : -2146232800); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ResolveLinkTarget_MissingDirectoryInLinkChain_ShouldReturnPathToMissingDirectory( string path, string pathToFinalTarget, string pathToMissingDirectory) { @@ -133,8 +133,8 @@ public async Task ResolveLinkTarget_MissingDirectoryInLinkChain_ShouldReturnPath await That(target!.FullName).IsEqualTo(FileSystem.Path.GetFullPath(pathToMissingDirectory)); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ResolveLinkTarget_NormalDirectory_ShouldReturnNull( string path) { @@ -146,8 +146,8 @@ public async Task ResolveLinkTarget_NormalDirectory_ShouldReturnNull( await That(target).IsNull(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ResolveLinkTarget_NormalFile_ShouldReturnNull( string path) { @@ -159,8 +159,8 @@ public async Task ResolveLinkTarget_NormalFile_ShouldReturnNull( await That(target).IsNull(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ResolveLinkTarget_RelativePath_ShouldFollowSymbolicLinkUnderWindows( string path, string pathToTarget) { @@ -175,8 +175,8 @@ public async Task ResolveLinkTarget_RelativePath_ShouldFollowSymbolicLinkUnderWi await That(target.Exists).IsTrue(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ResolveLinkTarget_TargetDeletedAfterLinkCreation_ShouldReturnNull( string path, string pathToTarget) { diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/Directory/SearchFilterTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/Directory/SearchFilterTests.cs index 947aafd12..800b904d7 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/Directory/SearchFilterTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/Directory/SearchFilterTests.cs @@ -5,12 +5,12 @@ namespace Testably.Abstractions.Tests.FileSystem.Directory; [FileSystemTests] -public partial class SearchFilterTests +public class SearchFilterTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [InlineAutoData("../", 4)] - [InlineAutoData("../*", 4)] - [InlineAutoData("../a*", 2)] + [Test] + [AutoArguments("../", 4)] + [AutoArguments("../*", 4)] + [AutoArguments("../a*", 2)] public async Task SearchPattern_Containing1InstanceOfTwoDotsAndDirectorySeparator_ShouldMatchExpectedFiles( string searchPattern, int expectedMatchingFiles) @@ -30,10 +30,10 @@ public async Task await That(result).Contains(FileSystem.Path.Combine(".", "..", "xyz", "a.test")); } - [Theory] - [InlineAutoData("../../", 5)] - [InlineAutoData("../../*", 5)] - [InlineAutoData("../../a*", 2)] + [Test] + [AutoArguments("../../", 5)] + [AutoArguments("../../*", 5)] + [AutoArguments("../../a*", 2)] public async Task SearchPattern_Containing2InstancesOfMultipleTwoDotsAndDirectorySeparator_ShouldMatchExpectedFiles( string searchPattern, int expectedMatchingFiles) @@ -59,10 +59,10 @@ public async Task await That(result).Contains(FileSystem.Path.Combine(".", "../..", "bar", "xyz", "a.test")); } - [Theory] - [InlineAutoData("../../../", 6)] - [InlineAutoData("../../../*", 6)] - [InlineAutoData("../../../a*", 2)] + [Test] + [AutoArguments("../../../", 6)] + [AutoArguments("../../../*", 6)] + [AutoArguments("../../../a*", 2)] public async Task SearchPattern_Containing3InstancesOfMultipleTwoDotsAndDirectorySeparator_ShouldMatchExpectedFiles( string searchPattern, int expectedMatchingFiles) @@ -91,7 +91,7 @@ await That(result) .Contains(FileSystem.Path.Combine(".", "../../..", "foo", "bar", "xyz", "a.test")); } - [Fact] + [Test] public async Task SearchPattern_ContainingAsterisk_ShouldReturnMatchingFiles() { FileSystem.Initialize() @@ -108,7 +108,7 @@ public async Task SearchPattern_ContainingAsterisk_ShouldReturnMatchingFiles() await That(result).Contains(FileSystem.Path.Combine(".", "another.test")); } - [Fact] + [Test] public async Task SearchPattern_ContainingQuestionMark_ShouldReturnMatchingFiles() { FileSystem.Initialize() @@ -124,7 +124,7 @@ public async Task SearchPattern_ContainingQuestionMark_ShouldReturnMatchingFiles await That(result[0]).IsEqualTo(FileSystem.Path.Combine(".", "a-test")); } - [Fact] + [Test] public async Task SearchPattern_ContainingTooManyInstancesOfMultipleTwoDotsAndDirectorySeparator_ShouldThrowUnauthorizedAccessException() { @@ -158,10 +158,10 @@ void Act() await That(Act).Throws().WithHResult(-2147024891); } - [Theory] - [InlineAutoData("../", 4)] - [InlineAutoData("../*", 4)] - [InlineAutoData("../a*", 2)] + [Test] + [Arguments("../", 4, "my-path")] + [Arguments("../*", 4, "my-path")] + [Arguments("../a*", 2, "my-path")] public async Task SearchPattern_ContainingTwoDotsAndDirectorySeparator_ShouldMatchExpectedFiles( string searchPattern, int expectedMatchingFiles, string path) { @@ -179,11 +179,11 @@ public async Task SearchPattern_ContainingTwoDotsAndDirectorySeparator_ShouldMat await That(result).Contains(FileSystem.Path.Combine(".", "..", path, "a.test")); } - [Theory] - [InlineAutoData("../")] - [InlineAutoData("../*")] - [InlineAutoData("../a*")] - [InlineAutoData("*t..")] + [Test] + [AutoArguments("../")] + [AutoArguments("../*")] + [AutoArguments("../a*")] + [AutoArguments("*t..")] public async Task SearchPattern_ContainingTwoDotsAndDirectorySeparator_ShouldThrowArgumentException_OnNetFramework( string searchPattern, string path) @@ -201,7 +201,7 @@ void Act() await That(Act).Throws().WithHResult(-2147024809); } - [Fact] + [Test] public async Task SearchPattern_ContainingWithTwoDots_ShouldContainMatchingFiles() { FileSystem.Initialize() @@ -215,7 +215,7 @@ public async Task SearchPattern_ContainingWithTwoDots_ShouldContainMatchingFiles await That(result.Length).IsEqualTo(1); } - [Fact] + [Test] public async Task SearchPattern_EndingWithTwoDots_ShouldNotMatchAnyFile() { Skip.If(Test.IsNetFramework); @@ -239,7 +239,7 @@ public async Task SearchPattern_EndingWithTwoDots_ShouldNotMatchAnyFile() } } - [Fact] + [Test] public async Task SearchPattern_Extension_ShouldReturnAllFilesWithTheExtension() { FileSystem.Initialize() @@ -257,7 +257,7 @@ public async Task SearchPattern_Extension_ShouldReturnAllFilesWithTheExtension() await That(result.Length).IsEqualTo(3); } - [Fact] + [Test] public async Task SearchPattern_Null_ShouldThrowArgumentNullException() { FileSystem.Initialize(); @@ -271,7 +271,7 @@ void Act() await That(Act).Throws().WithParamName("searchPattern"); } - [Fact] + [Test] public async Task SearchPattern_StarDot_ShouldReturnFilesWithoutExtension() { FileSystem.Initialize() @@ -294,15 +294,15 @@ public async Task SearchPattern_StarDot_ShouldReturnFilesWithoutExtension() } } - [Theory] + [Test] #if NETFRAMEWORK - [InlineAutoData(false, "")] + [AutoArguments(false, "")] #else - [InlineAutoData(true, "")] + [AutoArguments(true, "")] #endif - [InlineAutoData(true, "*")] - [InlineAutoData(true, ".")] - [InlineAutoData(true, "*.*")] + [AutoArguments(true, "*")] + [AutoArguments(true, ".")] + [AutoArguments(true, "*.*")] public async Task SearchPattern_WildCard_ShouldReturnFile( bool expectToBeFound, string searchPattern, string path) { diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/Directory/Tests.AdjustTimes.cs b/Tests/Testably.Abstractions.Tests/FileSystem/Directory/Tests.AdjustTimes.cs index 1453dba5b..3a7494424 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/Directory/Tests.AdjustTimes.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/Directory/Tests.AdjustTimes.cs @@ -2,8 +2,8 @@ namespace Testably.Abstractions.Tests.FileSystem.Directory; public partial class Tests { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AdjustTimes_WhenCreatingAFile_ShouldAdjustTimes( string path1, string path2, string fileName) { @@ -53,8 +53,8 @@ await That(rootLastWriteTime).IsBetween(creationTimeStart).And(creationTimeEnd) } #if FEATURE_FILESYSTEM_LINK - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AdjustTimes_WhenCreatingASymbolicLink_ShouldAdjustTimes( string path1, string path2, string fileName, string pathToTarget) { @@ -101,8 +101,8 @@ public async Task AdjustTimes_WhenCreatingASymbolicLink_ShouldAdjustTimes( } #endif - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AdjustTimes_WhenDeletingAFile_ShouldAdjustTimes( string path1, string path2, string fileName) { @@ -152,8 +152,8 @@ await That(rootLastWriteTime).IsBetween(creationTimeStart).And(creationTimeEnd) .Within(TimeComparison.Tolerance); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AdjustTimes_WhenUpdatingAFile_ShouldAdjustTimesOnlyOnWindows( string path1, string path2, string fileName) { diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/Directory/Tests.Times.cs b/Tests/Testably.Abstractions.Tests/FileSystem/Directory/Tests.Times.cs index 35749bb40..891212e13 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/Directory/Tests.Times.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/Directory/Tests.Times.cs @@ -4,8 +4,8 @@ namespace Testably.Abstractions.Tests.FileSystem.Directory; public partial class Tests { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetCreationTime_PathNotFound_ShouldReturnNullTime(string path) { DateTime expectedTime = FileTestHelper.NullTime.ToLocalTime(); @@ -15,8 +15,8 @@ public async Task GetCreationTime_PathNotFound_ShouldReturnNullTime(string path) await That(result).IsEqualTo(expectedTime); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetCreationTimeUtc_PathNotFound_ShouldReturnNullTime(string path) { DateTime expectedTime = FileTestHelper.NullTime.ToUniversalTime(); @@ -26,8 +26,8 @@ public async Task GetCreationTimeUtc_PathNotFound_ShouldReturnNullTime(string pa await That(result).IsEqualTo(expectedTime); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetLastAccessTime_PathNotFound_ShouldReturnNullTime(string path) { DateTime expectedTime = FileTestHelper.NullTime.ToLocalTime(); @@ -37,8 +37,8 @@ public async Task GetLastAccessTime_PathNotFound_ShouldReturnNullTime(string pat await That(result).IsEqualTo(expectedTime); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetLastAccessTimeUtc_PathNotFound_ShouldReturnNullTime(string path) { DateTime expectedTime = FileTestHelper.NullTime.ToUniversalTime(); @@ -48,8 +48,8 @@ public async Task GetLastAccessTimeUtc_PathNotFound_ShouldReturnNullTime(string await That(result).IsEqualTo(expectedTime); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetLastWriteTime_PathNotFound_ShouldReturnNullTime(string path) { DateTime expectedTime = FileTestHelper.NullTime.ToLocalTime(); @@ -59,8 +59,8 @@ public async Task GetLastWriteTime_PathNotFound_ShouldReturnNullTime(string path await That(result).IsEqualTo(expectedTime); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetLastWriteTimeUtc_PathNotFound_ShouldReturnNullTime(string path) { DateTime expectedTime = FileTestHelper.NullTime.ToUniversalTime(); @@ -70,8 +70,8 @@ public async Task GetLastWriteTimeUtc_PathNotFound_ShouldReturnNullTime(string p await That(result).IsEqualTo(expectedTime); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task LastAccessTime_CreateSubDirectory_ShouldUpdateLastAccessAndLastWriteTime( string path, string subPath) { @@ -101,8 +101,8 @@ await That(result.LastWriteTime).IsBetween(sleepTime).And(TimeSystem.DateTime.No .Within(TimeComparison.Tolerance); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task LastAccessTime_ShouldBeSet(string path) { DateTime start = TimeSystem.DateTime.Now; @@ -115,8 +115,8 @@ await That(result).IsBetween(start).And(TimeSystem.DateTime.Now) await That(result.Kind).IsEqualTo(DateTimeKind.Local); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task LastAccessTimeUtc_ShouldBeSet(string path) { DateTime start = TimeSystem.DateTime.UtcNow; @@ -129,8 +129,8 @@ await That(result).IsBetween(start).And(TimeSystem.DateTime.UtcNow) await That(result.Kind).IsEqualTo(DateTimeKind.Utc); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task LastWriteTime_ShouldBeSet(string path) { DateTime start = TimeSystem.DateTime.Now; @@ -143,8 +143,8 @@ await That(result).IsBetween(start).And(TimeSystem.DateTime.Now) await That(result.Kind).IsEqualTo(DateTimeKind.Local); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task LastWriteTimeUtc_ShouldBeSet(string path) { DateTime start = TimeSystem.DateTime.UtcNow; @@ -157,8 +157,8 @@ await That(result).IsBetween(start).And(TimeSystem.DateTime.UtcNow) await That(result.Kind).IsEqualTo(DateTimeKind.Utc); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task SetCreationTime_PathNotFound_ShouldThrowCorrectException( string path, DateTime creationTime) { @@ -181,8 +181,8 @@ await That(Act).Throws() } } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task SetCreationTime_ShouldChangeCreationTime( string path, DateTime creationTime) { @@ -198,8 +198,8 @@ public async Task SetCreationTime_ShouldChangeCreationTime( await That(FileSystem.Directory.GetCreationTimeUtc(path)).IsEqualTo(expectedTime); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task SetCreationTime_Unspecified_ShouldChangeCreationTime( string path, DateTime creationTime) { @@ -218,8 +218,8 @@ await That(FileSystem.Directory.GetCreationTime(path).Kind) .IsNotEqualTo(DateTimeKind.Unspecified); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task SetCreationTimeUtc_PathNotFound_ShouldThrowCorrectException( string path, DateTime creationTime) { @@ -242,8 +242,8 @@ await That(Act).Throws() } } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task SetCreationTimeUtc_ShouldChangeCreationTime( string path, DateTime creationTime) { @@ -259,8 +259,8 @@ public async Task SetCreationTimeUtc_ShouldChangeCreationTime( await That(FileSystem.Directory.GetCreationTime(path)).IsEqualTo(expectedTime); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task SetCreationTimeUtc_Unspecified_ShouldChangeCreationTime( string path, DateTime creationTime) { @@ -279,8 +279,8 @@ await That(FileSystem.Directory.GetCreationTime(path).Kind) .IsNotEqualTo(DateTimeKind.Unspecified); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task SetLastAccessTime_PathNotFound_ShouldThrowCorrectException( string path, DateTime lastAccessTime) { @@ -303,8 +303,8 @@ await That(Act).Throws() } } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task SetLastAccessTime_ShouldChangeLastAccessTime( string path, DateTime lastAccessTime) { @@ -317,8 +317,8 @@ public async Task SetLastAccessTime_ShouldChangeLastAccessTime( await That(FileSystem.Directory.GetLastAccessTimeUtc(path)).IsEqualTo(expectedTime); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task SetLastAccessTime_Unspecified_ShouldChangeLastAccessTime( string path, DateTime lastAccessTime) { @@ -334,8 +334,8 @@ await That(FileSystem.Directory.GetLastAccessTime(path).Kind) .IsNotEqualTo(DateTimeKind.Unspecified); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task SetLastAccessTimeUtc_PathNotFound_ShouldThrowCorrectException( string path, DateTime lastAccessTime) { @@ -358,8 +358,8 @@ await That(Act).Throws() } } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task SetLastAccessTimeUtc_ShouldChangeLastAccessTime( string path, DateTime lastAccessTime) { @@ -372,8 +372,8 @@ public async Task SetLastAccessTimeUtc_ShouldChangeLastAccessTime( await That(FileSystem.Directory.GetLastAccessTime(path)).IsEqualTo(expectedTime); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task SetLastAccessTimeUtc_Unspecified_ShouldChangeLastAccessTime( string path, DateTime lastAccessTime) { @@ -389,8 +389,8 @@ await That(FileSystem.Directory.GetLastAccessTime(path).Kind) .IsNotEqualTo(DateTimeKind.Unspecified); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task SetLastWriteTime_PathNotFound_ShouldThrowCorrectException( string path, DateTime lastWriteTime) { @@ -413,8 +413,8 @@ await That(Act).Throws() } } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task SetLastWriteTime_ShouldChangeLastWriteTime( string path, DateTime lastWriteTime) { @@ -427,8 +427,8 @@ public async Task SetLastWriteTime_ShouldChangeLastWriteTime( await That(FileSystem.Directory.GetLastWriteTimeUtc(path)).IsEqualTo(expectedTime); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task SetLastWriteTime_Unspecified_ShouldChangeLastWriteTime( string path, DateTime lastWriteTime) { @@ -444,8 +444,8 @@ await That(FileSystem.Directory.GetLastWriteTime(path).Kind) .IsNotEqualTo(DateTimeKind.Unspecified); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task SetLastWriteTimeUtc_PathNotFound_ShouldThrowCorrectException( string path, DateTime lastWriteTime) { @@ -468,8 +468,8 @@ await That(Act).Throws() } } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task SetLastWriteTimeUtc_ShouldChangeLastWriteTime( string path, DateTime lastWriteTime) { @@ -482,8 +482,8 @@ public async Task SetLastWriteTimeUtc_ShouldChangeLastWriteTime( await That(FileSystem.Directory.GetLastWriteTime(path)).IsEqualTo(expectedTime); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task SetLastWriteTimeUtc_Unspecified_ShouldChangeLastWriteTime( string path, DateTime lastWriteTime) { diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/Directory/Tests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/Directory/Tests.cs index f657293c0..29413c0cd 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/Directory/Tests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/Directory/Tests.cs @@ -3,10 +3,10 @@ namespace Testably.Abstractions.Tests.FileSystem.Directory; [FileSystemTests] -public partial class Tests +public partial class Tests(FileSystemTestData testData) : FileSystemTestBase(testData) { #if FEATURE_FILESYSTEM_NET_7_OR_GREATER - [Fact] + [Test] public async Task CreateTempSubdirectory_ShouldCreateTheTemporaryDirectory() { IDirectoryInfo result = FileSystem.Directory.CreateTempSubdirectory(); @@ -16,8 +16,8 @@ public async Task CreateTempSubdirectory_ShouldCreateTheTemporaryDirectory() #endif #if FEATURE_FILESYSTEM_NET_7_OR_GREATER - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateTempSubdirectory_WithPrefix_ShouldStartWithPrefix(string prefix) { IDirectoryInfo result = FileSystem.Directory.CreateTempSubdirectory(prefix); @@ -25,7 +25,7 @@ public async Task CreateTempSubdirectory_WithPrefix_ShouldStartWithPrefix(string await That(result.Name).StartsWith(prefix); } #endif - [Fact] + [Test] public async Task GetCurrentDirectory_ShouldNotBeRooted() { string result = FileSystem.Directory.GetCurrentDirectory(); @@ -33,8 +33,8 @@ public async Task GetCurrentDirectory_ShouldNotBeRooted() await That(result).IsNotEqualTo(FileTestHelper.RootDrive(Test)); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetDirectoryRoot_ShouldReturnRoot(string path) { string root = FileTestHelper.RootDrive(Test); @@ -45,7 +45,7 @@ public async Task GetDirectoryRoot_ShouldReturnRoot(string path) await That(result).IsEqualTo(root); } - [Fact] + [Test] public async Task GetLogicalDrives_ShouldNotBeEmpty() { string[] result = FileSystem.Directory.GetLogicalDrives(); @@ -54,8 +54,8 @@ public async Task GetLogicalDrives_ShouldNotBeEmpty() await That(result).Contains(FileTestHelper.RootDrive(Test)); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetParent_ArbitraryPaths_ShouldNotBeNull(string path1, string path2, string path3) @@ -70,7 +70,7 @@ public async Task GetParent_ArbitraryPaths_ShouldNotBeNull(string path1, await That(result!.FullName).IsEqualTo(expectedParent.FullName); } - [Fact] + [Test] public async Task GetParent_Root_ShouldReturnNull() { string path = FileTestHelper.RootDrive(Test); @@ -80,8 +80,8 @@ public async Task GetParent_Root_ShouldReturnNull() await That(result).IsNull(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task SetCurrentDirectory_MissingDirectory_ShouldThrowDirectoryNotFoundException( string path) @@ -104,8 +104,8 @@ await That(FileSystem.Directory.GetCurrentDirectory()) } } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task SetCurrentDirectory_RelativePath_ShouldBeFullyQualified(string path) { string previousCurrentDirectory = FileSystem.Directory.GetCurrentDirectory(); diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/Directory/UnixFileModeTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/Directory/UnixFileModeTests.cs index 33da74561..729cf8e44 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/Directory/UnixFileModeTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/Directory/UnixFileModeTests.cs @@ -5,9 +5,9 @@ namespace Testably.Abstractions.Tests.FileSystem.Directory; [FileSystemTests] -public partial class UnixFileModeTests +public class UnixFileModeTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Fact] + [Test] public async Task CreateDirectory_WhenUnixFileModeOfParentIsNone_ShouldThrowUnauthorizedAccessException() { @@ -25,7 +25,7 @@ await That(Act).Throws() .WithMessage("Access to the path '*/parent/child' is denied.").AsWildcard(); } - [Fact] + [Test] public async Task DeleteDirectory_WhenParentUnixFileModeIsNone_ShouldThrowUnauthorizedAccessException() { @@ -47,7 +47,7 @@ await That(Act).Throws() .WithMessage("Access to the path '*/parent/child' is denied.").AsWildcard(); } - [Fact] + [Test] public async Task DeleteDirectory_WhenUnixFileModeIsNone_ShouldNotThrow() { Skip.If(Test.RunsOnWindows, "UnixFileMode is not supported on Windows"); @@ -63,7 +63,7 @@ void Act() await That(FileSystem.Directory.Exists("parent")).IsFalse(); } - [Fact] + [Test] public async Task GetDirectories_WhenSubdirectoryHasUnixFileModeSetToNone_ShouldStillIncludeBothDirectories() { @@ -79,7 +79,7 @@ public async Task await That(result).HasCount(2); } - [Fact] + [Test] public async Task GetDirectories_WhenUnixFileModeIsNone_ShouldThrowUnauthorizedAccessException() { Skip.If(Test.RunsOnWindows, "UnixFileMode is not supported on Windows"); diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/AttributesTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/AttributesTests.cs index af1159632..09680527a 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/AttributesTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/AttributesTests.cs @@ -3,10 +3,10 @@ namespace Testably.Abstractions.Tests.FileSystem.DirectoryInfo; [FileSystemTests] -public partial class AttributesTests +public class AttributesTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Attributes_ClearAllAttributes_ShouldRemainDirectory(string path) { FileSystem.Directory.CreateDirectory(path); @@ -19,9 +19,9 @@ public async Task Attributes_ClearAllAttributes_ShouldRemainDirectory(string pat await That(sut.Attributes).HasFlag(FileAttributes.Directory); } - [Theory] - [InlineAutoData(FileAttributes.ReadOnly)] - [InlineAutoData(FileAttributes.Normal)] + [Test] + [AutoArguments(FileAttributes.ReadOnly)] + [AutoArguments(FileAttributes.Normal)] public async Task Attributes_WhenFileIsExisting_SetterShouldChangeAttributesOnFileSystem( FileAttributes attributes, string path) { @@ -35,7 +35,7 @@ public async Task Attributes_WhenFileIsExisting_SetterShouldChangeAttributesOnFi await That(sut2.Attributes).IsEqualTo(expectedAttributes); } - [Fact] + [Test] public async Task Attributes_WhenFileIsMissing_SetterShouldThrowFileNotFoundException() { IDirectoryInfo sut = FileSystem.DirectoryInfo.New("missing file"); @@ -48,7 +48,7 @@ void Act() await That(Act).Throws().WithHResult(-2147024894); } - [Fact] + [Test] public async Task Attributes_WhenFileIsMissing_ShouldReturnMinusOne() { IDirectoryInfo sut = FileSystem.DirectoryInfo.New("missing file"); diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/CreateAsSymbolicLinkTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/CreateAsSymbolicLinkTests.cs index 811f4c782..95c45ea66 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/CreateAsSymbolicLinkTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/CreateAsSymbolicLinkTests.cs @@ -4,10 +4,10 @@ namespace Testably.Abstractions.Tests.FileSystem.DirectoryInfo; [FileSystemTests] -public partial class CreateAsSymbolicLinkTests +public class CreateAsSymbolicLinkTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateAsSymbolicLink_ShouldCreateAsSymbolicLink( string path, string pathToTarget) { @@ -19,8 +19,8 @@ await That(FileSystem.DirectoryInfo.New(path).Attributes) .HasFlag(FileAttributes.ReparsePoint); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateAsSymbolicLink_SourceDirectoryAlreadyExists_ShouldThrowIOException( string path, string pathToTarget) { @@ -37,8 +37,8 @@ await That(Act).Throws() .WithHResult(Test.RunsOnWindows ? -2147024713 : 17); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateAsSymbolicLink_TargetDirectoryMissing_ShouldNotThrowException( string path, string pathToTarget) { @@ -50,8 +50,8 @@ void Act() await That(Act).DoesNotThrow(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateAsSymbolicLink_WithIllegalCharactersInTarget_ShouldThrowIOException( string path) { @@ -67,8 +67,8 @@ void Act() await That(Act).Throws().WithHResult(-2147024713); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateAsSymbolicLink_WithIllegalTarget_ShouldNotThrowException(string path) { void Act() diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/CreateSubdirectoryTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/CreateSubdirectoryTests.cs index d438d7a3e..b440de23d 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/CreateSubdirectoryTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/CreateSubdirectoryTests.cs @@ -3,10 +3,10 @@ namespace Testably.Abstractions.Tests.FileSystem.DirectoryInfo; [FileSystemTests] -public partial class CreateSubdirectoryTests +public class CreateSubdirectoryTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateSubdirectory_FileWithSameNameAlreadyExists_ShouldThrowIOException( string name) { @@ -22,8 +22,8 @@ void Act() await That(FileSystem.Directory.Exists(name)).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateSubdirectory_MissingParent_ShouldCreateDirectory( string path, string subdirectory) { @@ -37,8 +37,8 @@ public async Task CreateSubdirectory_MissingParent_ShouldCreateDirectory( await That(FileSystem.Directory.Exists(result.FullName)).IsTrue(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateSubdirectory_ShouldCreateDirectory(string path, string subdirectory) { IDirectoryInfo sut = FileSystem.DirectoryInfo.New(path); diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/CreateTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/CreateTests.cs index 61af4f897..826a95a6f 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/CreateTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/CreateTests.cs @@ -4,10 +4,10 @@ namespace Testably.Abstractions.Tests.FileSystem.DirectoryInfo; [FileSystemTests] -public partial class CreateTests +public class CreateTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Create_FileWithSameNameAlreadyExists_ShouldThrowIOException(string name) { FileSystem.File.WriteAllText(name, ""); @@ -22,8 +22,8 @@ void Act() await That(FileSystem.Directory.Exists(name)).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Create_ShouldCreateDirectory(string path) { IDirectoryInfo sut = FileSystem.DirectoryInfo.New(path); @@ -40,7 +40,7 @@ public async Task Create_ShouldCreateDirectory(string path) await That(FileSystem.Directory.Exists(sut.FullName)).IsTrue(); } - [Fact] + [Test] public async Task Create_ShouldCreateInBasePath() { IDirectoryInfo result = FileSystem.DirectoryInfo.New("foo"); @@ -51,7 +51,7 @@ public async Task Create_ShouldCreateInBasePath() await That(result.FullName).StartsWith(BasePath); } - [Fact] + [Test] public async Task Create_ShouldCreateParentDirectories() { string directoryLevel1 = "lvl1"; @@ -72,8 +72,8 @@ public async Task Create_ShouldCreateParentDirectories() await That(result.ToString()).IsEqualTo(path); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Create_ShouldRefreshExistsCacheForCurrentItem_ExceptOnNetFramework( string path) { @@ -102,10 +102,10 @@ public async Task Create_ShouldRefreshExistsCacheForCurrentItem_ExceptOnNetFrame await That(FileSystem.Directory.Exists(path)).IsTrue(); } - [Theory] - [InlineData("")] - [InlineData("/")] - [InlineData("\\")] + [Test] + [Arguments("")] + [Arguments("/")] + [Arguments("\\")] public async Task Create_TrailingDirectorySeparator_ShouldNotBeTrimmed( string suffix) { @@ -136,7 +136,7 @@ await That(result.FullName).IsEqualTo(FileSystem.Path.Combine(BasePath, expected await That(FileSystem.Directory.Exists(nameWithSuffix)).IsTrue(); } - [Fact] + [Test] public async Task CreateDirectory_WithoutAccessRightsToParent_ShouldThrowUnauthorizedAccessException() { diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/DeleteTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/DeleteTests.cs index 481fc28cc..bd3fce734 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/DeleteTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/DeleteTests.cs @@ -3,10 +3,10 @@ namespace Testably.Abstractions.Tests.FileSystem.DirectoryInfo; [FileSystemTests] -public partial class DeleteTests +public class DeleteTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Delete_MissingDirectory_ShouldThrowDirectoryNotFoundException(string path) { IDirectoryInfo sut = FileSystem.DirectoryInfo.New(path); @@ -22,8 +22,8 @@ await That(Act).Throws() .WithHResult(-2147024893); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Delete_ReadonlyDirectory_ShouldThrowIOExceptionOnWindows(string path) { IDirectoryInfo sut = FileSystem.Directory.CreateDirectory(path); @@ -43,8 +43,8 @@ await That(Act).Throws() .WithHResult(-2146232800); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Delete_Recursive_WithOpenFile_ShouldThrowIOException_OnWindows( string path, string filename) { @@ -77,8 +77,8 @@ await That(Act).Throws() } } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Delete_Recursive_WithSubdirectory_ShouldDeleteDirectoryWithContent( string path, string subdirectory) { @@ -99,8 +99,8 @@ public async Task Delete_Recursive_WithSubdirectory_ShouldDeleteDirectoryWithCon await That(FileSystem.Directory.Exists(subdirectoryPath)).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Delete_ShouldDeleteDirectory(string path) { FileSystem.Directory.CreateDirectory(path); @@ -118,8 +118,8 @@ public async Task Delete_ShouldDeleteDirectory(string path) await That(FileSystem.Directory.Exists(sut.FullName)).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Delete_WithSubdirectory_ShouldThrowIOException_AndNotDeleteDirectory( string path, string subdirectory) { @@ -144,9 +144,9 @@ await That(Act).Throws() await That(FileSystem.Directory.Exists(sut.FullName)).IsTrue(); } - [Theory] - [AutoData] - [InlineData(null)] + [Test] + [AutoArguments] + [Arguments(null)] public async Task Delete_CurrentDirectory_ShouldThrowIOException_OnWindows(string? nested) { // Arrange @@ -185,9 +185,9 @@ await That(Act).ThrowsExactly().OnlyIf(Test.RunsOnWindows).Which } } - [Theory] - [InlineData("next")] - [InlineData("next", "sub")] + [Test] + [Arguments("next")] + [Arguments("next", "sub")] public async Task Delete_DirNextToCurrentDirectory_ShouldNotThrow(params string[] paths) { // Arrange diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/EnumerateDirectoriesTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/EnumerateDirectoriesTests.cs index 2664018d9..a1d7b9814 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/EnumerateDirectoriesTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/EnumerateDirectoriesTests.cs @@ -6,10 +6,10 @@ namespace Testably.Abstractions.Tests.FileSystem.DirectoryInfo; [FileSystemTests] -public partial class EnumerateDirectoriesTests +public class EnumerateDirectoriesTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task EnumerateDirectories_SearchOptionAllDirectories_ShouldReturnAllSubdirectories( string path) { @@ -30,20 +30,20 @@ public async Task EnumerateDirectories_SearchOptionAllDirectories_ShouldReturnAl await That(result).Contains(d => string.Equals(d.Name, "xyz", StringComparison.Ordinal)); } - [Theory] + [Test] #if NETFRAMEWORK - [InlineAutoData(false, "")] + [AutoArguments(false, "")] #else - [InlineAutoData(true, "")] + [AutoArguments(true, "")] #endif - [InlineAutoData(true, "*")] - [InlineAutoData(true, ".")] - [InlineAutoData(true, "*.*")] - [InlineData(true, "a*c", "abc")] - [InlineData(true, "ab*c", "abc")] - [InlineData(true, "abc?", "abc")] - [InlineData(false, "ab?c", "abc")] - [InlineData(false, "ac", "abc")] + [AutoArguments(true, "*")] + [AutoArguments(true, ".")] + [AutoArguments(true, "*.*")] + [Arguments(true, "a*c", "abc")] + [Arguments(true, "ab*c", "abc")] + [Arguments(true, "abc?", "abc")] + [Arguments(false, "ab?c", "abc")] + [Arguments(false, "ac", "abc")] public async Task EnumerateDirectories_SearchPattern_ShouldReturnExpectedValue( bool expectToBeFound, string searchPattern, string subdirectoryName) { @@ -68,8 +68,8 @@ await That(result).IsEmpty() } #if FEATURE_FILESYSTEM_ENUMERATION_OPTIONS - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task EnumerateDirectories_WithEnumerationOptions_ShouldConsiderSetOptions( string path) { @@ -97,8 +97,8 @@ await That(result).DoesNotContain(d } #endif - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task EnumerateDirectories_WithNewline_ShouldThrowArgumentException( string path) { @@ -114,8 +114,8 @@ void Act() await That(Act).Throws().WithHResult(-2147024809); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task EnumerateDirectories_WithoutSearchString_ShouldReturnAllDirectSubdirectories( string path) { @@ -134,8 +134,8 @@ await That(result) await That(result).Contains(d => string.Equals(d.Name, "bar", StringComparison.Ordinal)); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task EnumerateDirectories_WithSearchPattern_ShouldReturnMatchingSubdirectory( string path) { @@ -151,8 +151,8 @@ await That(result).HasSingle() .Matching(d => string.Equals(d.Name, "foo", StringComparison.Ordinal)); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task EnumerateDirectories_WithSearchPatternInSubdirectory_ShouldReturnMatchingSubdirectory( string path) diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/EnumerateFileSystemInfosTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/EnumerateFileSystemInfosTests.cs index 53d6822d6..317b49ed3 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/EnumerateFileSystemInfosTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/EnumerateFileSystemInfosTests.cs @@ -6,10 +6,10 @@ namespace Testably.Abstractions.Tests.FileSystem.DirectoryInfo; [FileSystemTests] -public partial class EnumerateFileSystemInfosTests +public class EnumerateFileSystemInfosTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task EnumerateFileSystemInfos_SearchOptionAllFiles_ShouldReturnAllFiles( string path) { @@ -40,20 +40,20 @@ await That(result).Contains(d => string.Equals(d.Name, initialized[5].Name, StringComparison.Ordinal)); } - [Theory] + [Test] #if NETFRAMEWORK - [InlineAutoData(false, "")] + [AutoArguments(false, "")] #else - [InlineAutoData(true, "")] + [AutoArguments(true, "")] #endif - [InlineAutoData(true, "*")] - [InlineAutoData(true, ".")] - [InlineAutoData(true, "*.*")] - [InlineData(true, "a*c", "abc")] - [InlineData(true, "ab*c", "abc")] - [InlineData(true, "abc?", "abc")] - [InlineData(false, "ab?c", "abc")] - [InlineData(false, "ac", "abc")] + [AutoArguments(true, "*")] + [AutoArguments(true, ".")] + [AutoArguments(true, "*.*")] + [Arguments(true, "a*c", "abc")] + [Arguments(true, "ab*c", "abc")] + [Arguments(true, "abc?", "abc")] + [Arguments(false, "ab?c", "abc")] + [Arguments(false, "ac", "abc")] public async Task EnumerateFileSystemInfos_SearchPattern_ShouldReturnExpectedValue( bool expectToBeFound, string searchPattern, string fileName) { @@ -77,8 +77,8 @@ await That(result).HasSingle() } } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task EnumerateFileSystemInfos_ShouldMatchTypes(string path) { IFileSystemDirectoryInitializer initialized = @@ -102,7 +102,7 @@ await That(result).Contains(d } #if FEATURE_FILESYSTEM_ENUMERATION_OPTIONS - [Fact] + [Test] public async Task EnumerateFileSystemInfos_WithEnumerationOptions_ShouldConsiderSetOptions() { IDirectoryInfo baseDirectory = @@ -131,8 +131,8 @@ await That(result).DoesNotContain(d } #endif - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task EnumerateFileSystemInfos_WithNewline_ShouldThrowArgumentException( string path) { @@ -148,7 +148,7 @@ void Act() await That(Act).Throws().WithHResult(-2147024809); } - [Fact] + [Test] public async Task EnumerateFileSystemInfos_WithoutSearchString_ShouldReturnAllDirectFilesAndDirectories() { @@ -171,7 +171,7 @@ await That(result) await That(result).Contains(d => string.Equals(d.Name, "bar", StringComparison.Ordinal)); } - [Fact] + [Test] public async Task EnumerateFileSystemInfos_WithSearchPattern_ShouldReturnMatchingFiles() { IDirectoryInfo baseDirectory = @@ -188,7 +188,7 @@ await That(result).HasSingle() await That(result.Count()).IsEqualTo(1); } - [Fact] + [Test] public async Task EnumerateFileSystemInfos_WithSearchPatternInSubdirectory_ShouldReturnMatchingFiles() { diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/EnumerateFilesTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/EnumerateFilesTests.cs index 0fdfafe76..cde70d353 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/EnumerateFilesTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/EnumerateFilesTests.cs @@ -6,10 +6,10 @@ namespace Testably.Abstractions.Tests.FileSystem.DirectoryInfo; [FileSystemTests] -public partial class EnumerateFilesTests +public class EnumerateFilesTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task EnumerateFiles_SearchOptionAllFiles_ShouldReturnAllFiles( string path) { @@ -36,20 +36,20 @@ await That(result).Contains(d => string.Equals(d.Name, initialized[5].Name, StringComparison.Ordinal)); } - [Theory] + [Test] #if NETFRAMEWORK - [InlineAutoData(false, "")] + [AutoArguments(false, "")] #else - [InlineAutoData(true, "")] + [AutoArguments(true, "")] #endif - [InlineAutoData(true, "*")] - [InlineAutoData(true, ".")] - [InlineAutoData(true, "*.*")] - [InlineData(true, "a*c", "abc")] - [InlineData(true, "ab*c", "abc")] - [InlineData(true, "abc?", "abc")] - [InlineData(false, "ab?c", "abc")] - [InlineData(false, "ac", "abc")] + [AutoArguments(true, "*")] + [AutoArguments(true, ".")] + [AutoArguments(true, "*.*")] + [Arguments(true, "a*c", "abc")] + [Arguments(true, "ab*c", "abc")] + [Arguments(true, "abc?", "abc")] + [Arguments(false, "ab?c", "abc")] + [Arguments(false, "ac", "abc")] public async Task EnumerateFiles_SearchPattern_ShouldReturnExpectedValue( bool expectToBeFound, string searchPattern, string fileName) { @@ -74,7 +74,7 @@ await That(result).HasSingle() } #if FEATURE_FILESYSTEM_ENUMERATION_OPTIONS - [Fact] + [Test] public async Task EnumerateFiles_WithEnumerationOptions_ShouldConsiderSetOptions() { IDirectoryInfo baseDirectory = @@ -103,8 +103,8 @@ await That(result).DoesNotContain(d } #endif - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task EnumerateFiles_WithNewline_ShouldThrowArgumentException( string path) { @@ -120,7 +120,7 @@ void Act() await That(Act).Throws().WithHResult(-2147024809); } - [Fact] + [Test] public async Task EnumerateFiles_WithoutSearchString_ShouldReturnAllDirectFiles() { IDirectoryInfo baseDirectory = @@ -141,7 +141,7 @@ await That(result) await That(result).Contains(d => string.Equals(d.Name, "bar", StringComparison.Ordinal)); } - [Fact] + [Test] public async Task EnumerateFiles_WithSearchPattern_ShouldReturnMatchingFiles() { IDirectoryInfo baseDirectory = @@ -158,7 +158,7 @@ await That(result).HasSingle() await That(result.Count()).IsEqualTo(1); } - [Fact] + [Test] public async Task EnumerateFiles_WithSearchPatternInSubdirectory_ShouldReturnMatchingFiles() { @@ -178,7 +178,7 @@ public async Task await That(result).HasCount(2); } - [Fact] + [Test] public async Task EnumerateFiles_WithSearchPatternWithDirectorySeparator_ShouldReturnFilesInSubdirectoryOnWindows() { diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/ExceptionTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/ExceptionTests.cs index 716c8c271..2809f56a7 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/ExceptionTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/ExceptionTests.cs @@ -6,10 +6,26 @@ namespace Testably.Abstractions.Tests.FileSystem.DirectoryInfo; [FileSystemTests] -public partial class ExceptionTests +public class ExceptionTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [MemberData(nameof(GetDirectoryInfoCallbacks), "Illegal\tCharacter?InPath")] + public static IEnumerable<(Expression>, string, bool)> + GetDirectoryInfoCallbacksWithEmptyPath() + => GetDirectoryInfoCallbacks(""); + + public static IEnumerable<(Expression>, string, bool)> + GetDirectoryInfoCallbacksWithIllegalPathCharacters() + => GetDirectoryInfoCallbacks("Illegal\tCharacter?InPath"); + + public static IEnumerable<(Expression>, string, bool)> + GetDirectoryInfoCallbacksWithNullPath() + => GetDirectoryInfoCallbacks(null); + + public static IEnumerable<(Expression>, string, bool)> + GetDirectoryInfoCallbacksWithWhitespacePath() + => GetDirectoryInfoCallbacks(" "); + + [Test] + [MethodDataSource(nameof(GetDirectoryInfoCallbacksWithIllegalPathCharacters))] public async Task Operations_WhenValueContainsIllegalPathCharacters_ShouldThrowCorrectException_OnWindows( Expression> callback, string paramName, @@ -48,8 +64,8 @@ await That(Act).Throws() } } - [Theory] - [MemberData(nameof(GetDirectoryInfoCallbacks), "")] + [Test] + [MethodDataSource(nameof(GetDirectoryInfoCallbacksWithEmptyPath))] public async Task Operations_WhenValueIsEmpty_ShouldThrowArgumentException( Expression> callback, string paramName, bool ignoreParamCheck) @@ -66,8 +82,8 @@ await That(Act).Throws() $"\n{callback}\n has empty parameter for '{paramName}' (ignored: {ignoreParamCheck})"); } - [Theory] - [MemberData(nameof(GetDirectoryInfoCallbacks), (string?)null)] + [Test] + [MethodDataSource(nameof(GetDirectoryInfoCallbacksWithNullPath))] public async Task Operations_WhenValueIsNull_ShouldThrowArgumentNullException( Expression> callback, string paramName, bool ignoreParamCheck) @@ -83,8 +99,8 @@ await That(Act).Throws() $"\n{callback}\n has `null` parameter for '{paramName}' (ignored: {ignoreParamCheck})"); } - [Theory] - [MemberData(nameof(GetDirectoryInfoCallbacks), " ")] + [Test] + [MethodDataSource(nameof(GetDirectoryInfoCallbacksWithWhitespacePath))] public async Task Operations_WhenValueIsWhitespace_ShouldThrowArgumentException( Expression> callback, string paramName, bool ignoreParamCheck) @@ -115,23 +131,20 @@ await That(Act).Throws() #region Helpers #pragma warning disable MA0018 - public static TheoryData>, string, bool> + private static IEnumerable<(Expression>, string, bool)> GetDirectoryInfoCallbacks(string? path) { - TheoryData>, string, bool> theoryData = new(); foreach ((ExceptionTestHelper.TestTypes TestType, string ParamName, Expression> Callback) item in GetDirectoryInfoCallbackTestParameters(path!) .Where(item => item.TestType.HasFlag(path.ToTestType()))) { - theoryData.Add( + yield return ( item.Callback, item.ParamName, item.TestType.HasFlag(ExceptionTestHelper.TestTypes.IgnoreParamNameCheck)); } - - return theoryData; } #pragma warning restore MA0018 diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/ExistsTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/ExistsTests.cs index 021faa328..ee02c58cd 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/ExistsTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/ExistsTests.cs @@ -1,10 +1,10 @@ namespace Testably.Abstractions.Tests.FileSystem.DirectoryInfo; [FileSystemTests] -public partial class ExistsTests +public class ExistsTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Exists_ArbitraryPath_ShouldBeFalse(string path) { IDirectoryInfo sut = FileSystem.DirectoryInfo.New(path); @@ -13,8 +13,8 @@ public async Task Exists_ArbitraryPath_ShouldBeFalse(string path) await That(FileSystem.Directory.Exists(sut.FullName)).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Exists_ExistedPreviously_ShouldOnlyUpdateOnInitialization(string path) { FileSystem.Directory.CreateDirectory(path); @@ -26,8 +26,8 @@ public async Task Exists_ExistedPreviously_ShouldOnlyUpdateOnInitialization(stri await That(FileSystem.Directory.Exists(sut.FullName)).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Exists_File_ShouldReturnFalse(string path) { FileSystem.File.WriteAllText(path, null); @@ -36,7 +36,7 @@ public async Task Exists_File_ShouldReturnFalse(string path) await That(sut.Exists).IsFalse(); } - [Fact] + [Test] public async Task Exists_ForwardSlash_ShouldReturnTrue() { FileSystem.InitializeIn("/"); @@ -46,8 +46,8 @@ public async Task Exists_ForwardSlash_ShouldReturnTrue() await That(sut.Exists).IsTrue(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Exists_NotExistedPreviously_ShouldOnlyUpdateOnInitialization(string path) { IDirectoryInfo sut = FileSystem.DirectoryInfo.New(path); @@ -58,8 +58,8 @@ public async Task Exists_NotExistedPreviously_ShouldOnlyUpdateOnInitialization(s await That(FileSystem.Directory.Exists(sut.FullName)).IsTrue(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Exists_ShouldNotChangeOnMoveTo(string path, string destination) { FileSystem.Directory.CreateDirectory(path); @@ -71,8 +71,8 @@ public async Task Exists_ShouldNotChangeOnMoveTo(string path, string destination await That(sut.Exists).IsTrue(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Exists_ShouldUpdateOnCreateWhenNotNetFramework(string path) { IDirectoryInfo sut = FileSystem.DirectoryInfo.New(path); @@ -83,8 +83,8 @@ public async Task Exists_ShouldUpdateOnCreateWhenNotNetFramework(string path) await That(sut.Exists).IsEqualTo(!Test.IsNetFramework); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Exists_ShouldUpdateOnDeleteWhenNotNetFramework(string path) { FileSystem.Directory.CreateDirectory(path); @@ -96,8 +96,8 @@ public async Task Exists_ShouldUpdateOnDeleteWhenNotNetFramework(string path) await That(sut.Exists).IsEqualTo(Test.IsNetFramework); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Exists_ShouldUpdateOnRecursiveDeleteWhenNotNetFramework(string path) { FileSystem.Directory.CreateDirectory(path); @@ -109,8 +109,8 @@ public async Task Exists_ShouldUpdateOnRecursiveDeleteWhenNotNetFramework(string await That(sut.Exists).IsEqualTo(Test.IsNetFramework); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Exists_ShouldUpdateOnRefresh(string path) { FileSystem.Directory.CreateDirectory(path); diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/GetDirectoriesTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/GetDirectoriesTests.cs index 44c9c210e..710a575fe 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/GetDirectoriesTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/GetDirectoriesTests.cs @@ -6,10 +6,10 @@ namespace Testably.Abstractions.Tests.FileSystem.DirectoryInfo; [FileSystemTests] -public partial class GetDirectoriesTests +public class GetDirectoriesTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetDirectories_SearchOptionAllDirectories_ShouldReturnAllSubdirectories( string path) { @@ -30,20 +30,20 @@ public async Task GetDirectories_SearchOptionAllDirectories_ShouldReturnAllSubdi await That(result).Contains(d => string.Equals(d.Name, "xyz", StringComparison.Ordinal)); } - [Theory] + [Test] #if NETFRAMEWORK - [InlineAutoData(false, "")] + [AutoArguments(false, "")] #else - [InlineAutoData(true, "")] + [AutoArguments(true, "")] #endif - [InlineAutoData(true, "*")] - [InlineAutoData(true, ".")] - [InlineAutoData(true, "*.*")] - [InlineData(true, "a*c", "abc")] - [InlineData(true, "ab*c", "abc")] - [InlineData(true, "abc?", "abc")] - [InlineData(false, "ab?c", "abc")] - [InlineData(false, "ac", "abc")] + [AutoArguments(true, "*")] + [AutoArguments(true, ".")] + [AutoArguments(true, "*.*")] + [Arguments(true, "a*c", "abc")] + [Arguments(true, "ab*c", "abc")] + [Arguments(true, "abc?", "abc")] + [Arguments(false, "ab?c", "abc")] + [Arguments(false, "ac", "abc")] public async Task GetDirectories_SearchPattern_ShouldReturnExpectedValue( bool expectToBeFound, string searchPattern, string subdirectoryName) { @@ -68,8 +68,8 @@ await That(result).IsEmpty() } #if FEATURE_FILESYSTEM_ENUMERATION_OPTIONS - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetDirectories_WithEnumerationOptions_ShouldConsiderSetOptions( string path) { @@ -97,8 +97,8 @@ await That(result).DoesNotContain(d } #endif - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetDirectories_WithNewline_ShouldThrowArgumentException( string path) { @@ -114,8 +114,8 @@ void Act() await That(Act).Throws().WithHResult(-2147024809); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetDirectories_WithoutSearchString_ShouldReturnAllDirectSubdirectories( string path) { @@ -134,8 +134,8 @@ await That(result) await That(result).Contains(d => string.Equals(d.Name, "bar", StringComparison.Ordinal)); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetDirectories_WithSearchPattern_ShouldReturnMatchingSubdirectory( string path) { @@ -151,8 +151,8 @@ await That(result).HasSingle() .Matching(d => string.Equals(d.Name, "foo", StringComparison.Ordinal)); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetDirectories_WithSearchPatternInSubdirectory_ShouldReturnMatchingSubdirectory( string path) diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/GetFileSystemInfosTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/GetFileSystemInfosTests.cs index 3d2b60fd8..a63551f12 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/GetFileSystemInfosTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/GetFileSystemInfosTests.cs @@ -6,10 +6,10 @@ namespace Testably.Abstractions.Tests.FileSystem.DirectoryInfo; [FileSystemTests] -public partial class GetFileSystemInfosTests +public class GetFileSystemInfosTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetFileSystemInfos_SearchOptionAllFiles_ShouldReturnAllFiles( string path) { @@ -40,20 +40,20 @@ await That(result).Contains(d => string.Equals(d.Name, initialized[5].Name, StringComparison.Ordinal)); } - [Theory] + [Test] #if NETFRAMEWORK - [InlineAutoData(false, "")] + [AutoArguments(false, "")] #else - [InlineAutoData(true, "")] + [AutoArguments(true, "")] #endif - [InlineAutoData(true, "*")] - [InlineAutoData(true, ".")] - [InlineAutoData(true, "*.*")] - [InlineData(true, "a*c", "abc")] - [InlineData(true, "ab*c", "abc")] - [InlineData(true, "abc?", "abc")] - [InlineData(false, "ab?c", "abc")] - [InlineData(false, "ac", "abc")] + [AutoArguments(true, "*")] + [AutoArguments(true, ".")] + [AutoArguments(true, "*.*")] + [Arguments(true, "a*c", "abc")] + [Arguments(true, "ab*c", "abc")] + [Arguments(true, "abc?", "abc")] + [Arguments(false, "ab?c", "abc")] + [Arguments(false, "ac", "abc")] public async Task GetFileSystemInfos_SearchPattern_ShouldReturnExpectedValue( bool expectToBeFound, string searchPattern, string fileName) { @@ -77,8 +77,8 @@ await That(result).HasSingle() } } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetFileSystemInfos_ShouldMatchTypes(string path) { IFileSystemDirectoryInitializer initialized = @@ -102,7 +102,7 @@ await That(result).Contains(d } #if FEATURE_FILESYSTEM_ENUMERATION_OPTIONS - [Fact] + [Test] public async Task GetFileSystemInfos_WithEnumerationOptions_ShouldConsiderSetOptions() { IDirectoryInfo baseDirectory = @@ -131,8 +131,8 @@ await That(result).DoesNotContain(d } #endif - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetFileSystemInfos_WithNewline_ShouldThrowArgumentException( string path) { @@ -148,7 +148,7 @@ void Act() await That(Act).Throws().WithHResult(-2147024809); } - [Fact] + [Test] public async Task GetFileSystemInfos_WithoutSearchString_ShouldReturnAllDirectFilesAndDirectories() { @@ -171,7 +171,7 @@ await That(result) await That(result).Contains(d => string.Equals(d.Name, "bar", StringComparison.Ordinal)); } - [Fact] + [Test] public async Task GetFileSystemInfos_WithSearchPattern_ShouldReturnMatchingFiles() { IDirectoryInfo baseDirectory = @@ -188,7 +188,7 @@ await That(result).HasSingle() await That(result.Count()).IsEqualTo(1); } - [Fact] + [Test] public async Task GetFileSystemInfos_WithSearchPatternInSubdirectory_ShouldReturnMatchingFiles() { diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/GetFilesTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/GetFilesTests.cs index 15146e1cf..a16789f9f 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/GetFilesTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/GetFilesTests.cs @@ -6,10 +6,10 @@ namespace Testably.Abstractions.Tests.FileSystem.DirectoryInfo; [FileSystemTests] -public partial class GetFilesTests +public class GetFilesTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetFiles_SearchOptionAllFiles_ShouldReturnAllFiles( string path) { @@ -36,20 +36,20 @@ await That(result).Contains(d => string.Equals(d.Name, initialized[5].Name, StringComparison.Ordinal)); } - [Theory] + [Test] #if NETFRAMEWORK - [InlineAutoData(false, "")] + [AutoArguments(false, "")] #else - [InlineAutoData(true, "")] + [AutoArguments(true, "")] #endif - [InlineAutoData(true, "*")] - [InlineAutoData(true, ".")] - [InlineAutoData(true, "*.*")] - [InlineData(true, "a*c", "abc")] - [InlineData(true, "ab*c", "abc")] - [InlineData(true, "abc?", "abc")] - [InlineData(false, "ab?c", "abc")] - [InlineData(false, "ac", "abc")] + [AutoArguments(true, "*")] + [AutoArguments(true, ".")] + [AutoArguments(true, "*.*")] + [Arguments(true, "a*c", "abc")] + [Arguments(true, "ab*c", "abc")] + [Arguments(true, "abc?", "abc")] + [Arguments(false, "ab?c", "abc")] + [Arguments(false, "ac", "abc")] public async Task GetFiles_SearchPattern_ShouldReturnExpectedValue( bool expectToBeFound, string searchPattern, string fileName) { @@ -74,7 +74,7 @@ await That(result).HasSingle() } #if FEATURE_FILESYSTEM_ENUMERATION_OPTIONS - [Fact] + [Test] public async Task GetFiles_WithEnumerationOptions_ShouldConsiderSetOptions() { IDirectoryInfo baseDirectory = @@ -103,8 +103,8 @@ await That(result).DoesNotContain(d } #endif - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetFiles_WithNewline_ShouldThrowArgumentException( string path) { @@ -120,7 +120,7 @@ void Act() await That(Act).Throws().WithHResult(-2147024809); } - [Fact] + [Test] public async Task GetFiles_WithoutSearchString_ShouldReturnAllDirectFiles() { IDirectoryInfo baseDirectory = @@ -141,7 +141,7 @@ await That(result) await That(result).Contains(d => string.Equals(d.Name, "bar", StringComparison.Ordinal)); } - [Fact] + [Test] public async Task GetFiles_WithSearchPattern_ShouldReturnMatchingFiles() { IDirectoryInfo baseDirectory = @@ -158,7 +158,7 @@ await That(result).HasSingle() await That(result.Count()).IsEqualTo(1); } - [Fact] + [Test] public async Task GetFiles_WithSearchPatternInSubdirectory_ShouldReturnMatchingFiles() { diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/MoveToTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/MoveToTests.cs index e9daa4601..e4a634cf7 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/MoveToTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/MoveToTests.cs @@ -4,10 +4,10 @@ namespace Testably.Abstractions.Tests.FileSystem.DirectoryInfo; [FileSystemTests] -public partial class MoveToTests +public class MoveToTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task MoveTo_ShouldMoveDirectoryWithContent(string source, string destination) { IFileSystemDirectoryInitializer initialized = @@ -32,8 +32,8 @@ await That(FileSystem.Directory.GetDirectories(destination, initialized[4].Name, SearchOption.AllDirectories)).HasSingle(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task MoveTo_ShouldUpdatePropertiesOfDirectoryInfo( string source, string destination) { @@ -51,8 +51,8 @@ await That(sut.FullName.TrimEnd(FileSystem.Path.DirectorySeparatorChar)) .IsEqualTo(FileSystem.Path.GetFullPath(destination)); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task MoveTo_WithLockedFile_ShouldMoveDirectory_NotOnWindows( string source, string destination) { @@ -91,8 +91,8 @@ await That( .HasSingle(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task MoveTo_WithLockedFile_ShouldThrowIOException_AndNotMoveDirectory_OnWindows( string source, string destination) { @@ -139,8 +139,8 @@ await That(sourceDirectory.GetDirectories(initialized[4].Name, SearchOption.AllD .HasSingle(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task MoveTo_WithReadOnlyFile_ShouldMoveDirectoryWithContent( string source, string destination) { @@ -170,7 +170,7 @@ await That( .HasSingle(); } - [Fact] + [Test] public async Task MoveTo_CurrentDirectory_ShouldThrowIOException_OnWindows() { // Arrange @@ -189,8 +189,8 @@ await That(Act).ThrowsExactly().OnlyIf(Test.RunsOnWindows).Which.Ha ); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task MoveTo_NestedCurrentDirectory_ShouldThrowIOException_OnWindows(string nested) { // Arrange @@ -223,9 +223,9 @@ await That(Act).ThrowsExactly().OnlyIf(Test.RunsOnWindows).Which } } - [Theory] - [InlineData("next")] - [InlineData("next", "sub")] + [Test] + [Arguments("next")] + [Arguments("next", "sub")] public async Task Move_DirNextToCurrentDirectory_ShouldNotThrow(params string[] paths) { // Arrange diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/ResolveLinkTargetTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/ResolveLinkTargetTests.cs index 4fc2d3f93..0bc2b83e3 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/ResolveLinkTargetTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/ResolveLinkTargetTests.cs @@ -5,7 +5,7 @@ namespace Testably.Abstractions.Tests.FileSystem.DirectoryInfo; [FileSystemTests] -public partial class ResolveLinkTargetTests +public class ResolveLinkTargetTests(FileSystemTestData testData) : FileSystemTestBase(testData) { #region Test Setup @@ -17,8 +17,8 @@ public partial class ResolveLinkTargetTests #endregion - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ResolveLinkTarget_FinalTargetWithTooManyLevels_ShouldThrowIOException( string path, string pathToFinalTarget @@ -48,8 +48,8 @@ await That(Act).Throws() .WithMessageContaining($"'{directoryInfo.FullName}'"); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ResolveLinkTarget_ShouldReturnNull(string path) { IDirectoryInfo targetDir = FileSystem.DirectoryInfo.New(path); @@ -60,8 +60,8 @@ public async Task ResolveLinkTarget_ShouldReturnNull(string path) await That(resolvedTarget).IsNull(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ResolveLinkTarget_WithChainedLink_ShouldReturnNull( string path, string pathToLink, @@ -78,8 +78,8 @@ IFileSystemInfo innerLink await That(resolvedTarget?.Name).IsEqualTo(innerLink.LinkTarget); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ResolveLinkTarget_ShouldReturnImmediateFile(string path, string pathToTarget) { IDirectoryInfo targetDir = FileSystem.DirectoryInfo.New(pathToTarget); @@ -93,8 +93,8 @@ IFileSystemInfo symbolicLink await That(resolvedTarget?.FullName).IsEqualTo(targetDir.FullName); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ResolveLinkTarget_WithChainedLink_ShouldReturnImmediateLink( string path, string pathToLink, @@ -113,8 +113,8 @@ IFileSystemInfo innerLink await That(resolvedTarget?.FullName).IsEqualTo(innerLink.FullName); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ResolveLinkTarget_ShouldReturnFinalFile(string path, string pathToTarget) { IDirectoryInfo targetDir = FileSystem.DirectoryInfo.New(pathToTarget); @@ -128,8 +128,8 @@ IFileSystemInfo symbolicLink await That(resolvedTarget?.FullName).IsEqualTo(targetDir.FullName); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ResolveLinkTarget_WithChainedLink_ShouldReturnFinalFile( string path, string pathToLink, @@ -150,8 +150,8 @@ IFileSystemInfo outerLink await That(resolvedTarget?.FullName).IsEqualTo(targetDir.FullName); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ResolveLinkTarget_OfDifferentTypes_ShouldThrow( string directoryName, string fileLinkName, diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/Tests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/Tests.cs index 3b67316b8..25974975e 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/Tests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/Tests.cs @@ -3,11 +3,11 @@ namespace Testably.Abstractions.Tests.FileSystem.DirectoryInfo; [FileSystemTests] -public partial class Tests +public class Tests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [InlineData("foo")] - [InlineData("foo/")] + [Test] + [Arguments("foo")] + [Arguments("foo/")] public async Task Extension_ShouldReturnEmptyString(string path) { IDirectoryInfo sut = FileSystem.DirectoryInfo.New(path); @@ -17,10 +17,10 @@ public async Task Extension_ShouldReturnEmptyString(string path) await That(result).IsEmpty(); } - [Theory] - [InlineData(@"/temp\\folder")] - [InlineData("/temp/folder")] - [InlineData(@"/temp/\\/folder")] + [Test] + [Arguments(@"/temp\\folder")] + [Arguments("/temp/folder")] + [Arguments(@"/temp/\\/folder")] public async Task FullName_ShouldNotNormalizePathOnLinux(string path) { Skip.If(Test.RunsOnWindows); @@ -30,9 +30,9 @@ public async Task FullName_ShouldNotNormalizePathOnLinux(string path) await That(sut.FullName).IsEqualTo(path); } - [Theory] - [InlineData("foo")] - [InlineData("foo/")] + [Test] + [Arguments("foo")] + [Arguments("foo/")] public async Task FullName_ShouldReturnFullPath(string path) { string expectedPath = FileSystem.Path.GetFullPath(path); @@ -41,12 +41,12 @@ public async Task FullName_ShouldReturnFullPath(string path) await That(sut.FullName).IsEqualTo(expectedPath); } - [Theory] - [InlineData(@"\\unc\folder", @"\\unc\folder")] - [InlineData(@"\\unc/folder\\foo", @"\\unc\folder\foo")] - [InlineData(@"c:\temp\\folder", @"c:\temp\folder")] - [InlineData(@"c:\temp//folder", @"c:\temp\folder")] - [InlineData(@"c:\temp//\\///folder", @"c:\temp\folder")] + [Test] + [Arguments(@"\\unc\folder", @"\\unc\folder")] + [Arguments(@"\\unc/folder\\foo", @"\\unc\folder\foo")] + [Arguments(@"c:\temp\\folder", @"c:\temp\folder")] + [Arguments(@"c:\temp//folder", @"c:\temp\folder")] + [Arguments(@"c:\temp//\\///folder", @"c:\temp\folder")] public async Task FullName_ShouldReturnNormalizedPath_OnWindows( string path, string expectedPath) { @@ -57,8 +57,8 @@ public async Task FullName_ShouldReturnNormalizedPath_OnWindows( await That(sut.FullName).IsEqualTo(expectedPath); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task FullName_ShouldTrimTrailingSpaces_OnWindows(string path) { path = FileSystem.Path.GetFullPath(path); @@ -76,8 +76,8 @@ public async Task FullName_ShouldTrimTrailingSpaces_OnWindows(string path) } } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task MissingFile_Attributes_ShouldAlwaysBeNegativeOne_AndSetterShouldThrowFileNotFoundException( FileAttributes fileAttributes) @@ -94,8 +94,8 @@ void Act() await That(sut.Attributes).IsEqualTo((FileAttributes)(-1)); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task MissingFile_CreationTime_ShouldAlwaysBeNullTime_AndSetterShouldThrowCorrectException( DateTime creationTime) @@ -120,8 +120,8 @@ void Act() await That(sut.CreationTime).IsEqualTo(FileTestHelper.NullTime.ToLocalTime()); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task MissingFile_CreationTimeUtc_ShouldAlwaysBeNullTime_AndSetterShouldThrowCorrectException( DateTime creationTimeUtc) @@ -146,8 +146,8 @@ void Act() await That(sut.CreationTimeUtc).IsEqualTo(FileTestHelper.NullTime.ToUniversalTime()); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task MissingFile_LastAccessTime_ShouldAlwaysBeNullTime_AndSetterShouldThrowCorrectException( DateTime lastAccessTime) @@ -172,8 +172,8 @@ void Act() await That(sut.LastAccessTime).IsEqualTo(FileTestHelper.NullTime.ToLocalTime()); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task MissingFile_LastAccessTimeUtc_ShouldAlwaysBeNullTime_AndSetterShouldThrowCorrectException( DateTime lastAccessTimeUtc) @@ -198,8 +198,8 @@ void Act() await That(sut.LastAccessTimeUtc).IsEqualTo(FileTestHelper.NullTime.ToUniversalTime()); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task MissingFile_LastWriteTime_ShouldAlwaysBeNullTime_AndSetterShouldThrowCorrectException( DateTime lastWriteTime) @@ -224,8 +224,8 @@ void Act() await That(sut.LastWriteTime).IsEqualTo(FileTestHelper.NullTime.ToLocalTime()); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task MissingFile_LastWriteTimeUtc_ShouldAlwaysBeNullTime_AndSetterShouldThrowCorrectException( DateTime lastWriteTimeUtc) @@ -250,8 +250,8 @@ void Act() await That(sut.LastWriteTimeUtc).IsEqualTo(FileTestHelper.NullTime.ToUniversalTime()); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Name_ShouldTrimTrailingSpaces_OnWindows(string path) { string pathWithSpaces = path + " "; @@ -268,8 +268,8 @@ public async Task Name_ShouldTrimTrailingSpaces_OnWindows(string path) } } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Parent_ArbitraryPaths_ShouldNotBeNull(string path1, string path2, string path3) @@ -283,7 +283,7 @@ public async Task Parent_ArbitraryPaths_ShouldNotBeNull(string path1, await That(sut.Parent!.Exists).IsFalse(); } - [Fact] + [Test] public async Task Parent_Root_ShouldBeNull() { IDirectoryInfo sut = @@ -292,9 +292,9 @@ public async Task Parent_Root_ShouldBeNull() await That(sut.Parent).IsNull(); } - [Theory] - [InlineAutoData("./foo/bar", "foo")] - [InlineAutoData("./foo", ".")] + [Test] + [AutoArguments("./foo/bar", "foo")] + [AutoArguments("./foo", ".")] public async Task Parent_ToString_ShouldBeAbsolutePathOnNetCore( string path, string expectedParent) { @@ -317,9 +317,9 @@ public async Task Parent_ToString_ShouldBeAbsolutePathOnNetCore( } } - [Theory] - [InlineAutoData("./foo/bar", "foo")] - [InlineAutoData("./foo", "bar", "bar")] + [Test] + [AutoArguments("./foo/bar", "foo")] + [AutoArguments("./foo", "bar", "bar")] public async Task Parent_ToString_ShouldBeDirectoryNameOnNetFramework( string path, string expectedParent, string directory) { @@ -342,8 +342,8 @@ public async Task Parent_ToString_ShouldBeDirectoryNameOnNetFramework( } } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Parent_WithTrailingDirectorySeparator_ShouldReturnCorrectParent(string path1, string path2) { @@ -357,7 +357,7 @@ public async Task Parent_WithTrailingDirectorySeparator_ShouldReturnCorrectParen await That(sut.Parent!.FullName).IsEqualTo(expectedParent); } - [Fact] + [Test] public async Task Root_Name_ShouldBeCorrect() { string rootName = FileTestHelper.RootDrive(Test); @@ -368,8 +368,8 @@ public async Task Root_Name_ShouldBeCorrect() await That(sut.Name).IsEqualTo(rootName); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Root_ShouldExist(string path) { string expectedRoot = FileTestHelper.RootDrive(Test); @@ -379,10 +379,10 @@ public async Task Root_ShouldExist(string path) await That(result.Root.FullName).IsEqualTo(expectedRoot); } - [Theory] - [InlineData("/foo")] - [InlineData("./foo")] - [InlineData("foo")] + [Test] + [Arguments("/foo")] + [Arguments("./foo")] + [Arguments("foo")] public async Task ToString_ShouldReturnProvidedPath(string path) { IDirectoryInfo directoryInfo = FileSystem.DirectoryInfo.New(path); diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/UnixFileModeTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/UnixFileModeTests.cs index 9a598fd2c..61a638f0c 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/UnixFileModeTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfo/UnixFileModeTests.cs @@ -4,9 +4,9 @@ namespace Testably.Abstractions.Tests.FileSystem.DirectoryInfo; [FileSystemTests] -public partial class UnixFileModeTests +public class UnixFileModeTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Fact] + [Test] public async Task Create_WhenUnixFileModeOfParentIsNone_ShouldThrowUnauthorizedAccessException() { Skip.If(Test.RunsOnWindows, "UnixFileMode is not supported on Windows"); @@ -25,7 +25,7 @@ await That(Act).Throws() .WithMessage("Access to the path '*/parent/child' is denied.").AsWildcard(); } - [Fact] + [Test] public async Task Delete_WhenParentUnixFileModeIsNone_ShouldThrowUnauthorizedAccessException() { Skip.If(Test.RunsOnWindows, "UnixFileMode is not supported on Windows"); @@ -46,7 +46,7 @@ await That(Act).Throws() .WithMessage("Access to the path '*/parent/child' is denied.").AsWildcard(); } - [Fact] + [Test] public async Task Delete_WhenUnixFileModeIsNone_ShouldNotThrow() { Skip.If(Test.RunsOnWindows, "UnixFileMode is not supported on Windows"); @@ -62,7 +62,7 @@ void Act() await That(FileSystem.Directory.Exists("parent")).IsFalse(); } - [Fact] + [Test] public async Task GetDirectories_WhenSubdirectoryHasUnixFileModeSetToNone_ShouldStillIncludeBothDirectories() { @@ -77,7 +77,7 @@ public async Task await That(result).HasCount(2); } - [Fact] + [Test] public async Task GetDirectories_WhenUnixFileModeIsNone_ShouldThrowUnauthorizedAccessException() { Skip.If(Test.RunsOnWindows, "UnixFileMode is not supported on Windows"); diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfoFactory/ExceptionTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfoFactory/ExceptionTests.cs index 4a1403a50..37a62fe88 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfoFactory/ExceptionTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfoFactory/ExceptionTests.cs @@ -5,11 +5,26 @@ namespace Testably.Abstractions.Tests.FileSystem.DirectoryInfoFactory; [FileSystemTests] -public partial class ExceptionTests +public class ExceptionTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [MemberData(nameof(GetDirectoryInfoFactoryCallbacks), - "Illegal\tCharacter?InPath")] + public static IEnumerable<(Expression>, string, bool)> + GetDirectoryInfoFactoryCallbacksWithEmptyPath() + => GetDirectoryInfoFactoryCallbacks(""); + + public static IEnumerable<(Expression>, string, bool)> + GetDirectoryInfoFactoryCallbacksWithIllegalPathCharacters() + => GetDirectoryInfoFactoryCallbacks("Illegal\tCharacter?InPath"); + + public static IEnumerable<(Expression>, string, bool)> + GetDirectoryInfoFactoryCallbacksWithNullPath() + => GetDirectoryInfoFactoryCallbacks(null); + + public static IEnumerable<(Expression>, string, bool)> + GetDirectoryInfoFactoryCallbacksWithWhitespacePath() + => GetDirectoryInfoFactoryCallbacks(" "); + + [Test] + [MethodDataSource(nameof(GetDirectoryInfoFactoryCallbacksWithIllegalPathCharacters))] public async Task Operations_WhenValueContainsIllegalPathCharacters_ShouldThrowArgumentException_OnNetFramework( Expression> callback, string paramName, @@ -35,8 +50,8 @@ await That(Act).DoesNotThrow() } } - [Theory] - [MemberData(nameof(GetDirectoryInfoFactoryCallbacks), "")] + [Test] + [MethodDataSource(nameof(GetDirectoryInfoFactoryCallbacksWithEmptyPath))] public async Task Operations_WhenValueIsEmpty_ShouldThrowArgumentException( Expression> callback, string paramName, bool ignoreParamCheck) @@ -53,8 +68,8 @@ await That(Act).Throws() $"\n{callback}\n has empty parameter for '{paramName}' (ignored: {ignoreParamCheck})"); } - [Theory] - [MemberData(nameof(GetDirectoryInfoFactoryCallbacks), (string?)null)] + [Test] + [MethodDataSource(nameof(GetDirectoryInfoFactoryCallbacksWithNullPath))] public async Task Operations_WhenValueIsNull_ShouldThrowArgumentNullException( Expression> callback, string paramName, bool ignoreParamCheck) @@ -70,8 +85,8 @@ await That(Act).Throws() $"\n{callback}\n has `null` parameter for '{paramName}' (ignored: {ignoreParamCheck})"); } - [Theory] - [MemberData(nameof(GetDirectoryInfoFactoryCallbacks), " ")] + [Test] + [MethodDataSource(nameof(GetDirectoryInfoFactoryCallbacksWithWhitespacePath))] public async Task Operations_WhenValueIsWhitespace_ShouldThrowArgumentException( Expression> callback, string paramName, bool ignoreParamCheck) @@ -92,23 +107,20 @@ await That(Act).Throws() #region Helpers - public static TheoryData>, string, bool> + private static IEnumerable<(Expression>, string, bool)> GetDirectoryInfoFactoryCallbacks(string? path) { - TheoryData>, string, bool> theoryData = []; foreach ((ExceptionTestHelper.TestTypes TestType, string ParamName, Expression> Callback) in GetDirectoryInfoFactoryCallbackTestParameters(path!) .Where(item => item.TestType.HasFlag(path.ToTestType()))) { - theoryData.Add( + yield return ( Callback, ParamName, TestType.HasFlag(ExceptionTestHelper.TestTypes.IgnoreParamNameCheck)); } - - return theoryData; } private static IEnumerable<(ExceptionTestHelper.TestTypes TestType, string ParamName, diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfoFactory/Tests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfoFactory/Tests.cs index 822c578fc..305ba6e58 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfoFactory/Tests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/DirectoryInfoFactory/Tests.cs @@ -1,11 +1,11 @@ namespace Testably.Abstractions.Tests.FileSystem.DirectoryInfoFactory; [FileSystemTests] -public partial class Tests +public class Tests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [InlineData("\0foo")] - [InlineData("foo\0bar")] + [Test] + [Arguments("\0foo")] + [Arguments("foo\0bar")] public async Task New_NullCharacter_ShouldThrowArgumentException(string path) { #if NET8_0_OR_GREATER @@ -26,8 +26,8 @@ await That(Act).Throws() .WithHResult(-2147024809); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task New_ShouldCreateNewDirectoryInfoFromPath(string path) { IDirectoryInfo result = FileSystem.DirectoryInfo.New(path); @@ -36,8 +36,8 @@ public async Task New_ShouldCreateNewDirectoryInfoFromPath(string path) await That(result.Exists).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task New_WithTrailingDirectorySeparatorChar_ShouldHavePathAsName(string path) { IDirectoryInfo result = FileSystem.DirectoryInfo @@ -46,7 +46,7 @@ public async Task New_WithTrailingDirectorySeparatorChar_ShouldHavePathAsName(st await That(result.Name).IsEqualTo(path); } - [Fact] + [Test] public async Task Wrap_Null_ShouldReturnNull() { Skip.If(FileSystem is MockFileSystem mockFileSystem && @@ -57,8 +57,8 @@ public async Task Wrap_Null_ShouldReturnNull() await That(result).IsNull(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Wrap_ShouldWrapFromDirectoryInfo(string path) { Skip.If(FileSystem is MockFileSystem mockFileSystem && @@ -72,8 +72,8 @@ public async Task Wrap_ShouldWrapFromDirectoryInfo(string path) await That(result.Exists).IsEqualTo(directoryInfo.Exists); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Wrap_WithSimulatedMockFileSystem_ShouldThrowNotSupportedException(string path) { Skip.IfNot(FileSystem is MockFileSystem mockFileSystem && diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/DriveInfo/Tests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/DriveInfo/Tests.cs index ff84e79f9..649597fa7 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/DriveInfo/Tests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/DriveInfo/Tests.cs @@ -1,9 +1,9 @@ namespace Testably.Abstractions.Tests.FileSystem.DriveInfo; [FileSystemTests] -public partial class Tests +public class Tests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Fact] + [Test] public async Task ToString_ShouldReturnDriveName() { Skip.IfNot(Test.RunsOnWindows); @@ -14,7 +14,7 @@ public async Task ToString_ShouldReturnDriveName() await That(result.ToString()).IsEqualTo("C:\\"); } - [Fact] + [Test] public async Task VolumeLabel_ShouldBeWritable_OnWindows() { SkipIfLongRunningTestsShouldBeSkipped(); diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/DriveInfoFactory/ExceptionTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/DriveInfoFactory/ExceptionTests.cs index a8691ff1f..a190a52ec 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/DriveInfoFactory/ExceptionTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/DriveInfoFactory/ExceptionTests.cs @@ -5,12 +5,20 @@ namespace Testably.Abstractions.Tests.FileSystem.DriveInfoFactory; [FileSystemTests] -public partial class ExceptionTests +public class ExceptionTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [InlineData("?invalid-drive-name")] - [InlineData("invalid")] - [InlineData(" ")] + public static IEnumerable<(Expression>, string, bool)> + GetDriveInfoFactoryCallbacksWithEmptyPath() + => GetDriveInfoFactoryCallbacks(""); + + public static IEnumerable<(Expression>, string, bool)> + GetDriveInfoFactoryCallbacksWithNullPath() + => GetDriveInfoFactoryCallbacks(null); + + [Test] + [Arguments("?invalid-drive-name")] + [Arguments("invalid")] + [Arguments(" ")] public async Task New_WhenDriveNameIsInvalid_ShouldThrowArgumentException( string driveName) { @@ -24,8 +32,8 @@ void Act() await That(Act).Throws().WithHResult(-2147024809); } - [Theory] - [MemberData(nameof(GetDriveInfoFactoryCallbacks), "")] + [Test] + [MethodDataSource(nameof(GetDriveInfoFactoryCallbacksWithEmptyPath))] public async Task Operations_WhenValueIsEmpty_ShouldThrowArgumentException( Expression> callback, string paramName, bool ignoreParamCheck) @@ -42,8 +50,8 @@ await That(Act).Throws() $"\n{callback}\n has empty parameter for '{paramName}' (ignored: {ignoreParamCheck})"); } - [Theory] - [MemberData(nameof(GetDriveInfoFactoryCallbacks), (string?)null)] + [Test] + [MethodDataSource(nameof(GetDriveInfoFactoryCallbacksWithNullPath))] public async Task Operations_WhenValueIsNull_ShouldThrowArgumentNullException( Expression> callback, string paramName, bool ignoreParamCheck) @@ -59,28 +67,21 @@ await That(Act).Throws() $"\n{callback}\n has `null` parameter for '{paramName}' (ignored: {ignoreParamCheck})"); } - #region Helpers - - #pragma warning disable MA0018 - public static TheoryData>, string, bool> + private static IEnumerable<(Expression>, string, bool)> GetDriveInfoFactoryCallbacks(string? path) { - TheoryData>, string, bool> theoryData = new(); foreach ((ExceptionTestHelper.TestTypes TestType, string ParamName, Expression> Callback) item in GetDriveInfoFactoryCallbackTestParameters(path!) .Where(item => item.TestType.HasFlag(path.ToTestType()))) { - theoryData.Add( + yield return ( item.Callback, item.ParamName, item.TestType.HasFlag(ExceptionTestHelper.TestTypes.IgnoreParamNameCheck)); } - - return theoryData; } - #pragma warning restore MA0018 private static IEnumerable<(ExceptionTestHelper.TestTypes TestType, string ParamName, Expression> Callback)> @@ -89,6 +90,4 @@ public static TheoryData>, string, bool> yield return (ExceptionTestHelper.TestTypes.All, "driveName", driveInfoFactory => driveInfoFactory.New(value)); } - - #endregion } diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/DriveInfoFactory/Tests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/DriveInfoFactory/Tests.cs index da7703b96..e4b3c2833 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/DriveInfoFactory/Tests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/DriveInfoFactory/Tests.cs @@ -4,9 +4,9 @@ namespace Testably.Abstractions.Tests.FileSystem.DriveInfoFactory; [FileSystemTests] -public partial class Tests +public class Tests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Fact] + [Test] public async Task GetDrives_ShouldNotBeEmpty() { IDriveInfo[] result = FileSystem.DriveInfo.GetDrives(); @@ -14,8 +14,8 @@ public async Task GetDrives_ShouldNotBeEmpty() await That(result).IsNotEmpty(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task MissingDrive_CreateDirectoryInfo_ShouldOnlyThrowWhenAccessingData( string path, string subPath) { @@ -38,8 +38,8 @@ await That(Act).Throws() .WithHResult(-2147024893); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task MissingDrive_WriteAllBytes_ShouldThrowDirectoryNotFoundException( string path, byte[] bytes) { @@ -59,7 +59,7 @@ await That(Act).Throws() .WithHResult(-2147024893); } - [Fact] + [Test] public async Task New_DefaultDrive_ShouldBeFixed() { IDriveInfo result = @@ -75,8 +75,8 @@ public async Task New_DefaultDrive_ShouldBeFixed() await That(result.VolumeLabel).IsNotEmpty(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task New_InvalidDriveName_ShouldThrowArgumentException( string invalidDriveName) { @@ -90,10 +90,10 @@ void Act() await That(Act).Throws().WithHResult(-2147024809); } - [Theory] - [InlineData('A')] - [InlineData('C')] - [InlineData('X')] + [Test] + [Arguments('A')] + [Arguments('C')] + [Arguments('X')] public async Task New_WithDriveLetter_ShouldReturnDriveInfo(char driveLetter) { Skip.IfNot(Test.RunsOnWindows, "Linux does not support different drives."); @@ -103,10 +103,10 @@ public async Task New_WithDriveLetter_ShouldReturnDriveInfo(char driveLetter) await That(result.Name).IsEqualTo($"{driveLetter}:\\"); } - [Theory] - [InlineAutoData('A')] - [InlineAutoData('C')] - [InlineAutoData('Y')] + [Test] + [AutoArguments('A')] + [AutoArguments('C')] + [AutoArguments('Y')] public async Task New_WithRootedPath_ShouldReturnDriveInfo(char driveLetter, string path) { Skip.IfNot(Test.RunsOnWindows, "Linux does not support different drives."); @@ -118,7 +118,7 @@ public async Task New_WithRootedPath_ShouldReturnDriveInfo(char driveLetter, str await That(result.Name).IsEqualTo($"{driveLetter}:\\"); } - [Fact] + [Test] public async Task Wrap_Null_ShouldReturnNull() { Skip.If(FileSystem is MockFileSystem mockFileSystem && @@ -129,7 +129,7 @@ public async Task Wrap_Null_ShouldReturnNull() await That(result).IsNull(); } - [Fact] + [Test] public async Task Wrap_ShouldReturnDriveInfoWithSameName() { Skip.If(FileSystem is MockFileSystem mockFileSystem && @@ -142,7 +142,7 @@ public async Task Wrap_ShouldReturnDriveInfoWithSameName() await That(result.Name).IsEqualTo(driveInfo.Name); } - [Fact] + [Test] public async Task Wrap_WithSimulatedMockFileSystem_ShouldThrowNotSupportedException() { Skip.IfNot(FileSystem is MockFileSystem mockFileSystem && diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/File/AppendAllBytesAsyncTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/File/AppendAllBytesAsyncTests.cs index 517d36f12..d489762f9 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/File/AppendAllBytesAsyncTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/File/AppendAllBytesAsyncTests.cs @@ -6,10 +6,10 @@ namespace Testably.Abstractions.Tests.FileSystem.File; // ReSharper disable MethodHasAsyncOverload [FileSystemTests] -public partial class AppendAllBytesAsyncTests +public class AppendAllBytesAsyncTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllBytesAsync_Cancelled_ShouldThrowTaskCanceledException( string path, byte[] bytes) { @@ -22,23 +22,23 @@ async Task Act() => await That(Act).Throws().WithHResult(-2146233029); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllBytesAsync_ExistingFile_ShouldAppendLinesToFile( string path, byte[] previousBytes, byte[] bytes) { await FileSystem.File.AppendAllBytesAsync(path, previousBytes, - TestContext.Current.CancellationToken); + CancellationToken); await FileSystem.File.AppendAllBytesAsync(path, bytes, - TestContext.Current.CancellationToken); + CancellationToken); await That(FileSystem.File.Exists(path)).IsTrue(); await That(FileSystem.File.ReadAllBytes(path)).IsEqualTo([..previousBytes, ..bytes]); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllBytesAsync_MissingDirectory_ShouldThrowDirectoryNotFoundException( string missingPath, string fileName, byte[] bytes) { @@ -47,26 +47,26 @@ public async Task AppendAllBytesAsync_MissingDirectory_ShouldThrowDirectoryNotFo async Task Act() { await FileSystem.File.AppendAllBytesAsync(filePath, bytes, - TestContext.Current.CancellationToken); + CancellationToken); } await That(Act).Throws().WithHResult(-2147024893); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllBytesAsync_MissingFile_ShouldCreateFile( string path, byte[] bytes) { await FileSystem.File.AppendAllBytesAsync(path, bytes, - TestContext.Current.CancellationToken); + CancellationToken); await That(FileSystem.File.Exists(path)).IsTrue(); await That(FileSystem.File.ReadAllBytes(path)).IsEqualTo(bytes); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllBytesAsync_ReadOnlyMemory_Cancelled_ShouldThrowTaskCanceledException( string path, byte[] bytes) { @@ -79,23 +79,23 @@ async Task Act() => await That(Act).Throws().WithHResult(-2146233029); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllBytesAsync_ReadOnlyMemory_ExistingFile_ShouldAppendLinesToFile( string path, byte[] previousBytes, byte[] bytes) { await FileSystem.File.AppendAllBytesAsync(path, previousBytes, - TestContext.Current.CancellationToken); + CancellationToken); await FileSystem.File.AppendAllBytesAsync(path, bytes.AsMemory(), - TestContext.Current.CancellationToken); + CancellationToken); await That(FileSystem.File.Exists(path)).IsTrue(); await That(FileSystem.File.ReadAllBytes(path)).IsEqualTo([..previousBytes, ..bytes]); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllBytesAsync_ReadOnlyMemory_MissingDirectory_ShouldThrowDirectoryNotFoundException( string missingPath, string fileName, byte[] bytes) @@ -105,26 +105,26 @@ public async Task async Task Act() { await FileSystem.File.AppendAllBytesAsync(filePath, bytes.AsMemory(), - TestContext.Current.CancellationToken); + CancellationToken); } await That(Act).Throws().WithHResult(-2147024893); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllBytesAsync_ReadOnlyMemory_MissingFile_ShouldCreateFile( string path, byte[] bytes) { await FileSystem.File.AppendAllBytesAsync(path, bytes.AsMemory(), - TestContext.Current.CancellationToken); + CancellationToken); await That(FileSystem.File.Exists(path)).IsTrue(); await That(FileSystem.File.ReadAllBytes(path)).IsEqualTo(bytes); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllBytesAsync_ReadOnlyMemory_WhenDirectoryWithSameNameExists_ShouldThrowUnauthorizedAccessException( string path, byte[] bytes) @@ -134,7 +134,7 @@ public async Task async Task Act() { await FileSystem.File.AppendAllBytesAsync(path, bytes.AsMemory(), - TestContext.Current.CancellationToken); + CancellationToken); } await That(Act).Throws().WithHResult(-2147024891); @@ -142,8 +142,8 @@ await FileSystem.File.AppendAllBytesAsync(path, bytes.AsMemory(), await That(FileSystem.File.Exists(path)).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllBytesAsync_WhenDirectoryWithSameNameExists_ShouldThrowUnauthorizedAccessException( string path, byte[] bytes) @@ -153,7 +153,7 @@ public async Task async Task Act() { await FileSystem.File.AppendAllBytesAsync(path, bytes, - TestContext.Current.CancellationToken); + CancellationToken); } await That(Act).Throws().WithHResult(-2147024891); diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/File/AppendAllBytesTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/File/AppendAllBytesTests.cs index dddfe0b03..f60f20385 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/File/AppendAllBytesTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/File/AppendAllBytesTests.cs @@ -4,10 +4,10 @@ namespace Testably.Abstractions.Tests.FileSystem.File; [FileSystemTests] -public partial class AppendAllBytesTests +public class AppendAllBytesTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllBytes_ExistingFile_ShouldAppendLinesToFile( string path, byte[] previousBytes, byte[] bytes) { @@ -19,8 +19,8 @@ public async Task AppendAllBytes_ExistingFile_ShouldAppendLinesToFile( await That(FileSystem.File.ReadAllBytes(path)).IsEqualTo([..previousBytes, ..bytes]); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllBytes_MissingDirectory_ShouldThrowDirectoryNotFoundException( string missingPath, string fileName, byte[] bytes) { @@ -33,8 +33,8 @@ void Act() await That(Act).Throws().WithHResult(-2147024893); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllBytes_MissingFile_ShouldCreateFile( string path, byte[] bytes) { @@ -44,8 +44,8 @@ public async Task AppendAllBytes_MissingFile_ShouldCreateFile( await That(FileSystem.File.ReadAllBytes(path)).IsEqualTo(bytes); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllBytes_ShouldAdjustTimes(string path, byte[] bytes) { SkipIfLongRunningTestsShouldBeSkipped(); @@ -75,8 +75,8 @@ public async Task AppendAllBytes_ShouldAdjustTimes(string path, byte[] bytes) await That(lastWriteTime).IsOnOrAfter(updateTime.ApplySystemClockTolerance()); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllBytes_Span_ExistingFile_ShouldAppendLinesToFile( string path, byte[] previousBytes, byte[] bytes) { @@ -88,8 +88,8 @@ public async Task AppendAllBytes_Span_ExistingFile_ShouldAppendLinesToFile( await That(FileSystem.File.ReadAllBytes(path)).IsEqualTo([..previousBytes, ..bytes]); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllBytes_Span_MissingDirectory_ShouldThrowDirectoryNotFoundException( string missingPath, string fileName, byte[] bytes) { @@ -102,8 +102,8 @@ void Act() await That(Act).Throws().WithHResult(-2147024893); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllBytes_Span_MissingFile_ShouldCreateFile( string path, byte[] bytes) { @@ -113,8 +113,8 @@ public async Task AppendAllBytes_Span_MissingFile_ShouldCreateFile( await That(FileSystem.File.ReadAllBytes(path)).IsEqualTo(bytes); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllBytes_Span_ShouldAdjustTimes(string path, byte[] bytes) { SkipIfLongRunningTestsShouldBeSkipped(); @@ -144,8 +144,8 @@ public async Task AppendAllBytes_Span_ShouldAdjustTimes(string path, byte[] byte await That(lastWriteTime).IsOnOrAfter(updateTime.ApplySystemClockTolerance()); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllBytes_Span_WhenDirectoryWithSameNameExists_ShouldThrowUnauthorizedAccessException( string path) @@ -162,8 +162,8 @@ void Act() await That(FileSystem.File.Exists(path)).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllBytes_Span_WhenFileIsHidden_ShouldNotThrowException( string path, byte[] bytes) { @@ -178,8 +178,8 @@ void Act() await That(Act).DoesNotThrow(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllBytes_WhenDirectoryWithSameNameExists_ShouldThrowUnauthorizedAccessException( string path) @@ -196,8 +196,8 @@ void Act() await That(FileSystem.File.Exists(path)).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllBytes_WhenFileIsHidden_ShouldNotThrowException( string path, byte[] bytes) { diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/File/AppendAllLinesAsyncTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/File/AppendAllLinesAsyncTests.cs index bce6e4a3a..70f7695ed 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/File/AppendAllLinesAsyncTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/File/AppendAllLinesAsyncTests.cs @@ -10,10 +10,10 @@ namespace Testably.Abstractions.Tests.FileSystem.File; // ReSharper disable MethodHasAsyncOverload [FileSystemTests] -public partial class AppendAllLinesAsyncTests +public class AppendAllLinesAsyncTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllLinesAsync_Cancelled_ShouldThrowTaskCanceledException( string path, List contents) { @@ -26,8 +26,8 @@ async Task Act() => await That(Act).Throws().WithHResult(-2146233029); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllLinesAsync_Cancelled_WithEncoding_ShouldThrowTaskCanceledException( string path, List contents) @@ -42,8 +42,8 @@ await FileSystem.File.AppendAllLinesAsync(path, contents, Encoding.UTF8, await That(Act).Throws().WithHResult(-2146233029); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllLinesAsync_Enumerable_WithoutEncoding_ShouldUseUtf8( string path) { @@ -56,25 +56,25 @@ await FileSystem.File.AppendAllLinesAsync(path, contents.AsEnumerable(), await That(bytes.Length).IsEqualTo(6 + Environment.NewLine.Length); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllLinesAsync_ExistingFile_ShouldAppendLinesToFile( string path, List previousContents, List contents) { string expectedContent = string.Join(Environment.NewLine, previousContents.Concat(contents)) + Environment.NewLine; await FileSystem.File.AppendAllLinesAsync(path, previousContents, - TestContext.Current.CancellationToken); + CancellationToken); await FileSystem.File.AppendAllLinesAsync(path, contents, - TestContext.Current.CancellationToken); + CancellationToken); await That(FileSystem.File.Exists(path)).IsTrue(); await That(FileSystem.File.ReadAllText(path)).IsEqualTo(expectedContent); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllLinesAsync_MissingDirectory_ShouldThrowDirectoryNotFoundException( string missingPath, string fileName, List contents) { @@ -83,14 +83,14 @@ public async Task AppendAllLinesAsync_MissingDirectory_ShouldThrowDirectoryNotFo async Task Act() { await FileSystem.File.AppendAllLinesAsync(filePath, contents, - TestContext.Current.CancellationToken); + CancellationToken); } await That(Act).Throws().WithHResult(-2147024893); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllLinesAsync_MissingFile_ShouldCreateFile( string path, List contents) { @@ -98,21 +98,21 @@ public async Task AppendAllLinesAsync_MissingFile_ShouldCreateFile( + Environment.NewLine; await FileSystem.File.AppendAllLinesAsync(path, contents, - TestContext.Current.CancellationToken); + CancellationToken); await That(FileSystem.File.Exists(path)).IsTrue(); await That(FileSystem.File.ReadAllText(path)).IsEqualTo(expectedContent); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllLinesAsync_NullContent_ShouldThrowArgumentNullException( string path) { async Task Act() { await FileSystem.File.AppendAllLinesAsync(path, null!, - TestContext.Current.CancellationToken); + CancellationToken); } await That(Act).Throws() @@ -120,15 +120,15 @@ await That(Act).Throws() .WithParamName("contents"); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllLinesAsync_NullEncoding_ShouldThrowArgumentNullException( string path) { async Task Act() { await FileSystem.File.AppendAllLinesAsync(path, [], null!, - TestContext.Current.CancellationToken); + CancellationToken); } await That(Act).Throws() @@ -136,22 +136,22 @@ await That(Act).Throws() .WithParamName("encoding"); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllLinesAsync_ShouldEndWithNewline(string path) { string[] contents = ["foo", "bar"]; string expectedResult = "foo" + Environment.NewLine + "bar" + Environment.NewLine; await FileSystem.File.AppendAllLinesAsync(path, contents, - TestContext.Current.CancellationToken); + CancellationToken); await That(FileSystem.File.Exists(path)).IsTrue(); await That(FileSystem.File.ReadAllText(path)).IsEqualTo(expectedResult); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllLinesAsync_WhenDirectoryWithSameNameExists_ShouldThrowUnauthorizedAccessException( string path, string[] contents) @@ -161,7 +161,7 @@ public async Task async Task Act() { await FileSystem.File.AppendAllLinesAsync(path, contents, - TestContext.Current.CancellationToken); + CancellationToken); } await That(Act).Throws().WithHResult(-2147024891); @@ -169,8 +169,8 @@ await FileSystem.File.AppendAllLinesAsync(path, contents, await That(FileSystem.File.Exists(path)).IsFalse(); } - [Theory] - [ClassData(typeof(TestDataGetEncodingDifference))] + [Test] + [MethodDataSource(typeof(TestData), nameof(TestData.GetEncodingDifference))] public async Task AppendAllLinesAsync_WithDifferentEncoding_ShouldNotReturnWrittenText( string specialLine, Encoding writeEncoding, Encoding readEncoding) @@ -179,7 +179,7 @@ public async Task string[] lines = new Fixture().Create(); lines[1] = specialLine; await FileSystem.File.AppendAllLinesAsync(path, lines, writeEncoding, - TestContext.Current.CancellationToken); + CancellationToken); string[] result = FileSystem.File.ReadAllLines(path, readEncoding); diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/File/AppendAllLinesTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/File/AppendAllLinesTests.cs index 8f7069aaf..9288814a4 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/File/AppendAllLinesTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/File/AppendAllLinesTests.cs @@ -6,10 +6,10 @@ namespace Testably.Abstractions.Tests.FileSystem.File; [FileSystemTests] -public partial class AppendAllLinesTests +public class AppendAllLinesTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllLines_Enumerable_WithoutEncoding_ShouldUseUtf8( string path) { @@ -21,8 +21,8 @@ public async Task AppendAllLines_Enumerable_WithoutEncoding_ShouldUseUtf8( await That(bytes.Length).IsEqualTo(6 + Environment.NewLine.Length); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllLines_ExistingFile_ShouldAppendLinesToFile( string path, List previousContents, List contents) { @@ -36,8 +36,8 @@ public async Task AppendAllLines_ExistingFile_ShouldAppendLinesToFile( await That(FileSystem.File.ReadAllText(path)).IsEqualTo(expectedContent); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllLines_MissingFile_ShouldCreateFile( string path, List contents) { @@ -49,8 +49,8 @@ public async Task AppendAllLines_MissingFile_ShouldCreateFile( await That(FileSystem.File.ReadAllText(path)).IsEqualTo(expectedContent); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllLines_NullContent_ShouldThrowArgumentNullException( string path) { @@ -64,8 +64,8 @@ await That(Act).Throws() .WithParamName("contents"); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllLines_NullEncoding_ShouldThrowArgumentNullException( string path) { @@ -79,8 +79,8 @@ await That(Act).Throws() .WithParamName("encoding"); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllLines_ShouldEndWithNewline(string path) { string[] contents = ["foo", "bar"]; @@ -92,8 +92,8 @@ public async Task AppendAllLines_ShouldEndWithNewline(string path) await That(FileSystem.File.ReadAllText(path)).IsEqualTo(expectedResult); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllLines_WhenDirectoryWithSameNameExists_ShouldThrowUnauthorizedAccessException( string path, string[] contents) @@ -110,8 +110,8 @@ void Act() await That(FileSystem.File.Exists(path)).IsFalse(); } - [Theory] - [ClassData(typeof(TestDataGetEncodingDifference))] + [Test] + [MethodDataSource(typeof(TestData), nameof(TestData.GetEncodingDifference))] public async Task AppendAllLines_WithDifferentEncoding_ShouldNotReturnWrittenText( string specialLine, Encoding writeEncoding, Encoding readEncoding) { @@ -126,8 +126,8 @@ public async Task AppendAllLines_WithDifferentEncoding_ShouldNotReturnWrittenTex await That(result[0]).IsEqualTo(lines[0]); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllLines_WithoutEncoding_ShouldUseUtf8( string path) { diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/File/AppendAllTextAsyncTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/File/AppendAllTextAsyncTests.cs index b765c37f7..4db7731e2 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/File/AppendAllTextAsyncTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/File/AppendAllTextAsyncTests.cs @@ -8,10 +8,10 @@ namespace Testably.Abstractions.Tests.FileSystem.File; // ReSharper disable MethodHasAsyncOverload [FileSystemTests] -public partial class AppendAllTextAsyncTests +public class AppendAllTextAsyncTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllTextAsync_Cancelled_ShouldThrowTaskCanceledException( string path, string contents) { @@ -24,8 +24,8 @@ async Task Act() => await That(Act).Throws().WithHResult(-2146233029); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllTextAsync_Cancelled_WithEncoding_ShouldThrowTaskCanceledException( string path, string contents) @@ -39,23 +39,23 @@ async Task Act() => await That(Act).Throws().WithHResult(-2146233029); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllTextAsync_ExistingFile_ShouldAppendLinesToFile( string path, string previousContents, string contents) { await FileSystem.File.AppendAllTextAsync(path, previousContents, - TestContext.Current.CancellationToken); + CancellationToken); await FileSystem.File.AppendAllTextAsync(path, contents, - TestContext.Current.CancellationToken); + CancellationToken); await That(FileSystem.File.Exists(path)).IsTrue(); await That(FileSystem.File.ReadAllText(path)).IsEqualTo(previousContents + contents); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllTextAsync_MissingDirectory_ShouldThrowDirectoryNotFoundException( string missingPath, string fileName, string contents) { @@ -64,39 +64,39 @@ public async Task AppendAllTextAsync_MissingDirectory_ShouldThrowDirectoryNotFou async Task Act() { await FileSystem.File.AppendAllTextAsync(filePath, contents, - TestContext.Current.CancellationToken); + CancellationToken); } await That(Act).Throws().WithHResult(-2147024893); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllTextAsync_MissingFile_ShouldCreateFile( string path, string contents) { await FileSystem.File.AppendAllTextAsync(path, contents, - TestContext.Current.CancellationToken); + CancellationToken); await That(FileSystem.File.Exists(path)).IsTrue(); await That(FileSystem.File.ReadAllText(path)).IsEqualTo(contents); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllTextAsync_ShouldNotEndWithNewline(string path) { string contents = "foo"; await FileSystem.File.AppendAllTextAsync(path, contents, - TestContext.Current.CancellationToken); + CancellationToken); await That(FileSystem.File.Exists(path)).IsTrue(); await That(FileSystem.File.ReadAllText(path)).IsEqualTo(contents); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllTextAsync_WhenDirectoryWithSameNameExists_ShouldThrowUnauthorizedAccessException( string path, string contents) @@ -106,7 +106,7 @@ public async Task async Task Act() { await FileSystem.File.AppendAllTextAsync(path, contents, - TestContext.Current.CancellationToken); + CancellationToken); } await That(Act).Throws().WithHResult(-2147024891); @@ -114,22 +114,22 @@ await FileSystem.File.AppendAllTextAsync(path, contents, await That(FileSystem.File.Exists(path)).IsFalse(); } - [Theory] - [ClassData(typeof(TestDataGetEncodingDifference))] + [Test] + [MethodDataSource(typeof(TestData), nameof(TestData.GetEncodingDifference))] public async Task AppendAllTextAsync_WithDifferentEncoding_ShouldNotReturnWrittenText( string contents, Encoding writeEncoding, Encoding readEncoding) { string path = new Fixture().Create(); await FileSystem.File.AppendAllTextAsync(path, contents, writeEncoding, - TestContext.Current.CancellationToken); + CancellationToken); string[] result = FileSystem.File.ReadAllLines(path, readEncoding); await That(result).IsNotEqualTo([contents]); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllTextAsync_WithoutEncoding_ShouldUseUtf8( string path) { @@ -142,8 +142,8 @@ public async Task AppendAllTextAsync_WithoutEncoding_ShouldUseUtf8( } #if FEATURE_FILE_SPAN - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllTextAsync_ReadOnlyMemory_Cancelled_ShouldThrowTaskCanceledException( string path, string contents) { @@ -156,8 +156,8 @@ async Task Act() => await That(Act).Throws().WithHResult(-2146233029); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllTextAsync_ReadOnlyMemory_Cancelled_WithEncoding_ShouldThrowTaskCanceledException( string path, string contents) @@ -172,23 +172,23 @@ await FileSystem.File.AppendAllTextAsync(path, contents.AsMemory(), Encoding.UTF await That(Act).Throws().WithHResult(-2146233029); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllTextAsync_ReadOnlyMemory_ExistingFile_ShouldAppendLinesToFile( string path, string previousContents, string contents) { await FileSystem.File.AppendAllTextAsync(path, previousContents, - TestContext.Current.CancellationToken); + CancellationToken); await FileSystem.File.AppendAllTextAsync(path, contents.AsMemory(), - TestContext.Current.CancellationToken); + CancellationToken); await That(FileSystem.File.Exists(path)).IsTrue(); await That(FileSystem.File.ReadAllText(path)).IsEqualTo(previousContents + contents); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllTextAsync_ReadOnlyMemory_MissingDirectory_ShouldThrowDirectoryNotFoundException( string missingPath, string fileName, string contents) @@ -198,39 +198,39 @@ public async Task async Task Act() { await FileSystem.File.AppendAllTextAsync(filePath, contents.AsMemory(), - TestContext.Current.CancellationToken); + CancellationToken); } await That(Act).Throws().WithHResult(-2147024893); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllTextAsync_ReadOnlyMemory_MissingFile_ShouldCreateFile( string path, string contents) { await FileSystem.File.AppendAllTextAsync(path, contents.AsMemory(), - TestContext.Current.CancellationToken); + CancellationToken); await That(FileSystem.File.Exists(path)).IsTrue(); await That(FileSystem.File.ReadAllText(path)).IsEqualTo(contents); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllTextAsync_ReadOnlyMemory_ShouldNotEndWithNewline(string path) { string contents = "foo"; await FileSystem.File.AppendAllTextAsync(path, contents.AsMemory(), - TestContext.Current.CancellationToken); + CancellationToken); await That(FileSystem.File.Exists(path)).IsTrue(); await That(FileSystem.File.ReadAllText(path)).IsEqualTo(contents); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllTextAsync_ReadOnlyMemory_WhenDirectoryWithSameNameExists_ShouldThrowUnauthorizedAccessException( string path, string contents) @@ -240,7 +240,7 @@ public async Task async Task Act() { await FileSystem.File.AppendAllTextAsync(path, contents.AsMemory(), - TestContext.Current.CancellationToken); + CancellationToken); } await That(Act).Throws().WithHResult(-2147024891); @@ -248,23 +248,23 @@ await FileSystem.File.AppendAllTextAsync(path, contents.AsMemory(), await That(FileSystem.File.Exists(path)).IsFalse(); } - [Theory] - [ClassData(typeof(TestDataGetEncodingDifference))] + [Test] + [MethodDataSource(typeof(TestData), nameof(TestData.GetEncodingDifference))] public async Task AppendAllTextAsync_ReadOnlyMemory_WithDifferentEncoding_ShouldNotReturnWrittenText( string contents, Encoding writeEncoding, Encoding readEncoding) { string path = new Fixture().Create(); await FileSystem.File.AppendAllTextAsync(path, contents.AsMemory(), writeEncoding, - TestContext.Current.CancellationToken); + CancellationToken); string[] result = FileSystem.File.ReadAllLines(path, readEncoding); await That(result).IsNotEqualTo([contents]); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllTextAsync_ReadOnlyMemory_WithoutEncoding_ShouldUseUtf8( string path) { diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/File/AppendAllTextTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/File/AppendAllTextTests.cs index f1422a764..f84933a52 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/File/AppendAllTextTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/File/AppendAllTextTests.cs @@ -5,10 +5,10 @@ namespace Testably.Abstractions.Tests.FileSystem.File; [FileSystemTests] -public partial class AppendAllTextTests +public class AppendAllTextTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllText_ExistingFile_ShouldAppendLinesToFile( string path, string previousContents, string contents) { @@ -20,8 +20,8 @@ public async Task AppendAllText_ExistingFile_ShouldAppendLinesToFile( await That(FileSystem.File.ReadAllText(path)).IsEqualTo(previousContents + contents); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllText_MissingDirectory_ShouldThrowDirectoryNotFoundException( string missingPath, string fileName, string contents) { @@ -35,8 +35,8 @@ void Act() await That(Act).Throws().WithHResult(-2147024893); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllText_MissingFile_ShouldCreateFile( string path, string contents) { @@ -46,8 +46,8 @@ public async Task AppendAllText_MissingFile_ShouldCreateFile( await That(FileSystem.File.ReadAllText(path)).IsEqualTo(contents); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllText_MissingFile_ShouldCreateFileWithByteOrderMark( string path) { @@ -59,8 +59,8 @@ public async Task AppendAllText_MissingFile_ShouldCreateFileWithByteOrderMark( await That(FileSystem.File.ReadAllBytes(path)).IsEqualTo(expectedBytes); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllText_ShouldAdjustTimes(string path, string contents) { SkipIfLongRunningTestsShouldBeSkipped(); @@ -92,8 +92,8 @@ await That(lastAccessTime).IsBetween(creationTimeStart).And(creationTimeEnd) await That(lastWriteTime).IsOnOrAfter(updateTime.ApplySystemClockTolerance()); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllText_ShouldNotEndWithNewline(string path) { string contents = "foo"; @@ -104,8 +104,8 @@ public async Task AppendAllText_ShouldNotEndWithNewline(string path) await That(FileSystem.File.ReadAllText(path)).IsEqualTo(contents); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllText_WhenDirectoryWithSameNameExists_ShouldThrowUnauthorizedAccessException( string path) @@ -123,8 +123,8 @@ await That(Act).Throws() await That(FileSystem.File.Exists(path)).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllText_WhenFileIsHidden_ShouldNotThrowException( string path, string contents) { @@ -139,8 +139,8 @@ void Act() await That(Act).DoesNotThrow(); } - [Theory] - [ClassData(typeof(TestDataGetEncodingDifference))] + [Test] + [MethodDataSource(typeof(TestData), nameof(TestData.GetEncodingDifference))] public async Task AppendAllText_WithDifferentEncoding_ShouldNotReturnWrittenText( string contents, Encoding writeEncoding, Encoding readEncoding) { @@ -152,8 +152,8 @@ public async Task AppendAllText_WithDifferentEncoding_ShouldNotReturnWrittenText await That(result).IsNotEqualTo([contents]); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllText_WithoutEncoding_ShouldUseUtf8( string path) { @@ -166,8 +166,8 @@ public async Task AppendAllText_WithoutEncoding_ShouldUseUtf8( } #if FEATURE_FILE_SPAN - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllText_Span_ExistingFile_ShouldAppendLinesToFile( string path, string previousContents, string contents) { @@ -179,8 +179,8 @@ public async Task AppendAllText_Span_ExistingFile_ShouldAppendLinesToFile( await That(FileSystem.File.ReadAllText(path)).IsEqualTo(previousContents + contents); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllText_Span_MissingDirectory_ShouldThrowDirectoryNotFoundException( string missingPath, string fileName, string contents) { @@ -194,8 +194,8 @@ void Act() await That(Act).Throws().WithHResult(-2147024893); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllText_Span_MissingFile_ShouldCreateFile( string path, string contents) { @@ -205,8 +205,8 @@ public async Task AppendAllText_Span_MissingFile_ShouldCreateFile( await That(FileSystem.File.ReadAllText(path)).IsEqualTo(contents); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllText_Span_MissingFile_ShouldCreateFileWithByteOrderMark( string path) { @@ -218,8 +218,8 @@ public async Task AppendAllText_Span_MissingFile_ShouldCreateFileWithByteOrderMa await That(FileSystem.File.ReadAllBytes(path)).IsEqualTo(expectedBytes); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllText_Span_ShouldAdjustTimes(string path, string contents) { SkipIfLongRunningTestsShouldBeSkipped(); @@ -251,8 +251,8 @@ await That(lastAccessTime).IsBetween(creationTimeStart).And(creationTimeEnd) await That(lastWriteTime).IsOnOrAfter(updateTime.ApplySystemClockTolerance()); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllText_Span_ShouldNotEndWithNewline(string path) { string contents = "foo"; @@ -263,8 +263,8 @@ public async Task AppendAllText_Span_ShouldNotEndWithNewline(string path) await That(FileSystem.File.ReadAllText(path)).IsEqualTo(contents); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllText_Span_WhenDirectoryWithSameNameExists_ShouldThrowUnauthorizedAccessException( string path) @@ -281,8 +281,8 @@ void Act() await That(FileSystem.File.Exists(path)).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllText_Span_WhenFileIsHidden_ShouldNotThrowException( string path, string contents) { @@ -297,8 +297,8 @@ void Act() await That(Act).DoesNotThrow(); } - [Theory] - [ClassData(typeof(TestDataGetEncodingDifference))] + [Test] + [MethodDataSource(typeof(TestData), nameof(TestData.GetEncodingDifference))] public async Task AppendAllText_Span_WithDifferentEncoding_ShouldNotReturnWrittenText( string contents, Encoding writeEncoding, Encoding readEncoding) { @@ -310,8 +310,8 @@ public async Task AppendAllText_Span_WithDifferentEncoding_ShouldNotReturnWritte await That(result).IsNotEqualTo([contents]); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendAllText_Span_WithoutEncoding_ShouldUseUtf8( string path) { diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/File/AppendTextTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/File/AppendTextTests.cs index 2482fbd59..1678a3808 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/File/AppendTextTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/File/AppendTextTests.cs @@ -3,10 +3,10 @@ namespace Testably.Abstractions.Tests.FileSystem.File; [FileSystemTests] -public partial class AppendTextTests +public class AppendTextTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendText_MissingFile_ShouldCreateFile( string path, string appendText) { @@ -19,8 +19,8 @@ public async Task AppendText_MissingFile_ShouldCreateFile( await That(FileSystem.File.ReadAllText(path)).IsEqualTo(appendText); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendText_ShouldAddTextToExistingFile( string path, string contents, string appendText) { diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/File/CopyTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/File/CopyTests.cs index 78f7f4293..a033f47b6 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/File/CopyTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/File/CopyTests.cs @@ -3,10 +3,10 @@ namespace Testably.Abstractions.Tests.FileSystem.File; [FileSystemTests] -public partial class CopyTests +public class CopyTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Copy_CaseOnlyChange_ShouldThrowIOException_ExceptOnLinux( string name, string contents) { @@ -32,8 +32,8 @@ await That(Act).Throws() } } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Copy_DestinationDirectoryDoesNotExist_ShouldThrowDirectoryNotFoundException( string source) @@ -50,8 +50,8 @@ void Act() await That(Act).Throws().WithHResult(-2147024893); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Copy_DestinationExists_ShouldThrowIOException_AndNotCopyFile( string sourceName, string destinationName, @@ -75,8 +75,8 @@ void Act() } #if FEATURE_FILE_MOVETO_OVERWRITE - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Copy_DestinationExists_WithOverwrite_ShouldOverwriteDestination( string sourceName, string destinationName, @@ -95,10 +95,10 @@ public async Task Copy_DestinationExists_WithOverwrite_ShouldOverwriteDestinatio } #endif - [Theory] - [InlineData(@"0:\something\demo.txt", @"C:\elsewhere\demo.txt")] - [InlineData(@"C:\something\demo.txt", @"^:\elsewhere\demo.txt")] - [InlineData(@"C:\something\demo.txt", @"C:\elsewhere:\demo.txt")] + [Test] + [Arguments(@"0:\something\demo.txt", @"C:\elsewhere\demo.txt")] + [Arguments(@"C:\something\demo.txt", @"^:\elsewhere\demo.txt")] + [Arguments(@"C:\something\demo.txt", @"C:\elsewhere:\demo.txt")] public async Task Copy_InvalidDriveName_ShouldThrowNotSupportedException( string source, string destination) @@ -113,8 +113,8 @@ void Act() await That(Act).Throws().WithHResult(-2146233067); } - [Theory] - [InlineData(@"C::\something\demo.txt", @"C:\elsewhere\demo.txt")] + [Test] + [Arguments(@"C::\something\demo.txt", @"C:\elsewhere\demo.txt")] public async Task Copy_InvalidPath_ShouldThrowCorrectException( string source, string destination) @@ -139,8 +139,8 @@ await That(Act).Throws() } } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Copy_ReadOnly_ShouldCopyFile( string sourceName, string destinationName, string contents) { @@ -156,8 +156,8 @@ public async Task Copy_ReadOnly_ShouldCopyFile( await That(FileSystem.File.GetAttributes(destinationName)).HasFlag(FileAttributes.ReadOnly); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Copy_ShouldAdjustTimes( string source, string destination) { @@ -223,8 +223,8 @@ await That(destinationLastWriteTime).IsBetween(creationTimeStart).And(creationTi .Within(TimeComparison.Tolerance); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Copy_ShouldCloneBinaryContent( string source, string destination, byte[] original) { @@ -247,8 +247,8 @@ await That(FileSystem.File.ReadAllBytes(destination)) .IsNotEqualTo(FileSystem.File.ReadAllBytes(source)); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Copy_ShouldCloneTextContent( string source, string destination, string contents) { @@ -269,8 +269,8 @@ await That(FileSystem.File.ReadAllText(source)) .IsNotEqualTo(FileSystem.File.ReadAllText(destination)); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Copy_ShouldCopyFileWithContent( string sourceName, string destinationName, string contents) { @@ -287,13 +287,13 @@ public async Task Copy_ShouldCopyFileWithContent( await That(FileSystem.File.ReadAllText(destinationName)).IsEqualTo(contents); } - [Theory] - [InlineAutoData(FileAccess.Read, FileShare.Read)] - [InlineAutoData(FileAccess.Read, FileShare.ReadWrite)] - [InlineAutoData(FileAccess.ReadWrite, FileShare.Read)] - [InlineAutoData(FileAccess.ReadWrite, FileShare.ReadWrite)] - [InlineAutoData(FileAccess.Write, FileShare.Read)] - [InlineAutoData(FileAccess.Write, FileShare.ReadWrite)] + [Test] + [AutoArguments(FileAccess.Read, FileShare.Read)] + [AutoArguments(FileAccess.Read, FileShare.ReadWrite)] + [AutoArguments(FileAccess.ReadWrite, FileShare.Read)] + [AutoArguments(FileAccess.ReadWrite, FileShare.ReadWrite)] + [AutoArguments(FileAccess.Write, FileShare.Read)] + [AutoArguments(FileAccess.Write, FileShare.ReadWrite)] public async Task Copy_SourceAccessedWithReadShare_ShouldNotThrow( FileAccess fileAccess, FileShare fileShare, @@ -313,10 +313,10 @@ public async Task Copy_SourceAccessedWithReadShare_ShouldNotThrow( await That(FileSystem.File.ReadAllText(destinationPath)).IsEqualTo(sourceContents); } - [Theory] - [InlineAutoData(FileAccess.Read)] - [InlineAutoData(FileAccess.ReadWrite)] - [InlineAutoData(FileAccess.Write)] + [Test] + [AutoArguments(FileAccess.Read)] + [AutoArguments(FileAccess.ReadWrite)] + [AutoArguments(FileAccess.Write)] public async Task Copy_SourceAccessedWithWriteShare_ShouldNotThrowOnLinuxOrMac( FileAccess fileAccess, string sourcePath, @@ -337,8 +337,8 @@ public async Task Copy_SourceAccessedWithWriteShare_ShouldNotThrowOnLinuxOrMac( await That(FileSystem.File.ReadAllText(destinationPath)).IsEqualTo(sourceContents); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Copy_SourceDirectoryMissing_ShouldThrowDirectoryNotFoundException( string missingDirectory, string sourceName, @@ -359,8 +359,8 @@ await That(Act).Throws() await That(FileSystem.File.Exists(destinationName)).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Copy_SourceIsDirectory_ShouldThrowUnauthorizedAccessException_AndNotCopyFile( string sourceName, string destinationName) @@ -381,9 +381,9 @@ await That(Act).Throws() await That(FileSystem.File.Exists(destinationName)).IsFalse(); } - [Theory] - [InlineAutoData(FileShare.None)] - [InlineAutoData(FileShare.Write)] + [Test] + [AutoArguments(FileShare.None)] + [AutoArguments(FileShare.Write)] public async Task Copy_SourceLocked_ShouldThrowIOException( FileShare fileShare, string sourceName, @@ -414,8 +414,8 @@ void Act() } } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Copy_SourceMissing_ShouldThrowFileNotFoundException( string sourceName, string destinationName) diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/File/CreateSymbolicLinkTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/File/CreateSymbolicLinkTests.cs index a6c54c0c9..75c8ba419 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/File/CreateSymbolicLinkTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/File/CreateSymbolicLinkTests.cs @@ -4,10 +4,10 @@ namespace Testably.Abstractions.Tests.FileSystem.File; [FileSystemTests] -public partial class CreateSymbolicLinkTests +public class CreateSymbolicLinkTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateSymbolicLink_ShouldCreateSymbolicLink( string path, string pathToTarget) { @@ -19,8 +19,8 @@ await That(FileSystem.File.GetAttributes(path)) .HasFlag(FileAttributes.ReparsePoint); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateSymbolicLink_SourceFileAlreadyExists_ShouldThrowIOException( string path, string pathToTarget) { @@ -37,8 +37,8 @@ await That(Act).Throws() .WithHResult(Test.RunsOnWindows ? -2147024713 : 17); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateSymbolicLink_TargetFileMissing_ShouldNotThrowException( string path, string pathToTarget) { diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/File/CreateTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/File/CreateTests.cs index c01578b07..3cddb31ae 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/File/CreateTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/File/CreateTests.cs @@ -3,10 +3,10 @@ namespace Testably.Abstractions.Tests.FileSystem.File; [FileSystemTests] -public partial class CreateTests +public class CreateTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Create_ExistingFile_ShouldBeOverwritten( string path, string originalContent, string newContent) { @@ -22,8 +22,8 @@ public async Task Create_ExistingFile_ShouldBeOverwritten( await That(FileSystem.File.ReadAllText(path)).IsEqualTo(newContent); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Create_MissingDirectory_ShouldThrowDirectoryNotFoundException( string missingDirectory, string fileName) { @@ -37,8 +37,8 @@ void Act() await That(Act).Throws().WithHResult(-2147024893); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Create_MissingFile_ShouldCreateFile(string path) { using FileSystemStream stream = FileSystem.File.Create(path); @@ -46,8 +46,8 @@ public async Task Create_MissingFile_ShouldCreateFile(string path) await That(FileSystem.File.Exists(path)).IsTrue(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Create_ReadOnlyFile_ShouldThrowUnauthorizedAccessException( string path, string content) { @@ -62,8 +62,8 @@ void Act() await That(Act).Throws().WithHResult(-2147024891); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Create_ShouldUseReadWriteAccessAndNoneShare(string path) { using FileSystemStream stream = FileSystem.File.Create(path); @@ -76,8 +76,8 @@ public async Task Create_ShouldUseReadWriteAccessAndNoneShare(string path) await That(stream.CanTimeout).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Create_WithBufferSize_ShouldUseReadWriteAccessAndNoneShare( string path, int bufferSize) { @@ -90,8 +90,8 @@ public async Task Create_WithBufferSize_ShouldUseReadWriteAccessAndNoneShare( await That(FileTestHelper.CheckFileShare(FileSystem, path)).IsEqualTo(FileShare.None); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Create_WithBufferSizeAndFileOptions_ShouldUseReadWriteAccessAndNoneShare( string path, int bufferSize) { diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/File/CreateTextTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/File/CreateTextTests.cs index 2b98a0a01..94068c930 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/File/CreateTextTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/File/CreateTextTests.cs @@ -3,10 +3,10 @@ namespace Testably.Abstractions.Tests.FileSystem.File; [FileSystemTests] -public partial class CreateTextTests +public class CreateTextTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateText_MissingFile_ShouldCreateFile( string path, string appendText) { @@ -19,8 +19,8 @@ public async Task CreateText_MissingFile_ShouldCreateFile( await That(FileSystem.File.ReadAllText(path)).IsEqualTo(appendText); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateText_ShouldReplaceTextInExistingFile( string path, string contents, string appendText) { diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/File/DeleteTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/File/DeleteTests.cs index fc923e14b..490f0eeec 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/File/DeleteTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/File/DeleteTests.cs @@ -3,10 +3,10 @@ namespace Testably.Abstractions.Tests.FileSystem.File; [FileSystemTests] -public partial class DeleteTests +public class DeleteTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Delete_MissingDirectory_ShouldThrowDirectoryNotFoundException( string missingDirectory, string fileName) { @@ -20,8 +20,8 @@ void Act() await That(Act).Throws().WithHResult(-2147024893); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Delete_MissingFile_ShouldDoNothing( string fileName) { @@ -33,8 +33,8 @@ void Act() await That(Act).DoesNotThrow(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Delete_WhenDirectory_ShouldThrowUnauthorizedAccessException( string fileName) { @@ -51,8 +51,8 @@ await That(Act).Throws() .WithHResult(-2147024891); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Delete_WithOpenFile_ShouldThrowIOException_OnWindows(string filename) { FileSystem.Initialize(); diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/File/EncryptDecryptTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/File/EncryptDecryptTests.cs index f23959481..dddab7916 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/File/EncryptDecryptTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/File/EncryptDecryptTests.cs @@ -3,10 +3,10 @@ namespace Testably.Abstractions.Tests.FileSystem.File; [FileSystemTests] -public partial class EncryptDecryptTests +public class EncryptDecryptTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] [SupportedOSPlatform("windows")] public async Task Decrypt_EncryptedData_ShouldReturnOriginalText( string path, string contents) @@ -23,8 +23,8 @@ public async Task Decrypt_EncryptedData_ShouldReturnOriginalText( await That(result).IsEqualTo(contents); } - [Theory] - [AutoData] + [Test] + [AutoArguments] [SupportedOSPlatform("windows")] public async Task Decrypt_UnencryptedData_ShouldReturnOriginalText( string path, string contents) @@ -39,8 +39,8 @@ public async Task Decrypt_UnencryptedData_ShouldReturnOriginalText( await That(result).IsEqualTo(contents); } - [Theory] - [AutoData] + [Test] + [AutoArguments] [SupportedOSPlatform("windows")] public async Task Encrypt_Decrypt_ShouldChangeEncryptedFileAttribute( string path, string contents) @@ -58,8 +58,8 @@ public async Task Encrypt_Decrypt_ShouldChangeEncryptedFileAttribute( await That(FileSystem.File.GetAttributes(path)).DoesNotHaveFlag(FileAttributes.Encrypted); } - [Theory] - [AutoData] + [Test] + [AutoArguments] [SupportedOSPlatform("windows")] public async Task Encrypt_ShouldChangeData( string path, byte[] bytes) @@ -75,8 +75,8 @@ public async Task Encrypt_ShouldChangeData( await That(result).IsNotEqualTo(bytes).InAnyOrder(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] [SupportedOSPlatform("windows")] public async Task Encrypt_Twice_ShouldIgnoreTheSecondTime( string path, string contents) diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/File/ExceptionMissingFileTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/File/ExceptionMissingFileTests.cs index fb44d56b8..2687cae54 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/File/ExceptionMissingFileTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/File/ExceptionMissingFileTests.cs @@ -11,10 +11,10 @@ namespace Testably.Abstractions.Tests.FileSystem.File; [FileSystemTests] -public partial class ExceptionMissingFileTests +public class ExceptionMissingFileTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [MemberData(nameof(GetFileCallbacks), (int)MissingFileTestCases.DirectoryMissing)] + [Test] + [MethodDataSource(nameof(GetDirectoryMissingCallbacks))] public async Task Operations_WhenDirectoryIsMissing_ShouldThrowDirectoryNotFoundException( Expression> callback, Func skipTest) { @@ -40,8 +40,8 @@ await That(Act).ThrowsAFileOrDirectoryNotFoundException() } } - [Theory] - [MemberData(nameof(GetFileCallbacks), (int)MissingFileTestCases.FileMissing)] + [Test] + [MethodDataSource(nameof(GetFileMissingCallbacks))] public async Task Operations_WhenFileIsMissing_ShouldThrowFileNotFoundException( Expression> callback, Func skipTest) { @@ -69,22 +69,25 @@ await That(Act).ThrowsAFileOrDirectoryNotFoundException() #region Helpers - #pragma warning disable MA0018 - public static TheoryData>, Func> GetFileCallbacks( + public static IEnumerable<(Expression>, Func)> + GetFileMissingCallbacks() + => GetFileCallbacks((int)MissingFileTestCases.FileMissing); + + public static IEnumerable<(Expression>, Func)> + GetDirectoryMissingCallbacks() + => GetFileCallbacks((int)MissingFileTestCases.DirectoryMissing); + + private static IEnumerable<(Expression>, Func)> GetFileCallbacks( int testCases) { - TheoryData>, Func> theoryData = new(); foreach ((MissingFileTestCases TestCase, ExpectedExceptionType ExceptionType, Expression> Callback, Func? SkipTest) item in GetFileCallbackTestParameters() .Where(item => (item.TestCase & (MissingFileTestCases)testCases) != 0)) { - theoryData.Add(item.Callback, item.SkipTest ?? (_ => false)); + yield return(item.Callback, item.SkipTest ?? (_ => false)); } - - return theoryData; } - #pragma warning restore MA0018 private static IEnumerable<(MissingFileTestCases TestCase, ExpectedExceptionType ExceptionType, Expression> Callback, Func? SkipTest)> diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/File/ExceptionTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/File/ExceptionTests.cs index af57e542e..5c642347b 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/File/ExceptionTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/File/ExceptionTests.cs @@ -10,10 +10,26 @@ namespace Testably.Abstractions.Tests.FileSystem.File; [FileSystemTests] -public partial class ExceptionTests +public class ExceptionTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [MemberData(nameof(GetFileCallbacks), "Illegal\tCharacter?InPath")] + public static IEnumerable<(Expression>, string, bool, Func)> + GetFileCallbacksWithEmptyPath() + => GetFileCallbacks(""); + + public static IEnumerable<(Expression>, string, bool, Func)> + GetFileCallbacksWithIllegalPathCharacters() + => GetFileCallbacks("Illegal\tCharacter?InPath"); + + public static IEnumerable<(Expression>, string, bool, Func)> + GetFileCallbacksWithNullPath() + => GetFileCallbacks(null); + + public static IEnumerable<(Expression>, string, bool, Func)> + GetFileCallbacksWithWhitespacePath() + => GetFileCallbacks(" "); + + [Test] + [MethodDataSource(nameof(GetFileCallbacksWithIllegalPathCharacters))] public async Task Operations_WhenValueContainsIllegalPathCharacters_ShouldThrowCorrectException_OnWindows( Expression> callback, string paramName, bool ignoreParamCheck, @@ -54,8 +70,8 @@ await That(Act).Throws() } } - [Theory] - [MemberData(nameof(GetFileCallbacks), "")] + [Test] + [MethodDataSource(nameof(GetFileCallbacksWithEmptyPath))] public async Task Operations_WhenValueIsEmpty_ShouldThrowArgumentException( Expression> callback, string paramName, bool ignoreParamCheck, Func skipTest) @@ -74,8 +90,8 @@ await That(Act).Throws() $"\n{callback}\n has empty parameter for '{paramName}' (ignored: {ignoreParamCheck})"); } - [Theory] - [MemberData(nameof(GetFileCallbacks), (string?)null)] + [Test] + [MethodDataSource(nameof(GetFileCallbacksWithNullPath))] public async Task Operations_WhenValueIsNull_ShouldThrowArgumentNullException( Expression> callback, string paramName, bool ignoreParamCheck, Func skipTest) @@ -93,8 +109,8 @@ await That(Act).Throws() $"\n{callback}\n has `null` parameter for '{paramName}' (ignored: {ignoreParamCheck})"); } - [Theory] - [MemberData(nameof(GetFileCallbacks), " ")] + [Test] + [MethodDataSource(nameof(GetFileCallbacksWithWhitespacePath))] public async Task Operations_WhenValueIsWhitespace_ShouldThrowArgumentException( Expression> callback, string paramName, bool ignoreParamCheck, Func skipTest) @@ -117,23 +133,20 @@ await That(Act).Throws() #region Helpers #pragma warning disable MA0018 - public static TheoryData>, string, bool, Func> + private static IEnumerable<(Expression>, string, bool, Func)> GetFileCallbacks(string? path) { - TheoryData>, string, bool, Func> theoryData = new(); foreach ((ExceptionTestHelper.TestTypes TestType, string ParamName, Expression> Callback, Func? SkipTest) item in GetFileCallbackTestParameters(path!) .Where(item => item.TestType.HasFlag(path.ToTestType()))) { - theoryData.Add( + yield return ( item.Callback, item.ParamName, item.TestType.HasFlag(ExceptionTestHelper.TestTypes.IgnoreParamNameCheck), item.SkipTest ?? (_ => false)); } - - return theoryData; } #pragma warning restore MA0018 diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/File/ExistsTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/File/ExistsTests.cs index 146414d93..814d94ef1 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/File/ExistsTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/File/ExistsTests.cs @@ -1,10 +1,10 @@ namespace Testably.Abstractions.Tests.FileSystem.File; [FileSystemTests] -public partial class ExistsTests +public class ExistsTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Exists_Directory_ShouldReturnFalse(string path) { FileSystem.Directory.CreateDirectory(path); @@ -14,7 +14,7 @@ public async Task Exists_Directory_ShouldReturnFalse(string path) await That(result).IsFalse(); } - [Fact] + [Test] public async Task Exists_Empty_ShouldReturnFalse() { bool result = FileSystem.File.Exists(string.Empty); @@ -22,7 +22,7 @@ public async Task Exists_Empty_ShouldReturnFalse() await That(result).IsFalse(); } - [Fact] + [Test] public async Task Exists_Null_ShouldReturnFalse() { bool result = FileSystem.File.Exists(null); diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/File/GetAttributesTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/File/GetAttributesTests.cs index cbc142688..cbb8a5f01 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/File/GetAttributesTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/File/GetAttributesTests.cs @@ -3,11 +3,11 @@ namespace Testably.Abstractions.Tests.FileSystem.File; [FileSystemTests] -public partial class GetAttributesTests +public class GetAttributesTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [InlineAutoData(FileAttributes.ReadOnly)] - [InlineAutoData(FileAttributes.Normal)] + [Test] + [AutoArguments(FileAttributes.ReadOnly)] + [AutoArguments(FileAttributes.Normal)] public async Task GetAttributes_ShouldReturnAttributes( FileAttributes attributes, string path) { @@ -19,7 +19,7 @@ public async Task GetAttributes_ShouldReturnAttributes( await That(result).IsEqualTo(attributes); } - [Fact] + [Test] public async Task GetAttributes_WhenDotEntry_ShouldHaveHiddenFlag() { Skip.If(Test.RunsOnWindows); diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/File/MoveTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/File/MoveTests.cs index 3d1685ce4..a10eb4be9 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/File/MoveTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/File/MoveTests.cs @@ -3,10 +3,10 @@ namespace Testably.Abstractions.Tests.FileSystem.File; [FileSystemTests] -public partial class MoveTests +public class MoveTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Move_CaseOnlyChange_ShouldMoveFileWithContent( string name, string contents) { @@ -28,8 +28,8 @@ await That(FileSystem.Directory.GetFiles(".")).HasSingle() .Matching(d => d.Contains(destinationName, StringComparison.Ordinal)); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Move_DestinationDirectoryDoesNotExist_ShouldThrowDirectoryNotFoundException( string source) @@ -46,8 +46,8 @@ void Act() await That(Act).Throws().WithHResult(-2147024893); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Move_DestinationExists_ShouldThrowIOException_AndNotMoveFile( string sourceName, string destinationName, @@ -71,8 +71,8 @@ void Act() } #if FEATURE_FILE_MOVETO_OVERWRITE - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Move_DestinationExists_WithOverwrite_ShouldOverwriteDestination( string sourceName, string destinationName, @@ -90,8 +90,8 @@ public async Task Move_DestinationExists_WithOverwrite_ShouldOverwriteDestinatio } #endif - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Move_ReadOnly_ShouldMoveFile( string sourceName, string destinationName, string contents) { @@ -106,8 +106,8 @@ public async Task Move_ReadOnly_ShouldMoveFile( await That(FileSystem.File.GetAttributes(destinationName)).HasFlag(FileAttributes.ReadOnly); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Move_ShouldMoveFileWithContent( string sourceName, string destinationName, string contents) { @@ -120,8 +120,8 @@ public async Task Move_ShouldMoveFileWithContent( await That(FileSystem.File.ReadAllText(destinationName)).IsEqualTo(contents); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Move_ShouldNotAdjustTimes(string source, string destination) { SkipIfLongRunningTestsShouldBeSkipped(); @@ -145,8 +145,8 @@ await That(lastWriteTime).IsBetween(creationTimeStart).And(creationTimeEnd) .Within(TimeComparison.Tolerance); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Move_SourceAndDestinationIdentical_ShouldNotThrowException(string path) { FileSystem.Initialize() @@ -160,8 +160,8 @@ void Act() await That(Act).DoesNotThrow(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Move_SourceDirectoryMissing_ShouldThrowFileNotFoundException( string missingDirectory, string sourceName, @@ -180,19 +180,19 @@ await That(Act).Throws() await That(FileSystem.File.Exists(destinationName)).IsFalse(); } - [Theory] - [InlineAutoData(FileAccess.Read, FileShare.None)] - [InlineAutoData(FileAccess.Read, FileShare.Read)] - [InlineAutoData(FileAccess.Read, FileShare.ReadWrite)] - [InlineAutoData(FileAccess.Read, FileShare.Write)] - [InlineAutoData(FileAccess.ReadWrite, FileShare.None)] - [InlineAutoData(FileAccess.ReadWrite, FileShare.Read)] - [InlineAutoData(FileAccess.ReadWrite, FileShare.ReadWrite)] - [InlineAutoData(FileAccess.ReadWrite, FileShare.Write)] - [InlineAutoData(FileAccess.Write, FileShare.None)] - [InlineAutoData(FileAccess.Write, FileShare.Read)] - [InlineAutoData(FileAccess.Write, FileShare.ReadWrite)] - [InlineAutoData(FileAccess.Write, FileShare.Write)] + [Test] + [AutoArguments(FileAccess.Read, FileShare.None)] + [AutoArguments(FileAccess.Read, FileShare.Read)] + [AutoArguments(FileAccess.Read, FileShare.ReadWrite)] + [AutoArguments(FileAccess.Read, FileShare.Write)] + [AutoArguments(FileAccess.ReadWrite, FileShare.None)] + [AutoArguments(FileAccess.ReadWrite, FileShare.Read)] + [AutoArguments(FileAccess.ReadWrite, FileShare.ReadWrite)] + [AutoArguments(FileAccess.ReadWrite, FileShare.Write)] + [AutoArguments(FileAccess.Write, FileShare.None)] + [AutoArguments(FileAccess.Write, FileShare.Read)] + [AutoArguments(FileAccess.Write, FileShare.ReadWrite)] + [AutoArguments(FileAccess.Write, FileShare.Write)] public async Task Move_SourceLocked_ShouldThrowIOException_OnWindows( FileAccess fileAccess, FileShare fileShare, @@ -223,8 +223,8 @@ void Act() } } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Move_SourceMissing_CopyToItself_ShouldThrowFileNotFoundException( string sourceName) { @@ -238,8 +238,8 @@ await That(Act).Throws() .WithHResult(-2147024894); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Move_SourceMissing_ShouldThrowFileNotFoundException( string sourceName, string destinationName) diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/File/OpenReadTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/File/OpenReadTests.cs index 2a5a5c5b6..f180dc1d2 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/File/OpenReadTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/File/OpenReadTests.cs @@ -3,10 +3,10 @@ namespace Testably.Abstractions.Tests.FileSystem.File; [FileSystemTests] -public partial class OpenReadTests +public class OpenReadTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task OpenRead_MissingFile_ShouldThrowFileNotFoundException(string path) { void Act() @@ -19,8 +19,8 @@ await That(Act).Throws() .WithHResult(-2147024894); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task OpenRead_SetLength_ShouldThrowNotSupportedException(string path) { FileSystem.File.WriteAllText(path, null); @@ -34,8 +34,8 @@ void Act() await That(Act).Throws().WithHResult(-2146233067); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task OpenRead_ShouldUseReadAccessAndReadShare(string path) { FileSystem.File.WriteAllText(path, null); @@ -51,8 +51,8 @@ await That(FileTestHelper.CheckFileShare(FileSystem, path)).IsEqualTo( await That(stream.CanTimeout).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task OpenRead_Write_ShouldThrowNotSupportedException(string path, byte[] bytes) { FileSystem.File.WriteAllText(path, null); @@ -66,8 +66,8 @@ void Act() await That(Act).Throws().WithHResult(-2146233067); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task OpenRead_WriteAsync_ShouldThrowNotSupportedException( string path, byte[] bytes) { @@ -79,7 +79,7 @@ async Task Act() // ReSharper disable once UseAwaitUsing using FileSystemStream stream = FileSystem.File.OpenRead(path); #pragma warning disable CA1835 // Prefer the 'Memory'-based overloads for 'ReadAsync' and 'WriteAsync' - await stream.WriteAsync(bytes, 0, bytes.Length, TestContext.Current.CancellationToken); + await stream.WriteAsync(bytes, 0, bytes.Length, CancellationToken); #pragma warning restore CA1835 } @@ -87,25 +87,25 @@ async Task Act() } #if FEATURE_SPAN - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task OpenRead_WriteAsyncWithMemory_ShouldThrowNotSupportedException( string path, byte[] bytes) { - await FileSystem.File.WriteAllTextAsync(path, "", TestContext.Current.CancellationToken); + await FileSystem.File.WriteAllTextAsync(path, "", CancellationToken); async Task Act() { using FileSystemStream stream = FileSystem.File.OpenRead(path); - await stream.WriteAsync(bytes.AsMemory(), TestContext.Current.CancellationToken); + await stream.WriteAsync(bytes.AsMemory(), CancellationToken); } await That(Act).Throws().WithHResult(-2146233067); } #endif - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task OpenRead_WriteByte_ShouldThrowNotSupportedException(string path) { FileSystem.File.WriteAllText(path, null); @@ -120,8 +120,8 @@ void Act() } #if FEATURE_SPAN - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task OpenRead_WriteWithSpan_ShouldThrowNotSupportedException(string path, byte[] bytes) { FileSystem.File.WriteAllText(path, null); diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/File/OpenTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/File/OpenTests.cs index 890cf0b85..1fbe3e241 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/File/OpenTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/File/OpenTests.cs @@ -3,10 +3,10 @@ namespace Testably.Abstractions.Tests.FileSystem.File; [FileSystemTests] -public partial class OpenTests +public class OpenTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Open_ExistingFileWithCreateNewMode_ShouldThrowIOException( string path) { @@ -22,8 +22,8 @@ await That(Act).Throws() .WithHResult(Test.RunsOnWindows ? -2147024816 : 17); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Open_MissingFileAndIncorrectMode_ShouldThrowFileNotFoundException( string path) { @@ -37,9 +37,9 @@ await That(Act).Throws() .WithHResult(-2147024894); } - [Theory] - [InlineAutoData(FileMode.Open, FileAccess.Read)] - [InlineAutoData(FileMode.OpenOrCreate, FileAccess.ReadWrite)] + [Test] + [AutoArguments(FileMode.Open, FileAccess.Read)] + [AutoArguments(FileMode.OpenOrCreate, FileAccess.ReadWrite)] public async Task Open_ShouldNotAdjustTimes(FileMode mode, FileAccess access, string path) { SkipIfLongRunningTestsShouldBeSkipped(); @@ -64,10 +64,10 @@ await That(lastWriteTime).IsBetween(creationTimeStart).And(creationTimeEnd) .Within(TimeComparison.Tolerance); } - [Theory] - [InlineAutoData(FileMode.Append, FileAccess.Write)] - [InlineAutoData(FileMode.Open, FileAccess.ReadWrite)] - [InlineAutoData(FileMode.Create, FileAccess.ReadWrite)] + [Test] + [AutoArguments(FileMode.Append, FileAccess.Write)] + [AutoArguments(FileMode.Open, FileAccess.ReadWrite)] + [AutoArguments(FileMode.Create, FileAccess.ReadWrite)] public async Task Open_ShouldUseExpectedAccessDependingOnMode( FileMode mode, FileAccess expectedAccess, @@ -81,9 +81,9 @@ public async Task Open_ShouldUseExpectedAccessDependingOnMode( await That(FileTestHelper.CheckFileShare(FileSystem, path)).IsEqualTo(FileShare.None); } - [Theory] - [InlineAutoData(FileAccess.Read, FileShare.Write)] - [InlineAutoData(FileAccess.Write, FileShare.Read)] + [Test] + [AutoArguments(FileAccess.Read, FileShare.Write)] + [AutoArguments(FileAccess.Write, FileShare.Read)] public async Task Open_ShouldUseGivenAccessAndShare(string path, FileAccess access, FileShare share) @@ -97,8 +97,8 @@ public async Task Open_ShouldUseGivenAccessAndShare(string path, await That(FileTestHelper.CheckFileShare(FileSystem, path)).IsEqualTo(share); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Open_ShouldUseNoneShareAsDefault(string path, FileAccess access) { @@ -111,9 +111,9 @@ public async Task Open_ShouldUseNoneShareAsDefault(string path, } #if FEATURE_FILESYSTEM_STREAM_OPTIONS - [Theory] - [InlineAutoData(FileAccess.Read, FileShare.Write)] - [InlineAutoData(FileAccess.Write, FileShare.Read)] + [Test] + [AutoArguments(FileAccess.Read, FileShare.Write)] + [AutoArguments(FileAccess.Write, FileShare.Read)] public async Task Open_WithFileStreamOptions_ShouldUseGivenAccessAndShare( string path, FileAccess access, diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/File/OpenTextTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/File/OpenTextTests.cs index 6441adb17..4a373ed5e 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/File/OpenTextTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/File/OpenTextTests.cs @@ -3,10 +3,10 @@ namespace Testably.Abstractions.Tests.FileSystem.File; [FileSystemTests] -public partial class OpenTextTests +public class OpenTextTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task OpenText_MissingFile_ShouldThrowFileNotFoundException( string path) { @@ -20,8 +20,8 @@ await That(Act).Throws() .WithHResult(-2147024894); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task OpenText_ShouldReturnFileContent( string path, string contents) { diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/File/OpenWriteTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/File/OpenWriteTests.cs index c1c190eab..e37222d24 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/File/OpenWriteTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/File/OpenWriteTests.cs @@ -3,10 +3,10 @@ namespace Testably.Abstractions.Tests.FileSystem.File; [FileSystemTests] -public partial class OpenWriteTests +public class OpenWriteTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task OpenWrite_MissingFile_ShouldCreateFile(string path) { using FileSystemStream stream = FileSystem.File.OpenWrite(path); @@ -14,8 +14,8 @@ public async Task OpenWrite_MissingFile_ShouldCreateFile(string path) await That(FileSystem.File.Exists(path)).IsTrue(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task OpenWrite_ShouldOverwriteExistingFile(string path, string previousContent) { FileSystem.File.WriteAllText(path, previousContent); @@ -32,8 +32,8 @@ public async Task OpenWrite_ShouldOverwriteExistingFile(string path, string prev await That(result.Length).IsEqualTo(previousContent.Length); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task OpenWrite_ShouldUseWriteAccessAndNoneShare(string path) { FileSystem.File.WriteAllText(path, null); @@ -48,8 +48,8 @@ public async Task OpenWrite_ShouldUseWriteAccessAndNoneShare(string path) await That(stream.CanTimeout).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task OpenWrite_StreamShouldNotThrowExceptionWhenReading(string path) { FileSystem.File.WriteAllText(path, null); diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/File/ReadAllBytesAsyncTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/File/ReadAllBytesAsyncTests.cs index 005ce4df5..bfd357d18 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/File/ReadAllBytesAsyncTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/File/ReadAllBytesAsyncTests.cs @@ -1,5 +1,4 @@ #if FEATURE_FILESYSTEM_ASYNC -using NSubstitute.ExceptionExtensions; using System.IO; using System.Threading; using System.Threading.Tasks; @@ -7,10 +6,10 @@ namespace Testably.Abstractions.Tests.FileSystem.File; [FileSystemTests] -public partial class ReadAllBytesAsyncTests +public class ReadAllBytesAsyncTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ReadAllBytesAsync_Cancelled_ShouldThrowTaskCanceledException( string path) { @@ -23,28 +22,28 @@ async Task Act() => await That(Act).Throws().WithHResult(-2146233029); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ReadAllBytesAsync_MissingFile_ShouldThrowFileNotFoundException( string path) { async Task Act() => - await FileSystem.File.ReadAllBytesAsync(path, TestContext.Current.CancellationToken); + await FileSystem.File.ReadAllBytesAsync(path, CancellationToken); await That(Act).Throws() .WithMessageContaining($"'{FileSystem.Path.GetFullPath(path)}'").And .WithHResult(-2147024894); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ReadAllBytesAsync_ShouldReturnWrittenBytes( byte[] bytes, string path) { - await FileSystem.File.WriteAllBytesAsync(path, bytes, TestContext.Current.CancellationToken); + await FileSystem.File.WriteAllBytesAsync(path, bytes, CancellationToken); byte[] result = - await FileSystem.File.ReadAllBytesAsync(path, TestContext.Current.CancellationToken); + await FileSystem.File.ReadAllBytesAsync(path, CancellationToken); await That(result).IsEqualTo(bytes).InAnyOrder(); } diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/File/ReadAllBytesTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/File/ReadAllBytesTests.cs index 7bc8f3b32..2319c94e4 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/File/ReadAllBytesTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/File/ReadAllBytesTests.cs @@ -4,10 +4,10 @@ namespace Testably.Abstractions.Tests.FileSystem.File; [FileSystemTests] -public partial class ReadAllBytesTests +public class ReadAllBytesTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ReadAllBytes_MissingFile_ShouldThrowFileNotFoundException(string path) { void Act() @@ -20,8 +20,8 @@ await That(Act).ThrowsExactly() .WithMessage($"*'{FileSystem.Path.GetFullPath(path)}'*").AsWildcard(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ReadAllBytes_ShouldAdjustTimes(string path, byte[] bytes) { Skip.If(Test.IsNetFramework && FileSystem is RealFileSystem, @@ -56,8 +56,8 @@ await That(lastWriteTime).IsBetween(creationTimeStart).And(creationTimeEnd) .Within(TimeComparison.Tolerance); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ReadAllBytes_ShouldNotGetAReferenceToFileContent( string path, byte[] bytes) { @@ -71,8 +71,8 @@ public async Task ReadAllBytes_ShouldNotGetAReferenceToFileContent( await That(result).IsEqualTo(bytes).InAnyOrder(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ReadAllBytes_ShouldReturnWrittenBytes( byte[] bytes, string path) { @@ -83,8 +83,8 @@ public async Task ReadAllBytes_ShouldReturnWrittenBytes( await That(result).IsEqualTo(bytes).InAnyOrder(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ReadAllBytes_ShouldTolerateAltDirectorySeparatorChar( byte[] bytes, string directory, string fileName) { diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/File/ReadAllLinesAsyncTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/File/ReadAllLinesAsyncTests.cs index 760cd570c..2f2237bee 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/File/ReadAllLinesAsyncTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/File/ReadAllLinesAsyncTests.cs @@ -1,6 +1,5 @@ #if FEATURE_FILESYSTEM_ASYNC using AutoFixture; -using NSubstitute.ExceptionExtensions; using System.IO; using System.Text; using System.Threading; @@ -9,10 +8,10 @@ namespace Testably.Abstractions.Tests.FileSystem.File; [FileSystemTests] -public partial class ReadAllLinesAsyncTests +public class ReadAllLinesAsyncTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ReadAllLinesAsync_Cancelled_ShouldThrowTaskCanceledException( string path) { @@ -25,8 +24,8 @@ async Task Act() => await That(Act).Throws().WithHResult(-2146233029); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ReadAllLinesAsync_Cancelled_WithEncoding_ShouldThrowTaskCanceledException( string path) @@ -40,34 +39,34 @@ async Task Act() => await That(Act).Throws().WithHResult(-2146233029); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ReadAllLinesAsync_MissingFile_ShouldThrowFileNotFoundException( string path) { async Task Act() => - await FileSystem.File.ReadAllLinesAsync(path, TestContext.Current.CancellationToken); + await FileSystem.File.ReadAllLinesAsync(path, CancellationToken); await That(Act).Throws() .WithMessageContaining($"'{FileSystem.Path.GetFullPath(path)}'").And .WithHResult(-2147024894); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ReadAllLinesAsync_ShouldEnumerateLines(string path, string[] lines) { string contents = string.Join(Environment.NewLine, lines); - await FileSystem.File.WriteAllTextAsync(path, contents, TestContext.Current.CancellationToken); + await FileSystem.File.WriteAllTextAsync(path, contents, CancellationToken); string[] results = - await FileSystem.File.ReadAllLinesAsync(path, TestContext.Current.CancellationToken); + await FileSystem.File.ReadAllLinesAsync(path, CancellationToken); await That(results).IsEqualTo(lines); } - [Theory] - [ClassData(typeof(TestDataGetEncodingDifference))] + [Test] + [MethodDataSource(typeof(TestData), nameof(TestData.GetEncodingDifference))] public async Task ReadAllLinesAsync_WithDifferentEncoding_ShouldNotReturnWrittenText( string specialLine, Encoding writeEncoding, Encoding readEncoding) { @@ -75,10 +74,10 @@ public async Task ReadAllLinesAsync_WithDifferentEncoding_ShouldNotReturnWritten string[] lines = new Fixture().Create(); lines[1] = specialLine; string contents = string.Join(Environment.NewLine, lines); - await FileSystem.File.WriteAllTextAsync(path, contents, writeEncoding, TestContext.Current.CancellationToken); + await FileSystem.File.WriteAllTextAsync(path, contents, writeEncoding, CancellationToken); string[] result = - await FileSystem.File.ReadAllLinesAsync(path, readEncoding, TestContext.Current.CancellationToken); + await FileSystem.File.ReadAllLinesAsync(path, readEncoding, CancellationToken); await That(result).IsNotEqualTo(lines).InAnyOrder(); await That(result[0]).IsEqualTo(lines[0]); diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/File/ReadAllLinesTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/File/ReadAllLinesTests.cs index 3baa9e442..546cf2f6e 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/File/ReadAllLinesTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/File/ReadAllLinesTests.cs @@ -5,10 +5,10 @@ namespace Testably.Abstractions.Tests.FileSystem.File; [FileSystemTests] -public partial class ReadAllLinesTests +public class ReadAllLinesTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ReadAllLines_Empty_ShouldReturnEmptyArray(string path) { FileSystem.File.WriteAllText(path, ""); @@ -18,8 +18,8 @@ public async Task ReadAllLines_Empty_ShouldReturnEmptyArray(string path) await That(results).IsEmpty(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ReadAllLines_MissingFile_ShouldThrowFileNotFoundException(string path) { void Act() @@ -32,8 +32,8 @@ await That(Act).Throws() .WithHResult(-2147024894); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ReadAllLines_ShouldEnumerateLines(string path, string[] lines) { string contents = string.Join(Environment.NewLine, lines); @@ -44,8 +44,8 @@ public async Task ReadAllLines_ShouldEnumerateLines(string path, string[] lines) await That(results).IsEqualTo(lines); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ReadAllLines_ShouldNotReturnByteOrderMark(string path, string content) { FileSystem.File.WriteAllLines(path, [content], Encoding.UTF32); @@ -58,8 +58,8 @@ public async Task ReadAllLines_ShouldNotReturnByteOrderMark(string path, string await That(result[0]).IsEqualTo(content); } - [Theory] - [ClassData(typeof(TestDataGetEncodingDifference))] + [Test] + [MethodDataSource(typeof(TestData), nameof(TestData.GetEncodingDifference))] public async Task ReadAllLines_WithDifferentEncoding_ShouldNotReturnWrittenText( string specialLine, Encoding writeEncoding, Encoding readEncoding) { diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/File/ReadAllTextAsyncTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/File/ReadAllTextAsyncTests.cs index c01114758..bb227217b 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/File/ReadAllTextAsyncTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/File/ReadAllTextAsyncTests.cs @@ -1,6 +1,5 @@ #if FEATURE_FILESYSTEM_ASYNC using AutoFixture; -using NSubstitute.ExceptionExtensions; using System.IO; using System.Text; using System.Threading; @@ -8,10 +7,10 @@ namespace Testably.Abstractions.Tests.FileSystem.File; [FileSystemTests] -public partial class ReadAllTextAsyncTests +public class ReadAllTextAsyncTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ReadAllTextAsync_Cancelled_ShouldThrowTaskCanceledException( string path) { @@ -24,8 +23,8 @@ async Task Act() => await That(Act).Throws().WithHResult(-2146233029); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ReadAllTextAsync_Cancelled_WithEncoding_ShouldThrowTaskCanceledException( string path) @@ -39,29 +38,29 @@ async Task Act () => await That(Act).Throws().WithHResult(-2146233029); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ReadAllTextAsync_MissingFile_ShouldThrowFileNotFoundException( string path) { async Task Act() => - await FileSystem.File.ReadAllTextAsync(path, TestContext.Current.CancellationToken); + await FileSystem.File.ReadAllTextAsync(path, CancellationToken); await That(Act).Throws() .WithMessageContaining($"'{FileSystem.Path.GetFullPath(path)}'").And .WithHResult(-2147024894); } - [Theory] - [ClassData(typeof(TestDataGetEncodingDifference))] + [Test] + [MethodDataSource(typeof(TestData), nameof(TestData.GetEncodingDifference))] public async Task ReadAllTextAsync_WithDifferentEncoding_ShouldNotReturnWrittenText( string contents, Encoding writeEncoding, Encoding readEncoding) { string path = new Fixture().Create(); - await FileSystem.File.WriteAllTextAsync(path, contents, writeEncoding, TestContext.Current.CancellationToken); + await FileSystem.File.WriteAllTextAsync(path, contents, writeEncoding, CancellationToken); string result = - await FileSystem.File.ReadAllTextAsync(path, readEncoding, TestContext.Current.CancellationToken); + await FileSystem.File.ReadAllTextAsync(path, readEncoding, CancellationToken); await That(result).IsNotEqualTo(contents).Because($"{contents} should be different when encoding from {writeEncoding} to {readEncoding}."); } diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/File/ReadAllTextTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/File/ReadAllTextTests.cs index 93d23ffe2..fd630f03a 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/File/ReadAllTextTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/File/ReadAllTextTests.cs @@ -5,10 +5,10 @@ namespace Testably.Abstractions.Tests.FileSystem.File; [FileSystemTests] -public partial class ReadAllTextTests +public class ReadAllTextTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ReadAllText_FilenameNotOnWindows_ShouldBeCaseSensitive( string path, string contents1, string contents2) { @@ -23,8 +23,8 @@ public async Task ReadAllText_FilenameNotOnWindows_ShouldBeCaseSensitive( await That(result).IsEqualTo(contents2); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ReadAllText_FilenameOnWindows_ShouldBeCaseInsensitive( string path, string contents) { @@ -38,8 +38,8 @@ public async Task ReadAllText_FilenameOnWindows_ShouldBeCaseInsensitive( await That(result).IsEqualTo(contents); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ReadAllText_MissingFile_ShouldThrowFileNotFoundException(string path) { void Act() @@ -52,8 +52,8 @@ await That(Act).ThrowsExactly() .WithMessage($"*'{FileSystem.Path.GetFullPath(path)}'*").AsWildcard(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ReadAllText_ShouldAdjustTimes(string path, string contents) { Skip.If(Test.IsNetFramework && FileSystem is RealFileSystem, @@ -88,8 +88,8 @@ await That(lastWriteTime).IsBetween(creationTimeStart).And(creationTimeEnd) .Within(TimeComparison.Tolerance); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ReadAllText_ShouldTolerateAltDirectorySeparatorChar( string contents, string directory, string fileName) { @@ -103,8 +103,8 @@ public async Task ReadAllText_ShouldTolerateAltDirectorySeparatorChar( await That(result).IsEqualTo(contents); } - [Theory] - [ClassData(typeof(TestDataGetEncodingDifference))] + [Test] + [MethodDataSource(typeof(TestData), nameof(TestData.GetEncodingDifference))] public async Task ReadAllText_WithDifferentEncoding_ShouldNotReturnWrittenText( string contents, Encoding writeEncoding, Encoding readEncoding) { @@ -117,8 +117,8 @@ await That(result).IsNotEqualTo(contents).Because( $"{contents} should be different when encoding from {writeEncoding} to {readEncoding}."); } - [Theory] - [MemberData(nameof(GetEncodingsForReadAllText))] + [Test] + [MethodDataSource(typeof(TestData), nameof(TestData.GetEncodingsForReadAllText))] public async Task ReadAllText_WithoutReadEncoding_ShouldReturnWrittenText( Encoding writeEncoding) { @@ -133,8 +133,8 @@ await That(result).IsEqualTo(contents) $"{contents} should not be different when no read encoding is used for write encoding: {writeEncoding}."); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ReadAllText_WithStarCharacter_ShouldThrowException( string path, string contents) { @@ -147,20 +147,4 @@ void Act() await That(Act).ThrowsException(); } - - #region Helpers - - #pragma warning disable MA0018 - public static TheoryData GetEncodingsForReadAllText() - => new() - { - (Encoding)new UTF32Encoding(false, true, true), - // big endian - (Encoding)new UTF32Encoding(true, true, true), - (Encoding)new UTF8Encoding(true, true), - (Encoding)new ASCIIEncoding(), - }; - #pragma warning restore MA0018 - - #endregion } diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/File/ReadLinesAsyncTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/File/ReadLinesAsyncTests.cs index a23b37557..d9dbac1ee 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/File/ReadLinesAsyncTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/File/ReadLinesAsyncTests.cs @@ -1,6 +1,5 @@ #if FEATURE_FILESYSTEM_NET_7_OR_GREATER using AutoFixture; -using NSubstitute.ExceptionExtensions; using System.Collections.Generic; using System.IO; using System.Text; @@ -10,14 +9,14 @@ namespace Testably.Abstractions.Tests.FileSystem.File; [FileSystemTests] -public partial class ReadLinesAsyncTests +public class ReadLinesAsyncTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ReadLinesAsync_Cancelled_ShouldThrowTaskCanceledException( string path) { - await FileSystem.File.WriteAllTextAsync(path, "some content", TestContext.Current.CancellationToken); + await FileSystem.File.WriteAllTextAsync(path, "some content", CancellationToken); using CancellationTokenSource cts = new(); await cts.CancelAsync(); @@ -32,13 +31,13 @@ async Task Act() await That(Act).Throws().WithHResult(-2146233029); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ReadLinesAsync_Cancelled_WithEncoding_ShouldThrowTaskCanceledException( string path) { - await FileSystem.File.WriteAllTextAsync(path, "some content", TestContext.Current.CancellationToken); + await FileSystem.File.WriteAllTextAsync(path, "some content", CancellationToken); using CancellationTokenSource cts = new(); await cts.CancelAsync(); @@ -54,14 +53,14 @@ async Task Act() await That(Act).Throws().WithHResult(-2146233029); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ReadLinesAsync_MissingFile_ShouldThrowFileNotFoundException( string path) { async Task Act() { - await foreach (string _ in FileSystem.File.ReadLinesAsync(path, TestContext.Current.CancellationToken)) + await foreach (string _ in FileSystem.File.ReadLinesAsync(path, CancellationToken)) { // do nothing } @@ -72,15 +71,15 @@ await That(Act).Throws() .WithHResult(-2147024894); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ReadLinesAsync_ShouldEnumerateLines(string path, string[] lines) { string contents = string.Join(Environment.NewLine, lines); - await FileSystem.File.WriteAllTextAsync(path, contents, TestContext.Current.CancellationToken); + await FileSystem.File.WriteAllTextAsync(path, contents, CancellationToken); List results = []; - await foreach (string line in FileSystem.File.ReadLinesAsync(path, TestContext.Current.CancellationToken)) + await foreach (string line in FileSystem.File.ReadLinesAsync(path, CancellationToken)) { results.Add(line); } @@ -88,8 +87,8 @@ public async Task ReadLinesAsync_ShouldEnumerateLines(string path, string[] line await That(results).IsEqualTo(lines); } - [Theory] - [ClassData(typeof(TestDataGetEncodingDifference))] + [Test] + [MethodDataSource(typeof(TestData), nameof(TestData.GetEncodingDifference))] public async Task ReadLinesAsync_WithDifferentEncoding_ShouldNotReturnWrittenText( string specialLine, Encoding writeEncoding, Encoding readEncoding) { @@ -97,10 +96,10 @@ public async Task ReadLinesAsync_WithDifferentEncoding_ShouldNotReturnWrittenTex string[] lines = new Fixture().Create(); lines[1] = specialLine; string contents = string.Join(Environment.NewLine, lines); - await FileSystem.File.WriteAllTextAsync(path, contents, writeEncoding, TestContext.Current.CancellationToken); + await FileSystem.File.WriteAllTextAsync(path, contents, writeEncoding, CancellationToken); List results = []; - await foreach (string line in FileSystem.File.ReadLinesAsync(path, readEncoding, TestContext.Current.CancellationToken)) + await foreach (string line in FileSystem.File.ReadLinesAsync(path, readEncoding, CancellationToken)) { results.Add(line); } diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/File/ReadLinesTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/File/ReadLinesTests.cs index 80963380c..106aabf03 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/File/ReadLinesTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/File/ReadLinesTests.cs @@ -6,10 +6,10 @@ namespace Testably.Abstractions.Tests.FileSystem.File; [FileSystemTests] -public partial class ReadLinesTests +public class ReadLinesTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ReadLines_EmptyFile_ShouldEnumerateLines(string path) { FileSystem.File.WriteAllText(path, null); @@ -19,8 +19,8 @@ public async Task ReadLines_EmptyFile_ShouldEnumerateLines(string path) await That(results).IsEmpty(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ReadLines_MissingFile_ShouldThrowFileNotFoundException(string path) { void Act() @@ -33,8 +33,8 @@ await That(Act).Throws() .WithHResult(-2147024894); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ReadLines_ShouldEnumerateLines(string path, string[] lines) { string contents = string.Join(Environment.NewLine, lines); @@ -45,8 +45,8 @@ public async Task ReadLines_ShouldEnumerateLines(string path, string[] lines) await That(results).IsEqualTo(lines).InAnyOrder(); } - [Theory] - [ClassData(typeof(TestDataGetEncodingDifference))] + [Test] + [MethodDataSource(typeof(TestData), nameof(TestData.GetEncodingDifference))] public async Task ReadLines_WithDifferentEncoding_ShouldNotReturnWrittenText( string specialLine, Encoding writeEncoding, Encoding readEncoding) { diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/File/ReplaceTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/File/ReplaceTests.cs index 771232f34..c92c26a98 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/File/ReplaceTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/File/ReplaceTests.cs @@ -4,10 +4,10 @@ namespace Testably.Abstractions.Tests.FileSystem.File; [FileSystemTests] -public partial class ReplaceTests +public class ReplaceTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Replace_CaseOnlyChange_ShouldThrowIOException( string name, string contents) { @@ -43,8 +43,8 @@ await That(Act).Throws() } } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Replace_DestinationDirectoryDoesNotExist_ShouldThrowCorrectException( string source) { @@ -67,8 +67,8 @@ void Act() } } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Replace_DestinationIsDirectory_ShouldThrowUnauthorizedAccessException( string sourceName, string destinationName, @@ -85,8 +85,8 @@ void Act() await That(Act).Throws().WithHResult(-2147024891); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Replace_DestinationMissing_ShouldThrowFileNotFoundException( string sourceName, string destinationName, @@ -103,8 +103,8 @@ void Act() await That(FileSystem.File.Exists(backupName)).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Replace_ReadOnly_WithIgnoreMetadataError_ShouldReplaceFile( string sourceName, string destinationName, @@ -126,8 +126,8 @@ public async Task Replace_ReadOnly_WithIgnoreMetadataError_ShouldReplaceFile( await That(FileSystem.File.ReadAllText(backupName)).IsEquivalentTo(destinationContents); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Replace_ReadOnly_WithoutIgnoreMetadataError_ShouldThrowUnauthorizedAccessException_OnWindows( string sourceName, @@ -168,8 +168,8 @@ await That(FileSystem.File.GetAttributes(destinationName)) } } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Replace_ShouldReplaceFile( string sourceName, string destinationName, @@ -189,8 +189,8 @@ public async Task Replace_ShouldReplaceFile( await That(FileSystem.File.ReadAllText(backupName)).IsEquivalentTo(destinationContents); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Replace_Twice_ShouldReplaceFile( string sourceName, string destinationName) @@ -209,8 +209,8 @@ public async Task Replace_Twice_ShouldReplaceFile( await That(file1).HasContent("def"); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Replace_SourceIsDirectory_ShouldThrowUnauthorizedAccessException( string sourceName, string destinationName, @@ -229,19 +229,19 @@ void Act() await That(Act).Throws().WithHResult(-2147024891); } - [Theory] - [InlineAutoData(FileAccess.Read, FileShare.None)] - [InlineAutoData(FileAccess.Read, FileShare.Read)] - [InlineAutoData(FileAccess.Read, FileShare.ReadWrite)] - [InlineAutoData(FileAccess.Read, FileShare.Write)] - [InlineAutoData(FileAccess.ReadWrite, FileShare.None)] - [InlineAutoData(FileAccess.ReadWrite, FileShare.Read)] - [InlineAutoData(FileAccess.ReadWrite, FileShare.ReadWrite)] - [InlineAutoData(FileAccess.ReadWrite, FileShare.Write)] - [InlineAutoData(FileAccess.Write, FileShare.None)] - [InlineAutoData(FileAccess.Write, FileShare.Read)] - [InlineAutoData(FileAccess.Write, FileShare.ReadWrite)] - [InlineAutoData(FileAccess.Write, FileShare.Write)] + [Test] + [AutoArguments(FileAccess.Read, FileShare.None)] + [AutoArguments(FileAccess.Read, FileShare.Read)] + [AutoArguments(FileAccess.Read, FileShare.ReadWrite)] + [AutoArguments(FileAccess.Read, FileShare.Write)] + [AutoArguments(FileAccess.ReadWrite, FileShare.None)] + [AutoArguments(FileAccess.ReadWrite, FileShare.Read)] + [AutoArguments(FileAccess.ReadWrite, FileShare.ReadWrite)] + [AutoArguments(FileAccess.ReadWrite, FileShare.Write)] + [AutoArguments(FileAccess.Write, FileShare.None)] + [AutoArguments(FileAccess.Write, FileShare.Read)] + [AutoArguments(FileAccess.Write, FileShare.ReadWrite)] + [AutoArguments(FileAccess.Write, FileShare.Write)] public async Task Replace_SourceLocked_ShouldThrowIOException_OnWindows( FileAccess fileAccess, FileShare fileShare, @@ -287,8 +287,8 @@ await That(FileSystem.File.GetAttributes(destinationName)) } } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Replace_SourceMissing_ShouldThrowFileNotFoundException( string sourceName, string destinationName, @@ -309,8 +309,8 @@ void Act() } } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Replace_WithExistingBackupFile_ShouldIgnoreBackup( string sourceName, string destinationName, @@ -332,8 +332,8 @@ public async Task Replace_WithExistingBackupFile_ShouldIgnoreBackup( await That(FileSystem.File.ReadAllText(backupName)).IsEquivalentTo(backupContents); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Replace_WithoutBackup_ShouldReplaceFile( string sourceName, string destinationName, diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/File/ResolveLinkTargetTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/File/ResolveLinkTargetTests.cs index f3771f6d7..be22aa2ff 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/File/ResolveLinkTargetTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/File/ResolveLinkTargetTests.cs @@ -5,7 +5,7 @@ namespace Testably.Abstractions.Tests.FileSystem.File; [FileSystemTests] -public partial class ResolveLinkTargetTests +public class ResolveLinkTargetTests(FileSystemTestData testData) : FileSystemTestBase(testData) { #region Test Setup @@ -18,8 +18,8 @@ public partial class ResolveLinkTargetTests #endregion - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ResolveLinkTarget_AbsolutePath_ShouldFollowSymbolicLink( string path, string pathToTarget) { @@ -34,8 +34,8 @@ public async Task ResolveLinkTarget_AbsolutePath_ShouldFollowSymbolicLink( await That(target.Exists).IsTrue(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ResolveLinkTarget_FileWithDifferentCase_ShouldReturnPathToMissingFile( string path, string pathToTarget, string contents) { @@ -61,8 +61,8 @@ public async Task ResolveLinkTarget_FileWithDifferentCase_ShouldReturnPathToMiss } } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ResolveLinkTarget_FinalTarget_MultipleSteps_ShouldFollowSymbolicLinkToFinalTarget( string path, string pathToFinalTarget) { @@ -85,8 +85,8 @@ public async Task ResolveLinkTarget_FinalTarget_MultipleSteps_ShouldFollowSymbol await That(target!.FullName).IsEqualTo(FileSystem.Path.GetFullPath(pathToFinalTarget)); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ResolveLinkTarget_FinalTarget_ShouldFollowSymbolicLinkToFinalTarget( string path, string pathToFinalTarget) { @@ -108,8 +108,8 @@ public async Task ResolveLinkTarget_FinalTarget_ShouldFollowSymbolicLinkToFinalT await That(target!.FullName).IsEqualTo(FileSystem.Path.GetFullPath(pathToFinalTarget)); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ResolveLinkTarget_FinalTargetWithTooManyLevels_ShouldThrowIOException( string path, string pathToFinalTarget) { @@ -134,8 +134,8 @@ await That(Act).Throws() .WithHResult(Test.RunsOnWindows ? -2147022975 : -2146232800); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ResolveLinkTarget_MissingFileAtBeginningOfLinkChain_ShouldReturnPathToMissingFile( string path, string pathToFinalTarget, string pathToMissingFile) { @@ -152,8 +152,8 @@ public async Task ResolveLinkTarget_MissingFileAtBeginningOfLinkChain_ShouldRetu await That(target!.FullName).IsEqualTo(FileSystem.Path.GetFullPath(pathToMissingFile)); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ResolveLinkTarget_MissingFileInLinkChain_ShouldReturnPathToMissingFile( string path, string pathToIntermediateTarget, @@ -175,8 +175,8 @@ public async Task ResolveLinkTarget_MissingFileInLinkChain_ShouldReturnPathToMis await That(target!.FullName).IsEqualTo(FileSystem.Path.GetFullPath(pathToMissingFile)); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ResolveLinkTarget_NormalDirectory_ShouldReturnNull( string path) { @@ -188,8 +188,8 @@ public async Task ResolveLinkTarget_NormalDirectory_ShouldReturnNull( await That(target).IsNull(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ResolveLinkTarget_NormalFile_ShouldReturnNull( string path) { @@ -201,8 +201,8 @@ public async Task ResolveLinkTarget_NormalFile_ShouldReturnNull( await That(target).IsNull(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ResolveLinkTarget_RelativePath_ShouldFollowSymbolicLinkUnderWindows( string path, string pathToTarget) { @@ -217,8 +217,8 @@ public async Task ResolveLinkTarget_RelativePath_ShouldFollowSymbolicLinkUnderWi await That(target.Exists).IsTrue(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ResolveLinkTarget_TargetDeletedAfterLinkCreation_ShouldReturnNull( string path, string pathToTarget) { diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/File/SetAttributesTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/File/SetAttributesTests.cs index 2fa9fde03..35b7c1708 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/File/SetAttributesTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/File/SetAttributesTests.cs @@ -3,10 +3,10 @@ namespace Testably.Abstractions.Tests.FileSystem.File; [FileSystemTests] -public partial class SetAttributesTests +public class SetAttributesTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task SetAttributes_Directory_ShouldRemainFile(string path) { FileSystem.File.WriteAllText(path, null); @@ -17,9 +17,9 @@ public async Task SetAttributes_Directory_ShouldRemainFile(string path) await That(FileSystem.File.Exists(path)).IsTrue(); } - [Theory] - [InlineAutoData(FileAttributes.ReadOnly)] - [InlineAutoData(FileAttributes.Normal)] + [Test] + [AutoArguments(FileAttributes.ReadOnly)] + [AutoArguments(FileAttributes.Normal)] public async Task SetAttributes_ShouldNotAdjustTimes(FileAttributes attributes, string path) { SkipIfLongRunningTestsShouldBeSkipped(); diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/File/TestDataGetEncodingDifference.cs b/Tests/Testably.Abstractions.Tests/FileSystem/File/TestDataGetEncodingDifference.cs deleted file mode 100644 index 5e52df37b..000000000 --- a/Tests/Testably.Abstractions.Tests/FileSystem/File/TestDataGetEncodingDifference.cs +++ /dev/null @@ -1,24 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using System.Text; - -namespace Testably.Abstractions.Tests.FileSystem.File; - -public class TestDataGetEncodingDifference : IEnumerable> -{ - private const string SpecialCharactersContent = "_€_Ä_Ö_Ü"; - - #region IEnumerable> Members - - public IEnumerator> GetEnumerator() - { - yield return new TheoryDataRow(SpecialCharactersContent, - Encoding.ASCII, Encoding.UTF8); - } - - /// - IEnumerator IEnumerable.GetEnumerator() - => GetEnumerator(); - - #endregion -} diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/File/Tests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/File/Tests.cs index 3ffae7c2d..fe8304aba 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/File/Tests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/File/Tests.cs @@ -1,10 +1,10 @@ namespace Testably.Abstractions.Tests.FileSystem.File; [FileSystemTests] -public partial class Tests +public class Tests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetCreationTime_PathNotFound_ShouldReturnNullTime(string path) { DateTime expectedTime = FileTestHelper.NullTime.ToLocalTime(); @@ -14,8 +14,8 @@ public async Task GetCreationTime_PathNotFound_ShouldReturnNullTime(string path) await That(result).IsEqualTo(expectedTime); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetCreationTimeUtc_PathNotFound_ShouldReturnNullTime(string path) { DateTime expectedTime = FileTestHelper.NullTime.ToUniversalTime(); @@ -25,8 +25,8 @@ public async Task GetCreationTimeUtc_PathNotFound_ShouldReturnNullTime(string pa await That(result).IsEqualTo(expectedTime); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetLastAccessTime_PathNotFound_ShouldReturnNullTime(string path) { DateTime expectedTime = FileTestHelper.NullTime.ToLocalTime(); @@ -36,8 +36,8 @@ public async Task GetLastAccessTime_PathNotFound_ShouldReturnNullTime(string pat await That(result).IsEqualTo(expectedTime); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetLastAccessTimeUtc_PathNotFound_ShouldReturnNullTime(string path) { DateTime expectedTime = FileTestHelper.NullTime.ToUniversalTime(); @@ -47,8 +47,8 @@ public async Task GetLastAccessTimeUtc_PathNotFound_ShouldReturnNullTime(string await That(result).IsEqualTo(expectedTime); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetLastWriteTime_PathNotFound_ShouldReturnNullTime(string path) { DateTime expectedTime = FileTestHelper.NullTime.ToLocalTime(); @@ -58,8 +58,8 @@ public async Task GetLastWriteTime_PathNotFound_ShouldReturnNullTime(string path await That(result).IsEqualTo(expectedTime); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetLastWriteTimeUtc_PathNotFound_ShouldReturnNullTime(string path) { DateTime expectedTime = FileTestHelper.NullTime.ToUniversalTime(); @@ -69,8 +69,8 @@ public async Task GetLastWriteTimeUtc_PathNotFound_ShouldReturnNullTime(string p await That(result).IsEqualTo(expectedTime); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task LastAccessTime_ShouldBeSet(string path) { DateTime start = TimeSystem.DateTime.Now; @@ -83,8 +83,8 @@ await That(result).IsBetween(start).And(TimeSystem.DateTime.Now) await That(result.Kind).IsEqualTo(DateTimeKind.Local); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task LastAccessTimeUtc_ShouldBeSet(string path) { DateTime start = TimeSystem.DateTime.UtcNow; @@ -97,8 +97,8 @@ await That(result).IsBetween(start).And(TimeSystem.DateTime.UtcNow) await That(result.Kind).IsEqualTo(DateTimeKind.Utc); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task LastWriteTime_ShouldBeSet(string path) { DateTime start = TimeSystem.DateTime.Now; @@ -111,8 +111,8 @@ await That(result).IsBetween(start).And(TimeSystem.DateTime.Now) await That(result.Kind).IsEqualTo(DateTimeKind.Local); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task LastWriteTimeUtc_ShouldBeSet(string path) { DateTime start = TimeSystem.DateTime.UtcNow; @@ -125,8 +125,8 @@ await That(result).IsBetween(start).And(TimeSystem.DateTime.UtcNow) await That(result.Kind).IsEqualTo(DateTimeKind.Utc); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task SetCreationTime_ShouldChangeCreationTime( string path, DateTime creationTime) { @@ -142,8 +142,8 @@ public async Task SetCreationTime_ShouldChangeCreationTime( await That(FileSystem.File.GetCreationTimeUtc(path)).IsEqualTo(expectedTime); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task SetCreationTimeUtc_ShouldChangeCreationTime( string path, DateTime creationTime) { @@ -159,8 +159,8 @@ public async Task SetCreationTimeUtc_ShouldChangeCreationTime( await That(FileSystem.File.GetCreationTime(path)).IsEqualTo(expectedTime); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task SetLastAccessTime_ShouldChangeLastAccessTime( string path, DateTime lastAccessTime) { @@ -173,8 +173,8 @@ public async Task SetLastAccessTime_ShouldChangeLastAccessTime( await That(FileSystem.File.GetLastAccessTimeUtc(path)).IsEqualTo(expectedTime); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task SetLastAccessTimeUtc_ShouldChangeLastAccessTime( string path, DateTime lastAccessTime) { @@ -187,8 +187,8 @@ public async Task SetLastAccessTimeUtc_ShouldChangeLastAccessTime( await That(FileSystem.File.GetLastAccessTime(path)).IsEqualTo(expectedTime); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task SetLastWriteTime_ShouldChangeLastWriteTime( string path, DateTime lastWriteTime) { @@ -201,8 +201,8 @@ public async Task SetLastWriteTime_ShouldChangeLastWriteTime( await That(FileSystem.File.GetLastWriteTimeUtc(path)).IsEqualTo(expectedTime); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task SetLastWriteTimeUtc_ShouldChangeLastWriteTime( string path, DateTime lastWriteTime) { diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/File/UnixFileModeTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/File/UnixFileModeTests.cs index 66acc05c3..2f379cf6e 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/File/UnixFileModeTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/File/UnixFileModeTests.cs @@ -4,10 +4,10 @@ namespace Testably.Abstractions.Tests.FileSystem.File; [FileSystemTests] -public partial class UnixFileModeTests +public class UnixFileModeTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetUnixFileMode_ShouldBeInitializedCorrectly( string path) { @@ -26,8 +26,8 @@ public async Task GetUnixFileMode_ShouldBeInitializedCorrectly( await That(result).IsEqualTo(expected); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetUnixFileMode_ShouldThrowPlatformNotSupportedException_OnWindows( string path) { @@ -43,8 +43,8 @@ void Act() await That(Act).Throws().WithHResult(-2146233031); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ReadAllText_WhenUnixFileModeIsNone_ShouldThrowUnauthorizedAccessException( string path) { @@ -66,8 +66,8 @@ await That(Act).Throws() .WithMessage($"Access to the path '*/{path}' is denied.").AsWildcard(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task SetUnixFileMode_MissingFile_ShouldThrowFileNotFoundException( string path, UnixFileMode unixFileMode) { @@ -83,8 +83,8 @@ void Act() await That(Act).Throws().WithHResult(-2147024894); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task SetUnixFileMode_ShouldBeSettableOnLinux( string path, UnixFileMode unixFileMode) { @@ -100,8 +100,8 @@ public async Task SetUnixFileMode_ShouldBeSettableOnLinux( await That(result).IsEqualTo(unixFileMode); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task SetUnixFileMode_ShouldThrowPlatformNotSupportedException_OnWindows( string path, UnixFileMode mode) { @@ -117,8 +117,8 @@ void Act() await That(Act).Throws().WithHResult(-2146233031); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllText_WhenUnixFileModeIsNone_ShouldThrowUnauthorizedAccessException( string path) { diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/File/WriteAllBytesAsyncTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/File/WriteAllBytesAsyncTests.cs index ba242d8d5..aac45a647 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/File/WriteAllBytesAsyncTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/File/WriteAllBytesAsyncTests.cs @@ -8,10 +8,10 @@ namespace Testably.Abstractions.Tests.FileSystem.File; // ReSharper disable MethodHasAsyncOverload [FileSystemTests] -public partial class WriteAllBytesAsyncTests +public class WriteAllBytesAsyncTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllBytesAsync_Cancelled_ShouldThrowTaskCanceledException( string path, byte[] bytes) { @@ -24,45 +24,45 @@ async Task Act() => await That(Act).Throws().WithHResult(-2146233029); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllBytesAsync_PreviousFile_ShouldOverwriteFileWithBytes( string path, byte[] bytes) { - await FileSystem.File.WriteAllBytesAsync(path, Encoding.UTF8.GetBytes("foo"), TestContext.Current.CancellationToken); + await FileSystem.File.WriteAllBytesAsync(path, Encoding.UTF8.GetBytes("foo"), CancellationToken); - await FileSystem.File.WriteAllBytesAsync(path, bytes, TestContext.Current.CancellationToken); + await FileSystem.File.WriteAllBytesAsync(path, bytes, CancellationToken); await That(FileSystem.File.Exists(path)).IsTrue(); await That(FileSystem.File.ReadAllBytes(path)).IsEqualTo(bytes); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllBytesAsync_ShouldCreateFileWithBytes( string path, byte[] bytes) { - await FileSystem.File.WriteAllBytesAsync(path, bytes, TestContext.Current.CancellationToken); + await FileSystem.File.WriteAllBytesAsync(path, bytes, CancellationToken); await That(FileSystem.File.Exists(path)).IsTrue(); await That(FileSystem.File.ReadAllBytes(path)).IsEqualTo(bytes); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllBytesAsync_WhenBytesAreNull_ShouldThrowArgumentNullException( string path) { async Task Act() { - await FileSystem.File.WriteAllBytesAsync(path, null!, TestContext.Current.CancellationToken); + await FileSystem.File.WriteAllBytesAsync(path, null!, CancellationToken); } await That(Act).Throws().WithParamName("bytes"); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllBytesAsync_WhenDirectoryWithSameNameExists_ShouldThrowUnauthorizedAccessException( string path, byte[] bytes) @@ -71,7 +71,7 @@ public async Task async Task Act() { - await FileSystem.File.WriteAllBytesAsync(path, bytes, TestContext.Current.CancellationToken); + await FileSystem.File.WriteAllBytesAsync(path, bytes, CancellationToken); } await That(Act).Throws().WithHResult(-2147024891); @@ -79,28 +79,28 @@ async Task Act() await That(FileSystem.File.Exists(path)).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllTextAsync_WhenFileIsHidden_ShouldThrowUnauthorizedAccessException_OnWindows( string path, byte[] bytes) { Skip.IfNot(Test.RunsOnWindows); - await FileSystem.File.WriteAllTextAsync(path, "", TestContext.Current.CancellationToken); + await FileSystem.File.WriteAllTextAsync(path, "", CancellationToken); FileSystem.File.SetAttributes(path, FileAttributes.Hidden); async Task Act() { - await FileSystem.File.WriteAllBytesAsync(path, bytes, TestContext.Current.CancellationToken); + await FileSystem.File.WriteAllBytesAsync(path, bytes, CancellationToken); } await That(Act).Throws().WithHResult(-2147024891); } #if FEATURE_FILE_SPAN - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllBytesAsync_ReadOnlyMemory_Cancelled_ShouldThrowTaskCanceledException( string path, byte[] bytes) { @@ -113,32 +113,32 @@ async Task Act() => await That(Act).Throws().WithHResult(-2146233029); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllBytesAsync_ReadOnlyMemory_PreviousFile_ShouldOverwriteFileWithBytes( string path, byte[] bytes) { - await FileSystem.File.WriteAllBytesAsync(path, Encoding.UTF8.GetBytes("foo"), TestContext.Current.CancellationToken); + await FileSystem.File.WriteAllBytesAsync(path, Encoding.UTF8.GetBytes("foo"), CancellationToken); - await FileSystem.File.WriteAllBytesAsync(path, bytes.AsMemory(), TestContext.Current.CancellationToken); + await FileSystem.File.WriteAllBytesAsync(path, bytes.AsMemory(), CancellationToken); await That(FileSystem.File.Exists(path)).IsTrue(); await That(FileSystem.File.ReadAllBytes(path)).IsEqualTo(bytes); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllBytesAsync_ReadOnlyMemory_ShouldCreateFileWithBytes( string path, byte[] bytes) { - await FileSystem.File.WriteAllBytesAsync(path, bytes.AsMemory(), TestContext.Current.CancellationToken); + await FileSystem.File.WriteAllBytesAsync(path, bytes.AsMemory(), CancellationToken); await That(FileSystem.File.Exists(path)).IsTrue(); await That(FileSystem.File.ReadAllBytes(path)).IsEqualTo(bytes); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllBytesAsync_ReadOnlyMemory_WhenDirectoryWithSameNameExists_ShouldThrowUnauthorizedAccessException( string path, byte[] bytes) @@ -147,7 +147,7 @@ public async Task async Task Act() { - await FileSystem.File.WriteAllBytesAsync(path, bytes.AsMemory(), TestContext.Current.CancellationToken); + await FileSystem.File.WriteAllBytesAsync(path, bytes.AsMemory(), CancellationToken); } await That(Act).Throws().WithHResult(-2147024891); @@ -155,20 +155,20 @@ async Task Act() await That(FileSystem.File.Exists(path)).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllTextAsync_ReadOnlyMemory_WhenFileIsHidden_ShouldThrowUnauthorizedAccessException_OnWindows( string path, byte[] bytes) { Skip.IfNot(Test.RunsOnWindows); - await FileSystem.File.WriteAllTextAsync(path, "", TestContext.Current.CancellationToken); + await FileSystem.File.WriteAllTextAsync(path, "", CancellationToken); FileSystem.File.SetAttributes(path, FileAttributes.Hidden); async Task Act() { - await FileSystem.File.WriteAllBytesAsync(path, bytes.AsMemory(), TestContext.Current.CancellationToken); + await FileSystem.File.WriteAllBytesAsync(path, bytes.AsMemory(), CancellationToken); } await That(Act).Throws().WithHResult(-2147024891); diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/File/WriteAllBytesTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/File/WriteAllBytesTests.cs index 20a93991c..809a2d9aa 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/File/WriteAllBytesTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/File/WriteAllBytesTests.cs @@ -4,10 +4,10 @@ namespace Testably.Abstractions.Tests.FileSystem.File; [FileSystemTests] -public partial class WriteAllBytesTests +public class WriteAllBytesTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllBytes_PreviousFile_ShouldOverwriteFileWithBytes( string path, byte[] bytes) { @@ -19,8 +19,8 @@ public async Task WriteAllBytes_PreviousFile_ShouldOverwriteFileWithBytes( await That(FileSystem.File.ReadAllBytes(path)).IsEqualTo(bytes); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllBytes_ShouldCreateFileWithBytes(string path, byte[] bytes) { FileSystem.File.WriteAllBytes(path, bytes); @@ -29,8 +29,8 @@ public async Task WriteAllBytes_ShouldCreateFileWithBytes(string path, byte[] by await That(FileSystem.File.ReadAllBytes(path)).IsEqualTo(bytes); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllBytes_WhenBytesAreNull_ShouldThrowArgumentNullException(string path) { void Act() @@ -41,8 +41,8 @@ void Act() await That(Act).Throws().WithParamName("bytes"); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllBytes_WhenDirectoryWithSameNameExists_ShouldThrowUnauthorizedAccessException( string path, byte[] bytes) @@ -59,8 +59,8 @@ void Act() await That(FileSystem.File.Exists(path)).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllBytes_WhenFileIsHidden_ShouldThrowUnauthorizedAccessException_OnWindows( string path, byte[] bytes) @@ -79,8 +79,8 @@ void Act() } #if FEATURE_FILE_SPAN - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllBytes_Span_PreviousFile_ShouldOverwriteFileWithBytes( string path, byte[] bytes) { @@ -92,8 +92,8 @@ public async Task WriteAllBytes_Span_PreviousFile_ShouldOverwriteFileWithBytes( await That(FileSystem.File.ReadAllBytes(path)).IsEqualTo(bytes); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllBytes_Span_ShouldCreateFileWithBytes(string path, byte[] bytes) { FileSystem.File.WriteAllBytes(path, bytes.AsSpan()); @@ -102,8 +102,8 @@ public async Task WriteAllBytes_Span_ShouldCreateFileWithBytes(string path, byte await That(FileSystem.File.ReadAllBytes(path)).IsEqualTo(bytes); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllBytes_Span_WhenDirectoryWithSameNameExists_ShouldThrowUnauthorizedAccessException( string path, byte[] bytes) @@ -120,8 +120,8 @@ void Act() await That(FileSystem.File.Exists(path)).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllBytes_Span_WhenFileIsHidden_ShouldThrowUnauthorizedAccessException_OnWindows( string path, byte[] bytes) { diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/File/WriteAllLinesAsyncTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/File/WriteAllLinesAsyncTests.cs index e126ff593..c409c2742 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/File/WriteAllLinesAsyncTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/File/WriteAllLinesAsyncTests.cs @@ -7,10 +7,10 @@ namespace Testably.Abstractions.Tests.FileSystem.File; [FileSystemTests] -public partial class WriteAllLinesAsyncTests +public class WriteAllLinesAsyncTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllLinesAsync_Cancelled_ShouldThrowTaskCanceledException( string path, string[] contents) { @@ -23,8 +23,8 @@ async Task Act() => await That(Act).Throws().WithHResult(-2146233029); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllLinesAsync_Cancelled_WithEncoding_ShouldThrowTaskCanceledException( string path, string[] contents) @@ -38,8 +38,8 @@ async Task Act() => await That(Act).Throws().WithHResult(-2146233029); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllLinesAsync_Enumerable_Cancelled_ShouldThrowTaskCanceledException( string path, string[] contents) @@ -53,8 +53,8 @@ async Task Act() => await That(Act).Throws().WithHResult(-2146233029); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllLinesAsync_Enumerable_Cancelled_WithEncoding_ShouldThrowTaskCanceledException( string path, string[] contents) @@ -69,37 +69,37 @@ await FileSystem.File.WriteAllLinesAsync(path, contents.AsEnumerable(), await That(Act).Throws().WithHResult(-2146233029); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllLinesAsync_Enumerable_PreviousFile_ShouldOverwriteFileWithText( string path, string[] contents) { - await FileSystem.File.WriteAllTextAsync(path, "foo", TestContext.Current.CancellationToken); + await FileSystem.File.WriteAllTextAsync(path, "foo", CancellationToken); await FileSystem.File.WriteAllLinesAsync(path, contents.AsEnumerable(), - TestContext.Current.CancellationToken); + CancellationToken); string[] result = - await FileSystem.File.ReadAllLinesAsync(path, TestContext.Current.CancellationToken); + await FileSystem.File.ReadAllLinesAsync(path, CancellationToken); await That(result).IsEqualTo(contents); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllLinesAsync_Enumerable_ShouldCreateFileWithText( string path, string[] contents) { await FileSystem.File.WriteAllLinesAsync(path, contents.AsEnumerable(), - TestContext.Current.CancellationToken); + CancellationToken); string[] result = - await FileSystem.File.ReadAllLinesAsync(path, TestContext.Current.CancellationToken); + await FileSystem.File.ReadAllLinesAsync(path, CancellationToken); await That(result).IsEqualTo(contents); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllLinesAsync_Enumerable_WithoutEncoding_ShouldUseUtf8( string path) { @@ -112,36 +112,36 @@ await FileSystem.File.WriteAllLinesAsync(path, contents.AsEnumerable(), await That(bytes.Length).IsEqualTo(6 + Environment.NewLine.Length); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllLinesAsync_PreviousFile_ShouldOverwriteFileWithText( string path, string[] contents) { - await FileSystem.File.WriteAllTextAsync(path, "foo", TestContext.Current.CancellationToken); + await FileSystem.File.WriteAllTextAsync(path, "foo", CancellationToken); await FileSystem.File.WriteAllLinesAsync(path, contents, - TestContext.Current.CancellationToken); + CancellationToken); string[] result = - await FileSystem.File.ReadAllLinesAsync(path, TestContext.Current.CancellationToken); + await FileSystem.File.ReadAllLinesAsync(path, CancellationToken); await That(result).IsEqualTo(contents); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllLinesAsync_ShouldCreateFileWithText( string path, string[] contents) { await FileSystem.File.WriteAllLinesAsync(path, contents, - TestContext.Current.CancellationToken); + CancellationToken); string[] result = - await FileSystem.File.ReadAllLinesAsync(path, TestContext.Current.CancellationToken); + await FileSystem.File.ReadAllLinesAsync(path, CancellationToken); await That(result).IsEqualTo(contents); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllLinesAsync_WhenDirectoryWithSameNameExists_ShouldThrowUnauthorizedAccessException( string path, string[] contents) @@ -151,7 +151,7 @@ public async Task async Task Act() { await FileSystem.File.WriteAllLinesAsync(path, contents, - TestContext.Current.CancellationToken); + CancellationToken); } await That(Act).Throws().WithHResult(-2147024891); @@ -159,21 +159,21 @@ await FileSystem.File.WriteAllLinesAsync(path, contents, await That(FileSystem.File.Exists(path)).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllLinesAsync_WhenFileIsHidden_ShouldThrowUnauthorizedAccessException_OnWindows( string path, string[] contents) { Skip.IfNot(Test.RunsOnWindows); - await FileSystem.File.WriteAllTextAsync(path, "", TestContext.Current.CancellationToken); + await FileSystem.File.WriteAllTextAsync(path, "", CancellationToken); FileSystem.File.SetAttributes(path, FileAttributes.Hidden); async Task Act() { await FileSystem.File.WriteAllLinesAsync(path, contents, - TestContext.Current.CancellationToken); + CancellationToken); } await That(Act).Throws().WithHResult(-2147024891); diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/File/WriteAllLinesTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/File/WriteAllLinesTests.cs index ad25fe8eb..ecd137e67 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/File/WriteAllLinesTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/File/WriteAllLinesTests.cs @@ -5,10 +5,10 @@ namespace Testably.Abstractions.Tests.FileSystem.File; [FileSystemTests] -public partial class WriteAllLinesTests +public class WriteAllLinesTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllLines_Enumerable_PreviousFile_ShouldOverwriteFileWithText( string path, string[] contents) { @@ -20,8 +20,8 @@ public async Task WriteAllLines_Enumerable_PreviousFile_ShouldOverwriteFileWithT await That(result).IsEqualTo(contents); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllLines_Enumerable_ShouldCreateFileWithText( string path, string[] contents) { @@ -31,8 +31,8 @@ public async Task WriteAllLines_Enumerable_ShouldCreateFileWithText( await That(result).IsEqualTo(contents); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllLines_Enumerable_WithEncoding_ShouldCreateFileWithText( Encoding encoding, string path, string[] contents) { @@ -42,8 +42,8 @@ public async Task WriteAllLines_Enumerable_WithEncoding_ShouldCreateFileWithText await That(result).IsEqualTo(contents); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllLines_Enumerable_WithoutEncoding_ShouldUseUtf8( string path) { @@ -55,8 +55,8 @@ public async Task WriteAllLines_Enumerable_WithoutEncoding_ShouldUseUtf8( await That(bytes.Length).IsEqualTo(6 + Environment.NewLine.Length); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllLines_PreviousFile_ShouldOverwriteFileWithText( string path, string[] contents) { @@ -68,8 +68,8 @@ public async Task WriteAllLines_PreviousFile_ShouldOverwriteFileWithText( await That(result).IsEqualTo(contents); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllLines_ShouldCreateFileWithText(string path, string[] contents) { FileSystem.File.WriteAllLines(path, contents); @@ -78,8 +78,8 @@ public async Task WriteAllLines_ShouldCreateFileWithText(string path, string[] c await That(result).IsEqualTo(contents); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllLines_WhenDirectoryWithSameNameExists_ShouldThrowUnauthorizedAccessException( string path, string[] contents) @@ -96,8 +96,8 @@ void Act() await That(FileSystem.File.Exists(path)).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllLines_WhenFileIsHidden_ShouldThrowUnauthorizedAccessException_OnWindows( string path, string[] contents) @@ -115,8 +115,8 @@ void Act() await That(Act).Throws().WithHResult(-2147024891); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllLines_WithEncoding_ShouldCreateFileWithText( Encoding encoding, string path, string[] contents) { @@ -126,8 +126,8 @@ public async Task WriteAllLines_WithEncoding_ShouldCreateFileWithText( await That(result).IsEqualTo(contents); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllLines_WithoutEncoding_ShouldUseUtf8( string path) { diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/File/WriteAllTextAsyncTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/File/WriteAllTextAsyncTests.cs index 07aa8e76c..08d1e5092 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/File/WriteAllTextAsyncTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/File/WriteAllTextAsyncTests.cs @@ -6,10 +6,10 @@ namespace Testably.Abstractions.Tests.FileSystem.File; [FileSystemTests] -public partial class WriteAllTextAsyncTests +public class WriteAllTextAsyncTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllTextAsync_Cancelled_ShouldThrowTaskCanceledException( string path, string? contents) { @@ -22,8 +22,8 @@ async Task Act() => await That(Act).Throws().WithHResult(-2146233029); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllTextAsync_Cancelled_WithEncoding_ShouldThrowTaskCanceledException( string path, string? contents) @@ -37,37 +37,37 @@ async Task Act() => await That(Act).Throws().WithHResult(-2146233029); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllTextAsync_PreviousFile_ShouldOverwriteFileWithText( string path, string contents) { - await FileSystem.File.WriteAllTextAsync(path, "foo", TestContext.Current.CancellationToken); + await FileSystem.File.WriteAllTextAsync(path, "foo", CancellationToken); await FileSystem.File.WriteAllTextAsync(path, contents, - TestContext.Current.CancellationToken); + CancellationToken); string result = - await FileSystem.File.ReadAllTextAsync(path, TestContext.Current.CancellationToken); + await FileSystem.File.ReadAllTextAsync(path, CancellationToken); await That(result).IsEqualTo(contents); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllTextAsync_ShouldCreateFileWithText( string path, string contents) { await FileSystem.File.WriteAllTextAsync(path, contents, - TestContext.Current.CancellationToken); + CancellationToken); string result = - await FileSystem.File.ReadAllTextAsync(path, TestContext.Current.CancellationToken); + await FileSystem.File.ReadAllTextAsync(path, CancellationToken); await That(result).IsEqualTo(contents); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllTextAsync_SpecialCharacters_ShouldReturnSameText( string path) { @@ -85,31 +85,31 @@ public async Task WriteAllTextAsync_SpecialCharacters_ShouldReturnSameText( { string contents = "_" + specialCharacter; await FileSystem.File.WriteAllTextAsync(path, contents, - TestContext.Current.CancellationToken); + CancellationToken); string result = - await FileSystem.File.ReadAllTextAsync(path, TestContext.Current.CancellationToken); + await FileSystem.File.ReadAllTextAsync(path, CancellationToken); await That(result).IsEqualTo(contents) .Because($"{contents} should be encoded and decoded identical."); } } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllTextAsync_WhenContentIsNull_ShouldNotThrowException(string path) { async Task Act() { await FileSystem.File.WriteAllTextAsync(path, (string?)null, - TestContext.Current.CancellationToken); + CancellationToken); } await That(Act).DoesNotThrow(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllTextAsync_WhenDirectoryWithSameNameExists_ShouldThrowUnauthorizedAccessException( string path, string contents) @@ -119,7 +119,7 @@ public async Task async Task Act() { await FileSystem.File.WriteAllTextAsync(path, contents, - TestContext.Current.CancellationToken); + CancellationToken); } await That(Act).Throws().WithHResult(-2147024891); @@ -127,28 +127,28 @@ await FileSystem.File.WriteAllTextAsync(path, contents, await That(FileSystem.File.Exists(path)).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllTextAsync_WhenFileIsHidden_ShouldThrowUnauthorizedAccessException_OnWindows( string path, string contents) { Skip.IfNot(Test.RunsOnWindows); - await FileSystem.File.WriteAllTextAsync(path, "", TestContext.Current.CancellationToken); + await FileSystem.File.WriteAllTextAsync(path, "", CancellationToken); FileSystem.File.SetAttributes(path, FileAttributes.Hidden); async Task Act() { await FileSystem.File.WriteAllTextAsync(path, contents, - TestContext.Current.CancellationToken); + CancellationToken); } await That(Act).Throws().WithHResult(-2147024891); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllTextAsync_WithoutEncoding_ShouldUseUtf8( string path) { @@ -161,8 +161,8 @@ public async Task WriteAllTextAsync_WithoutEncoding_ShouldUseUtf8( } #if FEATURE_FILE_SPAN - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllTextAsync_ReadOnlyMemory_Cancelled_ShouldThrowTaskCanceledException( string path, string? contents) { @@ -175,8 +175,8 @@ async Task Act() => await That(Act).Throws().WithHResult(-2146233029); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllTextAsync_ReadOnlyMemory_Cancelled_WithEncoding_ShouldThrowTaskCanceledException( string path, string? contents) @@ -191,37 +191,37 @@ await FileSystem.File.WriteAllTextAsync(path, contents.AsMemory(), Encoding.UTF8 await That(Act).Throws().WithHResult(-2146233029); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllTextAsync_ReadOnlyMemory_PreviousFile_ShouldOverwriteFileWithText( string path, string contents) { - await FileSystem.File.WriteAllTextAsync(path, "foo", TestContext.Current.CancellationToken); + await FileSystem.File.WriteAllTextAsync(path, "foo", CancellationToken); await FileSystem.File.WriteAllTextAsync(path, contents.AsMemory(), - TestContext.Current.CancellationToken); + CancellationToken); string result = - await FileSystem.File.ReadAllTextAsync(path, TestContext.Current.CancellationToken); + await FileSystem.File.ReadAllTextAsync(path, CancellationToken); await That(result).IsEqualTo(contents); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllTextAsync_ReadOnlyMemory_ShouldCreateFileWithText( string path, string contents) { await FileSystem.File.WriteAllTextAsync(path, contents.AsMemory(), - TestContext.Current.CancellationToken); + CancellationToken); string result = - await FileSystem.File.ReadAllTextAsync(path, TestContext.Current.CancellationToken); + await FileSystem.File.ReadAllTextAsync(path, CancellationToken); await That(result).IsEqualTo(contents); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllTextAsync_ReadOnlyMemory_SpecialCharacters_ShouldReturnSameText( string path) { @@ -239,18 +239,18 @@ public async Task WriteAllTextAsync_ReadOnlyMemory_SpecialCharacters_ShouldRetur { string contents = "_" + specialCharacter; await FileSystem.File.WriteAllTextAsync(path, contents.AsMemory(), - TestContext.Current.CancellationToken); + CancellationToken); string result = - await FileSystem.File.ReadAllTextAsync(path, TestContext.Current.CancellationToken); + await FileSystem.File.ReadAllTextAsync(path, CancellationToken); await That(result).IsEqualTo(contents) .Because($"{contents} should be encoded and decoded identical."); } } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllTextAsync_ReadOnlyMemory_WhenDirectoryWithSameNameExists_ShouldThrowUnauthorizedAccessException( string path, string contents) @@ -260,7 +260,7 @@ public async Task async Task Act() { await FileSystem.File.WriteAllTextAsync(path, contents.AsMemory(), - TestContext.Current.CancellationToken); + CancellationToken); } await That(Act).Throws().WithHResult(-2147024891); @@ -268,28 +268,28 @@ await FileSystem.File.WriteAllTextAsync(path, contents.AsMemory(), await That(FileSystem.File.Exists(path)).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllTextAsync_ReadOnlyMemory_WhenFileIsHidden_ShouldThrowUnauthorizedAccessException_OnWindows( string path, string contents) { Skip.IfNot(Test.RunsOnWindows); - await FileSystem.File.WriteAllTextAsync(path, "", TestContext.Current.CancellationToken); + await FileSystem.File.WriteAllTextAsync(path, "", CancellationToken); FileSystem.File.SetAttributes(path, FileAttributes.Hidden); async Task Act() { await FileSystem.File.WriteAllTextAsync(path, contents.AsMemory(), - TestContext.Current.CancellationToken); + CancellationToken); } await That(Act).Throws().WithHResult(-2147024891); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllTextAsync_ReadOnlyMemory_WithoutEncoding_ShouldUseUtf8( string path) { diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/File/WriteAllTextTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/File/WriteAllTextTests.cs index a19fac7c0..acc5daa77 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/File/WriteAllTextTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/File/WriteAllTextTests.cs @@ -5,10 +5,10 @@ namespace Testably.Abstractions.Tests.FileSystem.File; [FileSystemTests] -public partial class WriteAllTextTests +public class WriteAllTextTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllText_MissingDirectory_ShouldThrowDirectoryNotFoundException( string directory, string path) { @@ -24,8 +24,8 @@ await That(Act).Throws() .WithMessageContaining($"'{FileSystem.Path.GetFullPath(fullPath)}'"); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllText_PreviousFile_ShouldOverwriteFileWithText( string path, string contents) { @@ -37,8 +37,8 @@ public async Task WriteAllText_PreviousFile_ShouldOverwriteFileWithText( await That(result).IsEqualTo(contents); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllText_ShouldAdjustTimes(string path, string contents) { SkipIfLongRunningTestsShouldBeSkipped(); @@ -70,8 +70,8 @@ await That(lastAccessTime).IsBetween(creationTimeStart).And(creationTimeEnd) await That(lastWriteTime).IsOnOrAfter(updateTime.ApplySystemClockTolerance()); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllText_ShouldCreateFileWithByteOrderMark( string path) { @@ -83,8 +83,8 @@ public async Task WriteAllText_ShouldCreateFileWithByteOrderMark( await That(FileSystem.File.ReadAllBytes(path)).IsEqualTo(expectedBytes); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllText_ShouldCreateFileWithText(string path, string contents) { FileSystem.File.WriteAllText(path, contents); @@ -93,8 +93,8 @@ public async Task WriteAllText_ShouldCreateFileWithText(string path, string cont await That(result).IsEqualTo(contents); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllText_SpecialCharacters_ShouldReturnSameText(string path) { char[] specialCharacters = @@ -119,8 +119,8 @@ await That(result).IsEqualTo(contents) } } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllText_WhenContentIsNull_ShouldNotThrowException(string path) { void Act() @@ -131,8 +131,8 @@ void Act() await That(Act).DoesNotThrow(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllText_WhenDirectoryWithSameNameExists_ShouldThrowUnauthorizedAccessException( string path) @@ -149,8 +149,8 @@ void Act() await That(FileSystem.File.Exists(path)).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllText_WhenFileIsHidden_ShouldThrowUnauthorizedAccessException_OnWindows( string path, string contents) @@ -168,7 +168,7 @@ void Act() await That(Act).Throws().WithHResult(-2147024891); } - [Fact] + [Test] public async Task WriteAllText_WithoutAccessRightsToParentDirectory_ShouldThrowUnauthorizedAccessException() { @@ -196,8 +196,8 @@ await That(Act).Throws() .WithMessage($"Access to the path '{path}' is denied."); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllText_WithoutEncoding_ShouldUseUtf8( string path) { @@ -210,8 +210,8 @@ public async Task WriteAllText_WithoutEncoding_ShouldUseUtf8( } #if FEATURE_FILE_SPAN - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllText_Span_MissingDirectory_ShouldThrowDirectoryNotFoundException( string directory, string path) { @@ -227,8 +227,8 @@ await That(Act).Throws() .WithMessageContaining($"'{FileSystem.Path.GetFullPath(fullPath)}'"); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllText_Span_PreviousFile_ShouldOverwriteFileWithText( string path, string contents) { @@ -240,8 +240,8 @@ public async Task WriteAllText_Span_PreviousFile_ShouldOverwriteFileWithText( await That(result).IsEqualTo(contents); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllText_Span_ShouldAdjustTimes(string path, string contents) { SkipIfLongRunningTestsShouldBeSkipped(); @@ -273,8 +273,8 @@ await That(lastAccessTime).IsBetween(creationTimeStart).And(creationTimeEnd) await That(lastWriteTime).IsOnOrAfter(updateTime.ApplySystemClockTolerance()); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllText_Span_ShouldCreateFileWithByteOrderMark( string path) { @@ -286,8 +286,8 @@ public async Task WriteAllText_Span_ShouldCreateFileWithByteOrderMark( await That(FileSystem.File.ReadAllBytes(path)).IsEqualTo(expectedBytes); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllText_Span_ShouldCreateFileWithText(string path, string contents) { FileSystem.File.WriteAllText(path, contents.AsSpan()); @@ -296,8 +296,8 @@ public async Task WriteAllText_Span_ShouldCreateFileWithText(string path, string await That(result).IsEqualTo(contents); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllText_Span_SpecialCharacters_ShouldReturnSameText(string path) { char[] specialCharacters = @@ -322,8 +322,8 @@ await That(result).IsEqualTo(contents) } } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllText_Span_WhenDirectoryWithSameNameExists_ShouldThrowUnauthorizedAccessException( string path) @@ -340,8 +340,8 @@ void Act() await That(FileSystem.File.Exists(path)).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllText_Span_WhenFileIsHidden_ShouldThrowUnauthorizedAccessException_OnWindows( string path, string contents) @@ -359,8 +359,8 @@ void Act() await That(Act).Throws().WithHResult(-2147024891); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAllText_Span_WithoutEncoding_ShouldUseUtf8( string path) { diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/AppendTextTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/AppendTextTests.cs index d8e8524f1..a4446ff3e 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/AppendTextTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/AppendTextTests.cs @@ -3,10 +3,10 @@ namespace Testably.Abstractions.Tests.FileSystem.FileInfo; [FileSystemTests] -public partial class AppendTextTests +public class AppendTextTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendText_MissingFile_ShouldCreateFile( string path, string appendText) { @@ -21,8 +21,8 @@ public async Task AppendText_MissingFile_ShouldCreateFile( await That(FileSystem.File.ReadAllText(path)).IsEqualTo(appendText); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task AppendText_ShouldAddTextToExistingFile( string path, string contents, string appendText) { diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/AttributesTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/AttributesTests.cs index 7d1ed32ba..ede79e618 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/AttributesTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/AttributesTests.cs @@ -3,10 +3,10 @@ namespace Testably.Abstractions.Tests.FileSystem.FileInfo; [FileSystemTests] -public partial class AttributesTests +public class AttributesTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Attributes_SetDirectoryAttribute_ShouldRemainFile(string path) { FileSystem.File.WriteAllText(path, "foo"); @@ -17,8 +17,8 @@ public async Task Attributes_SetDirectoryAttribute_ShouldRemainFile(string path) await That(sut.Attributes).DoesNotHaveFlag(FileAttributes.Directory); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Attributes_ShouldNotHaveDirectoryAttribute(string path) { FileSystem.File.WriteAllText(path, "foo"); diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/CopyToTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/CopyToTests.cs index 2b7f0e27d..d97dda21e 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/CopyToTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/CopyToTests.cs @@ -3,10 +3,10 @@ namespace Testably.Abstractions.Tests.FileSystem.FileInfo; [FileSystemTests] -public partial class CopyToTests +public class CopyToTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CopyTo_DestinationExists_ShouldThrowIOException_AndNotCopyFile( string sourceName, string destinationName, @@ -31,8 +31,8 @@ void Act() } #if FEATURE_FILE_MOVETO_OVERWRITE - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CopyTo_DestinationExists_WithOverwrite_ShouldOverwriteDestination( string sourceName, string destinationName, @@ -56,8 +56,8 @@ public async Task CopyTo_DestinationExists_WithOverwrite_ShouldOverwriteDestinat } #endif - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CopyTo_ReadOnly_ShouldCopyFile( string sourceName, string destinationName, string contents) { @@ -73,9 +73,9 @@ public async Task CopyTo_ReadOnly_ShouldCopyFile( await That(FileSystem.File.GetAttributes(destinationName)).HasFlag(FileAttributes.ReadOnly); } - [Theory] - [InlineAutoData(FileAttributes.ReadOnly)] - [InlineAutoData(FileAttributes.System)] + [Test] + [AutoArguments(FileAttributes.ReadOnly)] + [AutoArguments(FileAttributes.System)] public async Task CopyTo_ShouldAddArchiveAttribute_OnWindows( FileAttributes fileAttributes, string sourceName, @@ -98,8 +98,8 @@ public async Task CopyTo_ShouldAddArchiveAttribute_OnWindows( await That(FileSystem.File.GetAttributes(destinationName)).IsEqualTo(expectedAttributes); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CopyTo_ShouldCopyFileWithContent( string sourceName, string destinationName, string contents) { @@ -122,8 +122,8 @@ public async Task CopyTo_ShouldCopyFileWithContent( await That(FileSystem.File.ReadAllText(destinationName)).IsEqualTo(contents); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CopyTo_ShouldKeepMetadata( string sourceName, string destinationName, @@ -169,13 +169,13 @@ await That(FileSystem.File.GetLastWriteTime(destinationName)) .IsEqualTo(sourceLastWriteTime); } - [Theory] - [InlineAutoData(FileAccess.Read, FileShare.Read)] - [InlineAutoData(FileAccess.Read, FileShare.ReadWrite)] - [InlineAutoData(FileAccess.ReadWrite, FileShare.Read)] - [InlineAutoData(FileAccess.ReadWrite, FileShare.ReadWrite)] - [InlineAutoData(FileAccess.Write, FileShare.Read)] - [InlineAutoData(FileAccess.Write, FileShare.ReadWrite)] + [Test] + [AutoArguments(FileAccess.Read, FileShare.Read)] + [AutoArguments(FileAccess.Read, FileShare.ReadWrite)] + [AutoArguments(FileAccess.ReadWrite, FileShare.Read)] + [AutoArguments(FileAccess.ReadWrite, FileShare.ReadWrite)] + [AutoArguments(FileAccess.Write, FileShare.Read)] + [AutoArguments(FileAccess.Write, FileShare.ReadWrite)] public async Task CopyTo_SourceAccessedWithReadShare_ShouldNotThrow( FileAccess fileAccess, FileShare fileShare, @@ -196,10 +196,10 @@ public async Task CopyTo_SourceAccessedWithReadShare_ShouldNotThrow( await That(FileSystem.File.ReadAllText(destinationPath)).IsEqualTo(sourceContents); } - [Theory] - [InlineAutoData(FileAccess.Read)] - [InlineAutoData(FileAccess.ReadWrite)] - [InlineAutoData(FileAccess.Write)] + [Test] + [AutoArguments(FileAccess.Read)] + [AutoArguments(FileAccess.ReadWrite)] + [AutoArguments(FileAccess.Write)] public async Task CopyTo_SourceAccessedWithWriteShare_ShouldNotThrowOnLinuxOrMac( FileAccess fileAccess, string sourcePath, @@ -221,8 +221,8 @@ public async Task CopyTo_SourceAccessedWithWriteShare_ShouldNotThrowOnLinuxOrMac await That(FileSystem.File.ReadAllText(destinationPath)).IsEqualTo(sourceContents); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CopyTo_SourceIsDirectory_ShouldThrowUnauthorizedAccessException_AndNotCopyFile( string sourceName, @@ -243,9 +243,9 @@ await That(Act).Throws() await That(FileSystem.File.Exists(destinationName)).IsFalse(); } - [Theory] - [InlineAutoData(FileShare.None)] - [InlineAutoData(FileShare.Write)] + [Test] + [AutoArguments(FileShare.None)] + [AutoArguments(FileShare.Write)] public async Task CopyTo_SourceLocked_ShouldThrowIOException( FileShare fileShare, string sourceName, @@ -276,8 +276,8 @@ void Act() } } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CopyTo_SourceMissing_ShouldThrowFileNotFoundException( string sourceName, string destinationName) diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/CreateAsSymbolicLinkTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/CreateAsSymbolicLinkTests.cs index aa13215cd..cfa73604c 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/CreateAsSymbolicLinkTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/CreateAsSymbolicLinkTests.cs @@ -4,10 +4,10 @@ namespace Testably.Abstractions.Tests.FileSystem.FileInfo; [FileSystemTests] -public partial class CreateAsSymbolicLinkTests +public class CreateAsSymbolicLinkTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateAsSymbolicLink_ShouldCreateSymbolicLink( string path, string pathToTarget) { @@ -19,8 +19,8 @@ await That(FileSystem.File.GetAttributes(path)) .HasFlag(FileAttributes.ReparsePoint); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateAsSymbolicLink_SourceFileAlreadyExists_ShouldThrowIOException( string path, string pathToTarget) { @@ -37,8 +37,8 @@ await That(Act).Throws() .WithHResult(Test.RunsOnWindows ? -2147024713 : 17); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateAsSymbolicLink_TargetFileMissing_ShouldNotThrowException( string path, string pathToTarget) { @@ -50,8 +50,8 @@ void Act() await That(Act).DoesNotThrow(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateAsSymbolicLink_WithEmptyPath_ShouldThrowArgumentException( string pathToTarget) { @@ -65,8 +65,8 @@ void Act() await That(Act).Throws().WithParamName("path"); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateAsSymbolicLink_WithEmptyTarget_ShouldThrowArgumentException( string path) { @@ -80,8 +80,8 @@ void Act() await That(Act).Throws().WithParamName("pathToTarget"); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateAsSymbolicLink_WithIllegalCharactersInPath_ShouldThrowIOException( string pathToTarget) { @@ -97,8 +97,8 @@ void Act() await That(Act).Throws().WithHResult(-2147024773); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateAsSymbolicLink_WithIllegalCharactersInTarget_ShouldThrowIOException( string path) { @@ -114,8 +114,8 @@ void Act() await That(Act).Throws().WithHResult(-2147024713); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateAsSymbolicLink_WithIllegalPath_ShouldThrowArgumentException_OnWindows( string pathToTarget) { @@ -136,8 +136,8 @@ void Act() } } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateAsSymbolicLink_WithIllegalTarget_ShouldNotThrowException( string path) { @@ -149,8 +149,8 @@ void Act() await That(Act).DoesNotThrow(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateAsSymbolicLink_WithNullPath_ShouldThrowArgumentNullException( string pathToTarget) { @@ -164,8 +164,8 @@ void Act() await That(Act).Throws().WithParamName("fileName"); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateAsSymbolicLink_WithNullTarget_ShouldThrowArgumentNullException( string path) { diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/CreateTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/CreateTests.cs index 6e7de272a..c40ee1772 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/CreateTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/CreateTests.cs @@ -3,10 +3,10 @@ namespace Testably.Abstractions.Tests.FileSystem.FileInfo; [FileSystemTests] -public partial class CreateTests +public class CreateTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Create_MissingFile_ShouldCreateFile(string path) { IFileInfo sut = FileSystem.FileInfo.New(path); @@ -17,8 +17,8 @@ public async Task Create_MissingFile_ShouldCreateFile(string path) await That(FileSystem.File.Exists(path)).IsTrue(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Create_ShouldRefreshExistsCacheForCurrentItem_ExceptOnNetFramework( string path) { @@ -47,8 +47,8 @@ public async Task Create_ShouldRefreshExistsCacheForCurrentItem_ExceptOnNetFrame await That(FileSystem.File.Exists(path)).IsTrue(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Create_ShouldUseReadWriteAccessAndNoneShare(string path) { FileSystem.File.WriteAllText(path, null); diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/CreateTextTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/CreateTextTests.cs index 3782c2d58..d069e9005 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/CreateTextTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/CreateTextTests.cs @@ -3,10 +3,10 @@ namespace Testably.Abstractions.Tests.FileSystem.FileInfo; [FileSystemTests] -public partial class CreateTextTests +public class CreateTextTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateText_MissingFile_ShouldCreateFile( string path, string appendText) { @@ -22,8 +22,8 @@ public async Task CreateText_MissingFile_ShouldCreateFile( } #if NET8_0_OR_GREATER - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateText_ShouldRefreshExistsCache( string path, string appendText) { @@ -39,8 +39,8 @@ public async Task CreateText_ShouldRefreshExistsCache( await That(FileSystem.File.Exists(path)).IsTrue(); } #else - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateText_ShouldNotRefreshExistsCache( string path, string appendText) { @@ -57,8 +57,8 @@ public async Task CreateText_ShouldNotRefreshExistsCache( } #endif - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateText_ShouldReplaceTextInExistingFile( string path, string contents, string appendText) { diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/DeleteTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/DeleteTests.cs index db7151478..b58eaa268 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/DeleteTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/DeleteTests.cs @@ -3,10 +3,10 @@ namespace Testably.Abstractions.Tests.FileSystem.FileInfo; [FileSystemTests] -public partial class DeleteTests +public class DeleteTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Delete_MissingDirectory_ShouldThrowDirectoryNotFoundException( string missingDirectory, string fileName) { @@ -20,8 +20,8 @@ void Act() await That(Act).Throws().WithHResult(-2147024893); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Delete_MissingFile_ShouldDoNothing( string fileName) { @@ -33,8 +33,8 @@ void Act() await That(Act).DoesNotThrow(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Delete_ShouldRefreshExistsCache_ExceptOnNetFramework(string path) { FileSystem.File.WriteAllText(path, "some content"); @@ -55,8 +55,8 @@ public async Task Delete_ShouldRefreshExistsCache_ExceptOnNetFramework(string pa await That(FileSystem.File.Exists(path)).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Delete_WithOpenFile_ShouldThrowIOException_OnWindows(string filename) { FileSystem.Initialize(); diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/EncryptDecryptTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/EncryptDecryptTests.cs index 2ccd8efa7..4af750f0d 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/EncryptDecryptTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/EncryptDecryptTests.cs @@ -3,10 +3,10 @@ namespace Testably.Abstractions.Tests.FileSystem.FileInfo; [FileSystemTests] -public partial class EncryptDecryptTests +public class EncryptDecryptTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] [SupportedOSPlatform("windows")] public async Task Decrypt_EncryptedData_ShouldReturnOriginalText( string path, string contents) @@ -24,8 +24,8 @@ public async Task Decrypt_EncryptedData_ShouldReturnOriginalText( await That(result).IsEqualTo(contents); } - [Theory] - [AutoData] + [Test] + [AutoArguments] [SupportedOSPlatform("windows")] public async Task Decrypt_UnencryptedData_ShouldReturnOriginalText( string path, string contents) @@ -41,8 +41,8 @@ public async Task Decrypt_UnencryptedData_ShouldReturnOriginalText( await That(result).IsEqualTo(contents); } - [Theory] - [AutoData] + [Test] + [AutoArguments] [SupportedOSPlatform("windows")] public async Task Encrypt_Decrypt_ShouldChangeEncryptedFileAttribute( string path, string contents) @@ -59,8 +59,8 @@ public async Task Encrypt_Decrypt_ShouldChangeEncryptedFileAttribute( await That(sut.Attributes).DoesNotHaveFlag(FileAttributes.Encrypted); } - [Theory] - [AutoData] + [Test] + [AutoArguments] [SupportedOSPlatform("windows")] public async Task Encrypt_ShouldChangeData( string path, byte[] bytes) @@ -77,8 +77,8 @@ public async Task Encrypt_ShouldChangeData( await That(result).IsNotEqualTo(bytes).InAnyOrder(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] [SupportedOSPlatform("windows")] public async Task Encrypt_Twice_ShouldIgnoreTheSecondTime( string path, string contents) diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/ExceptionTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/ExceptionTests.cs index 07d5a6fea..311c89af0 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/ExceptionTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/ExceptionTests.cs @@ -6,10 +6,26 @@ namespace Testably.Abstractions.Tests.FileSystem.FileInfo; [FileSystemTests] -public partial class ExceptionTests +public class ExceptionTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [MemberData(nameof(GetFileInfoCallbacks), "Illegal\tCharacter?InPath")] + public static IEnumerable<(Expression>, string, bool)> + GetFileInfoCallbacksWithEmptyPath() + => GetFileInfoCallbacks(""); + + public static IEnumerable<(Expression>, string, bool)> + GetFileInfoCallbacksWithIllegalPathCharacters() + => GetFileInfoCallbacks("Illegal\tCharacter?InPath"); + + public static IEnumerable<(Expression>, string, bool)> + GetFileInfoCallbacksWithNullPath() + => GetFileInfoCallbacks(null); + + public static IEnumerable<(Expression>, string, bool)> + GetFileInfoCallbacksWithWhitespacePath() + => GetFileInfoCallbacks(" "); + + [Test] + [MethodDataSource(nameof(GetFileInfoCallbacksWithIllegalPathCharacters))] public async Task Operations_WhenValueContainsIllegalPathCharacters_ShouldThrowCorrectException_OnWindows( Expression> callback, string paramName, @@ -48,8 +64,8 @@ await That(Act).Throws() } } - [Theory] - [MemberData(nameof(GetFileInfoCallbacks), "")] + [Test] + [MethodDataSource(nameof(GetFileInfoCallbacksWithEmptyPath))] public async Task Operations_WhenValueIsEmpty_ShouldThrowArgumentException( Expression> callback, string paramName, bool ignoreParamCheck) { @@ -65,8 +81,8 @@ await That(Act).Throws() $"\n{callback}\n has empty parameter for '{paramName}' (ignored: {ignoreParamCheck})"); } - [Theory] - [MemberData(nameof(GetFileInfoCallbacks), (string?)null)] + [Test] + [MethodDataSource(nameof(GetFileInfoCallbacksWithNullPath))] public async Task Operations_WhenValueIsNull_ShouldThrowArgumentNullException( Expression> callback, string paramName, bool ignoreParamCheck) { @@ -84,22 +100,19 @@ await That(Act).Throws() #region Helpers #pragma warning disable MA0018 - public static TheoryData>, string, bool> GetFileInfoCallbacks( + public static IEnumerable<(Expression>, string, bool)> GetFileInfoCallbacks( string? path) { - TheoryData>, string, bool> theoryData = new(); foreach ((ExceptionTestHelper.TestTypes TestType, string ParamName, Expression> Callback) item in GetFileInfoCallbackTestParameters(path!) .Where(item => item.TestType.HasFlag(path.ToTestType()))) { - theoryData.Add( + yield return ( item.Callback, item.ParamName, item.TestType.HasFlag(ExceptionTestHelper.TestTypes.IgnoreParamNameCheck)); } - - return theoryData; } #pragma warning restore MA0018 diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/ExistsTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/ExistsTests.cs index f03f94a09..f90f9e36d 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/ExistsTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/ExistsTests.cs @@ -1,10 +1,10 @@ namespace Testably.Abstractions.Tests.FileSystem.FileInfo; [FileSystemTests] -public partial class ExistsTests +public class ExistsTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Exists_Directory_ShouldReturnFalse(string path) { FileSystem.Directory.CreateDirectory(path); @@ -13,11 +13,11 @@ public async Task Exists_Directory_ShouldReturnFalse(string path) await That(sut.Exists).IsFalse(); } - [Theory] - [InlineData("foo", "foo.")] - [InlineData("foo.", "foo")] - [InlineData("foo", "foo..")] - [InlineData("foo..", "foo")] + [Test] + [Arguments("foo", "foo.")] + [Arguments("foo.", "foo")] + [Arguments("foo", "foo..")] + [Arguments("foo..", "foo")] public async Task Exists_ShouldIgnoreTrailingDot_OnWindows(string path1, string path2) { FileSystem.File.WriteAllText(path1, "some text"); @@ -26,8 +26,8 @@ public async Task Exists_ShouldIgnoreTrailingDot_OnWindows(string path1, string await That(sut.Exists).IsEqualTo(Test.RunsOnWindows); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Exists_ShouldReturnCachedValueUntilRefresh(string path) { IFileInfo sut = FileSystem.FileInfo.New(path); diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/LengthTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/LengthTests.cs index a117b12ce..e8c9314db 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/LengthTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/LengthTests.cs @@ -3,10 +3,10 @@ namespace Testably.Abstractions.Tests.FileSystem.FileInfo; [FileSystemTests] -public partial class LengthTests +public class LengthTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Length_MissingDirectory_ShouldThrowFileNotFoundException( string missingDirectory, string fileName) { @@ -25,8 +25,8 @@ await That(Act).Throws() : $"'{FileSystem.Path.GetFullPath(path)}'"); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Length_MissingFile_ShouldThrowFileNotFoundException(string path) { IFileInfo sut = FileSystem.FileInfo.New(path); @@ -43,8 +43,8 @@ await That(Act).Throws() : $"'{FileSystem.Path.GetFullPath(path)}'"); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Length_PathIsDirectory_ShouldThrowFileNotFoundException(string path) { FileSystem.Directory.CreateDirectory(path); @@ -62,8 +62,8 @@ await That(Act).Throws() : $"'{FileSystem.Path.GetFullPath(path)}'"); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Length_WhenFileExists_ShouldBeSetCorrectly(string path, byte[] bytes) { FileSystem.File.WriteAllBytes(path, bytes); @@ -74,8 +74,8 @@ public async Task Length_WhenFileExists_ShouldBeSetCorrectly(string path, byte[] await That(result).IsEqualTo(bytes.Length); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Length_WhenFileIsCreated_ShouldBeSetCorrectly(string path, byte[] bytes) { IFileInfo sut = FileSystem.FileInfo.New(path); @@ -87,8 +87,8 @@ public async Task Length_WhenFileIsCreated_ShouldBeSetCorrectly(string path, byt await That(result).IsEqualTo(bytes.Length); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Length_WhenFileIsCreatedAfterAccessed_ShouldBeSetCorrectly( string path, byte[] bytes) { @@ -107,8 +107,8 @@ void Act() await That(result).IsEqualTo(bytes.Length); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Length_WhenFileIsCreatedAfterLengthAccessed_ShouldThrowFileNotFoundExceptionAgain( string path, byte[] bytes) diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/MoveToTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/MoveToTests.cs index 3169a3568..f8253d9c2 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/MoveToTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/MoveToTests.cs @@ -3,10 +3,10 @@ namespace Testably.Abstractions.Tests.FileSystem.FileInfo; [FileSystemTests] -public partial class MoveToTests +public class MoveToTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task MoveTo_DestinationExists_ShouldThrowIOException_AndNotMoveFile( string sourceName, string destinationName, @@ -32,8 +32,8 @@ void Act() } #if FEATURE_FILE_MOVETO_OVERWRITE - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task MoveTo_DestinationExists_WithOverwrite_ShouldOverwriteDestination( string sourceName, string destinationName, @@ -55,8 +55,8 @@ public async Task MoveTo_DestinationExists_WithOverwrite_ShouldOverwriteDestinat } #endif - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task MoveTo_Itself_ShouldDoNothing( string sourceName, string contents) @@ -72,8 +72,8 @@ void Act() await That(Act).DoesNotThrow(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task MoveTo_Itself_SourceMissing_ShouldThrowFileNotFoundException( string sourceName) { @@ -92,8 +92,8 @@ await That(Act).Throws() await That(FileSystem.File.Exists(sourceName)).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task MoveTo_MissingDestinationDirectory_ShouldThrowDirectoryNotFoundException_AndNotMoveFile( string sourceName, @@ -119,8 +119,8 @@ void Act() await That(FileSystem.File.Exists(destinationName)).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task MoveTo_ReadOnly_ShouldMoveFile( string sourceName, string destinationName, string contents) { @@ -136,9 +136,9 @@ public async Task MoveTo_ReadOnly_ShouldMoveFile( await That(FileSystem.File.GetAttributes(destinationName)).HasFlag(FileAttributes.ReadOnly); } - [Theory] - [InlineAutoData(FileAttributes.ReadOnly)] - [InlineAutoData(FileAttributes.System)] + [Test] + [AutoArguments(FileAttributes.ReadOnly)] + [AutoArguments(FileAttributes.System)] public async Task MoveTo_ShouldAddArchiveAttribute_OnWindows( FileAttributes fileAttributes, string sourceName, @@ -160,8 +160,8 @@ public async Task MoveTo_ShouldAddArchiveAttribute_OnWindows( await That(FileSystem.File.GetAttributes(destinationName)).IsEqualTo(expectedAttributes); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task MoveTo_ShouldKeepMetadata( string sourceName, string destinationName, @@ -186,8 +186,8 @@ await That(FileSystem.File.GetLastWriteTime(destinationName)) .IsEqualTo(sourceLastWriteTime); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task MoveTo_ShouldMoveFileWithContent( string sourceName, string destinationName, string contents) { @@ -203,8 +203,8 @@ public async Task MoveTo_ShouldMoveFileWithContent( await That(FileSystem.File.ReadAllText(destinationName)).IsEqualTo(contents); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task MoveTo_ShouldNotAdjustTimes(string source, string destination) { SkipIfLongRunningTestsShouldBeSkipped(); @@ -230,19 +230,19 @@ public async Task MoveTo_ShouldNotAdjustTimes(string source, string destination) await That(lastWriteTime).IsEqualTo(expectedLastWriteTime); } - [Theory] - [InlineAutoData(FileAccess.Read, FileShare.None)] - [InlineAutoData(FileAccess.Read, FileShare.Read)] - [InlineAutoData(FileAccess.Read, FileShare.ReadWrite)] - [InlineAutoData(FileAccess.Read, FileShare.Write)] - [InlineAutoData(FileAccess.ReadWrite, FileShare.None)] - [InlineAutoData(FileAccess.ReadWrite, FileShare.Read)] - [InlineAutoData(FileAccess.ReadWrite, FileShare.ReadWrite)] - [InlineAutoData(FileAccess.ReadWrite, FileShare.Write)] - [InlineAutoData(FileAccess.Write, FileShare.None)] - [InlineAutoData(FileAccess.Write, FileShare.Read)] - [InlineAutoData(FileAccess.Write, FileShare.ReadWrite)] - [InlineAutoData(FileAccess.Write, FileShare.Write)] + [Test] + [AutoArguments(FileAccess.Read, FileShare.None)] + [AutoArguments(FileAccess.Read, FileShare.Read)] + [AutoArguments(FileAccess.Read, FileShare.ReadWrite)] + [AutoArguments(FileAccess.Read, FileShare.Write)] + [AutoArguments(FileAccess.ReadWrite, FileShare.None)] + [AutoArguments(FileAccess.ReadWrite, FileShare.Read)] + [AutoArguments(FileAccess.ReadWrite, FileShare.ReadWrite)] + [AutoArguments(FileAccess.ReadWrite, FileShare.Write)] + [AutoArguments(FileAccess.Write, FileShare.None)] + [AutoArguments(FileAccess.Write, FileShare.Read)] + [AutoArguments(FileAccess.Write, FileShare.ReadWrite)] + [AutoArguments(FileAccess.Write, FileShare.Write)] public async Task MoveTo_SourceLocked_ShouldThrowIOException( FileAccess fileAccess, FileShare fileShare, @@ -274,8 +274,8 @@ void Act() } } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task MoveTo_SourceMissing_ShouldThrowFileNotFoundException( string sourceName, string destinationName) diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/OpenReadTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/OpenReadTests.cs index 7a94e9eb6..d42aec651 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/OpenReadTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/OpenReadTests.cs @@ -3,10 +3,10 @@ namespace Testably.Abstractions.Tests.FileSystem.FileInfo; [FileSystemTests] -public partial class OpenReadTests +public class OpenReadTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task OpenRead_MissingFile_ShouldThrowFileNotFoundException(string path) { IFileInfo sut = FileSystem.FileInfo.New(path); @@ -21,8 +21,8 @@ await That(Act).Throws() .WithHResult(-2147024894); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task OpenRead_ShouldUseReadAccessAndReadShare(string path) { FileSystem.File.WriteAllText(path, null); diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/OpenTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/OpenTests.cs index d712d9275..a3eefbb1a 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/OpenTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/OpenTests.cs @@ -3,11 +3,11 @@ namespace Testably.Abstractions.Tests.FileSystem.FileInfo; [FileSystemTests] -public partial class OpenTests +public class OpenTests(FileSystemTestData testData) : FileSystemTestBase(testData) { #if NETFRAMEWORK - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Open_AppendMode_ShouldThrowArgumentException(string path) { FileSystem.File.WriteAllText(path, null); @@ -23,8 +23,8 @@ void Act() #endif #if !NETFRAMEWORK - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Open_AppendMode_ShouldOpenExistingFile( string path, byte[] bytes) { @@ -39,8 +39,8 @@ public async Task Open_AppendMode_ShouldOpenExistingFile( #endif #if !NETFRAMEWORK - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Open_AppendMode_SeekShouldThrowIOException_WhenReadingBackward( string path, byte[] bytes) { @@ -62,8 +62,8 @@ void Act() #endif #if !NETFRAMEWORK - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Open_AppendMode_SeekShouldWorkWhenKeepingInNewArea( string path, byte[] bytes) { @@ -87,8 +87,8 @@ void Act() #endif #if !NETFRAMEWORK - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Open_AppendMode_ReadShouldThrowNotSupportedException( string path, byte[] bytes) { @@ -112,8 +112,8 @@ void Act() } #endif - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Open_ExistingFileWithCreateNewMode_ShouldThrowIOException( string path) { @@ -130,9 +130,9 @@ await That(Act).Throws() .WithHResult(Test.RunsOnWindows ? -2147024816 : 17); } - [Theory] - [InlineAutoData(FileMode.Open)] - [InlineAutoData(FileMode.Truncate)] + [Test] + [AutoArguments(FileMode.Open)] + [AutoArguments(FileMode.Truncate)] public async Task Open_MissingFileAndIncorrectMode_ShouldThrowFileNotFoundException( FileMode mode, string path) { @@ -148,13 +148,13 @@ await That(Act).Throws() .WithHResult(-2147024894); } - [Theory] + [Test] #if !NETFRAMEWORK - [InlineAutoData(FileMode.Append)] + [AutoArguments(FileMode.Append)] #endif - [InlineAutoData(FileMode.Create)] - [InlineAutoData(FileMode.CreateNew)] - [InlineAutoData(FileMode.OpenOrCreate)] + [AutoArguments(FileMode.Create)] + [AutoArguments(FileMode.CreateNew)] + [AutoArguments(FileMode.OpenOrCreate)] public async Task Open_MissingFileAndCorrectMode_ShouldCreateFile( FileMode mode, string path) { @@ -170,8 +170,8 @@ void Act() await That(FileSystem.File.Exists(path)).IsTrue(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Open_ShouldOpenWithReadAndWriteAccess( string path) { @@ -183,12 +183,12 @@ public async Task Open_ShouldOpenWithReadAndWriteAccess( await That(stream.CanWrite).IsTrue(); } - [Theory] + [Test] #if !NETFRAMEWORK - [InlineAutoData(FileMode.Append, FileAccess.Write)] + [AutoArguments(FileMode.Append, FileAccess.Write)] #endif - [InlineAutoData(FileMode.Open, FileAccess.ReadWrite)] - [InlineAutoData(FileMode.Create, FileAccess.ReadWrite)] + [AutoArguments(FileMode.Open, FileAccess.ReadWrite)] + [AutoArguments(FileMode.Create, FileAccess.ReadWrite)] public async Task Open_ShouldUseExpectedAccessDependingOnMode( FileMode mode, FileAccess expectedAccess, @@ -203,9 +203,9 @@ public async Task Open_ShouldUseExpectedAccessDependingOnMode( await That(FileTestHelper.CheckFileShare(FileSystem, path)).IsEqualTo(FileShare.None); } - [Theory] - [InlineAutoData(FileAccess.Read, FileShare.Write)] - [InlineAutoData(FileAccess.Write, FileShare.Read)] + [Test] + [AutoArguments(FileAccess.Read, FileShare.Write)] + [AutoArguments(FileAccess.Write, FileShare.Read)] public async Task Open_ShouldUseGivenAccessAndShare(string path, FileAccess access, FileShare share) @@ -219,8 +219,8 @@ public async Task Open_ShouldUseGivenAccessAndShare(string path, await That(FileTestHelper.CheckFileShare(FileSystem, path)).IsEqualTo(share); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Open_ShouldUseNoneShareAsDefault(string path, FileAccess access) { @@ -234,9 +234,9 @@ public async Task Open_ShouldUseNoneShareAsDefault(string path, } #if FEATURE_FILESYSTEM_STREAM_OPTIONS - [Theory] - [InlineAutoData(FileAccess.Read, FileShare.Write)] - [InlineAutoData(FileAccess.Write, FileShare.Read)] + [Test] + [AutoArguments(FileAccess.Read, FileShare.Write)] + [AutoArguments(FileAccess.Write, FileShare.Read)] public async Task Open_WithFileStreamOptions_ShouldUseGivenAccessAndShare( string path, FileAccess access, diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/OpenTextTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/OpenTextTests.cs index 9285aa589..19221eefc 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/OpenTextTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/OpenTextTests.cs @@ -3,10 +3,10 @@ namespace Testably.Abstractions.Tests.FileSystem.FileInfo; [FileSystemTests] -public partial class OpenTextTests +public class OpenTextTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task OpenText_MissingFile_ShouldThrowFileNotFoundException( string path) { @@ -22,8 +22,8 @@ await That(Act).Throws() .WithHResult(-2147024894); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task OpenText_ShouldReturnFileContent( string path, string contents) { diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/OpenWriteTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/OpenWriteTests.cs index be11d0ccb..ab1c79d9d 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/OpenWriteTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/OpenWriteTests.cs @@ -3,10 +3,10 @@ namespace Testably.Abstractions.Tests.FileSystem.FileInfo; [FileSystemTests] -public partial class OpenWriteTests +public class OpenWriteTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task OpenWrite_MissingFile_ShouldCreateFile(string path) { IFileInfo sut = FileSystem.FileInfo.New(path); @@ -16,8 +16,8 @@ public async Task OpenWrite_MissingFile_ShouldCreateFile(string path) await That(FileSystem.File.Exists(path)).IsTrue(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task OpenWrite_ShouldUseWriteAccessAndNoneShare(string path) { FileSystem.File.WriteAllText(path, null); diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/ReplaceTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/ReplaceTests.cs index cccc2fc5b..91545c995 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/ReplaceTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/ReplaceTests.cs @@ -4,10 +4,10 @@ namespace Testably.Abstractions.Tests.FileSystem.FileInfo; [FileSystemTests] -public partial class ReplaceTests +public class ReplaceTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Replace_BackupDirectoryMissing_ShouldThrowCorrectException( string sourceName, string destinationName, @@ -26,8 +26,8 @@ void Act() await That(Act).ThrowsAFileOrDirectoryNotFoundException(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Replace_DestinationDirectoryMissing_ShouldThrowDirectoryNotFoundException( string sourceName, string missingDirectory, @@ -47,8 +47,8 @@ void Act() await That(Act).ThrowsAFileOrDirectoryNotFoundException(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Replace_DestinationIsDirectory_ShouldThrowUnauthorizedAccessException( string sourceName, string destinationName, @@ -66,8 +66,8 @@ void Act() await That(Act).Throws().WithHResult(-2147024891); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Replace_DestinationMissing_ShouldThrowFileNotFoundException( string sourceName, string destinationName, @@ -85,8 +85,8 @@ void Act() await That(FileSystem.File.Exists(backupName)).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Replace_ReadOnly_WithIgnoreMetadataError_ShouldReplaceFile( string sourceName, string destinationName, @@ -111,8 +111,8 @@ public async Task Replace_ReadOnly_WithIgnoreMetadataError_ShouldReplaceFile( await That(FileSystem.File.ReadAllText(backupName)).IsEqualTo(destinationContents); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Replace_ReadOnly_WithoutIgnoreMetadataError_ShouldThrowUnauthorizedAccessException_OnWindows( string sourceName, @@ -154,9 +154,9 @@ await That(FileSystem.File.GetAttributes(destinationName)) } } - [Theory] - [InlineAutoData(FileAttributes.Hidden, FileAttributes.System)] - [InlineAutoData(FileAttributes.System, FileAttributes.Hidden)] + [Test] + [AutoArguments(FileAttributes.Hidden, FileAttributes.System)] + [AutoArguments(FileAttributes.System, FileAttributes.Hidden)] public async Task Replace_ShouldAddArchiveAttribute_OnWindows( FileAttributes sourceFileAttributes, FileAttributes destinationFileAttributes, @@ -203,8 +203,8 @@ await That(FileSystem.File.GetAttributes(backupName)) .IsEqualTo(expectedDestinationAttributes); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Replace_ShouldKeepMetadata( string sourceName, string destinationName, @@ -254,8 +254,8 @@ await That(FileSystem.File.GetLastWriteTime(backupName)) .IsEqualTo(destinationLastWriteTime); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Replace_ShouldReplaceFile( string sourceName, string destinationName, @@ -278,8 +278,8 @@ public async Task Replace_ShouldReplaceFile( await That(FileSystem.File.ReadAllText(backupName)).IsEqualTo(destinationContents); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Replace_SourceDirectoryMissing_ShouldThrowFileNotFoundException( string missingDirectory, string sourceName, @@ -297,8 +297,8 @@ void Act() await That(Act).ThrowsAFileOrDirectoryNotFoundException(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Replace_SourceIsDirectory_ShouldThrowUnauthorizedAccessException( string sourceName, string destinationName, @@ -318,19 +318,19 @@ void Act() await That(Act).Throws().WithHResult(-2147024891); } - [Theory] - [InlineAutoData(FileAccess.Read, FileShare.None)] - [InlineAutoData(FileAccess.Read, FileShare.Read)] - [InlineAutoData(FileAccess.Read, FileShare.ReadWrite)] - [InlineAutoData(FileAccess.Read, FileShare.Write)] - [InlineAutoData(FileAccess.ReadWrite, FileShare.None)] - [InlineAutoData(FileAccess.ReadWrite, FileShare.Read)] - [InlineAutoData(FileAccess.ReadWrite, FileShare.ReadWrite)] - [InlineAutoData(FileAccess.ReadWrite, FileShare.Write)] - [InlineAutoData(FileAccess.Write, FileShare.None)] - [InlineAutoData(FileAccess.Write, FileShare.Read)] - [InlineAutoData(FileAccess.Write, FileShare.ReadWrite)] - [InlineAutoData(FileAccess.Write, FileShare.Write)] + [Test] + [AutoArguments(FileAccess.Read, FileShare.None)] + [AutoArguments(FileAccess.Read, FileShare.Read)] + [AutoArguments(FileAccess.Read, FileShare.ReadWrite)] + [AutoArguments(FileAccess.Read, FileShare.Write)] + [AutoArguments(FileAccess.ReadWrite, FileShare.None)] + [AutoArguments(FileAccess.ReadWrite, FileShare.Read)] + [AutoArguments(FileAccess.ReadWrite, FileShare.ReadWrite)] + [AutoArguments(FileAccess.ReadWrite, FileShare.Write)] + [AutoArguments(FileAccess.Write, FileShare.None)] + [AutoArguments(FileAccess.Write, FileShare.Read)] + [AutoArguments(FileAccess.Write, FileShare.ReadWrite)] + [AutoArguments(FileAccess.Write, FileShare.Write)] public async Task Replace_SourceLocked_ShouldThrowIOException_OnWindows( FileAccess fileAccess, FileShare fileShare, @@ -376,8 +376,8 @@ await That(FileSystem.File.GetAttributes(destinationName)) } } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Replace_SourceMissing_ShouldThrowFileNotFoundException( string sourceName, string destinationName, @@ -399,8 +399,8 @@ void Act() } } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Replace_Twice_ShouldReplaceFile( string sourceName, string destinationName) @@ -419,8 +419,8 @@ public async Task Replace_Twice_ShouldReplaceFile( await That(file1).HasContent("def"); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Replace_WhenFileIsReadOnly_ShouldThrowUnauthorizedAccessException_OnWindows( string sourceName, string destinationName, @@ -445,8 +445,8 @@ void Act() await That(Act).Throws().WithHResult(-2147024891); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Replace_WithExistingBackupFile_ShouldIgnoreBackup( string sourceName, string destinationName, @@ -471,8 +471,8 @@ public async Task Replace_WithExistingBackupFile_ShouldIgnoreBackup( await That(FileSystem.File.ReadAllText(backupName)).IsEqualTo(backupContents); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Replace_WithoutBackup_ShouldReplaceFile( string sourceName, string destinationName, diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/ResolveLinkTargetTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/ResolveLinkTargetTests.cs index 8906232ca..8b9655593 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/ResolveLinkTargetTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/ResolveLinkTargetTests.cs @@ -5,7 +5,7 @@ namespace Testably.Abstractions.Tests.FileSystem.FileInfo; [FileSystemTests] -public partial class ResolveLinkTargetTests +public class ResolveLinkTargetTests(FileSystemTestData testData) : FileSystemTestBase(testData) { #region Test Setup @@ -17,8 +17,8 @@ public partial class ResolveLinkTargetTests #endregion - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ResolveLinkTarget_FinalTargetWithTooManyLevels_ShouldThrowIOException( string path, string pathToFinalTarget @@ -52,8 +52,8 @@ await That(Act).Throws() .WithMessageContaining($"'{fileInfo.FullName}'"); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ResolveLinkTarget_ShouldReturnNull(string path) { IFileInfo targetFile = FileSystem.FileInfo.New(path); @@ -64,8 +64,8 @@ public async Task ResolveLinkTarget_ShouldReturnNull(string path) await That(resolvedTarget).IsNull(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ResolveLinkTarget_WithChainedLink_ShouldReturnNull( string path, string pathToLink, @@ -80,8 +80,8 @@ string pathToTarget await That(resolvedTarget?.Name).IsEqualTo(innerLink.LinkTarget); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ResolveLinkTarget_ShouldReturnImmediateFile(string path, string pathToTarget) { IFileInfo targetFile = FileSystem.FileInfo.New(pathToTarget); @@ -95,8 +95,8 @@ IFileSystemInfo symbolicLink await That(resolvedTarget?.FullName).IsEqualTo(targetFile.FullName); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ResolveLinkTarget_WithChainedLink_ShouldReturnImmediateLink( string path, string pathToLink, @@ -113,8 +113,8 @@ string pathToTarget await That(resolvedTarget?.FullName).IsEqualTo(innerLink.FullName); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ResolveLinkTarget_ShouldReturnFinalFile(string path, string pathToTarget) { IFileInfo targetFile = FileSystem.FileInfo.New(pathToTarget); @@ -128,8 +128,8 @@ IFileSystemInfo symbolicLink await That(resolvedTarget?.FullName).IsEqualTo(targetFile.FullName); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ResolveLinkTarget_WithChainedLink_ShouldReturnFinalFile( string path, string pathToLink, @@ -147,8 +147,8 @@ string pathToTarget await That(resolvedTarget?.FullName).IsEqualTo(targetFile.FullName); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ResolveLinkTarget_OfDifferentTypes_ShouldThrow( string fileName, string directoryName, diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/Tests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/Tests.cs index b2fbd5013..f3e432635 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/Tests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/FileInfo/Tests.cs @@ -4,10 +4,10 @@ namespace Testably.Abstractions.Tests.FileSystem.FileInfo; [FileSystemTests] -public partial class Tests +public class Tests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Attributes_WhenFileIsMissing_SetterShouldThrowFileNotFoundException( string path) { @@ -21,8 +21,8 @@ void Act() await That(Act).Throws().WithHResult(-2147024894); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Attributes_WhenFileIsMissing_ShouldReturnMinusOne(string path) { FileAttributes expected = (FileAttributes)(-1); @@ -31,7 +31,7 @@ public async Task Attributes_WhenFileIsMissing_ShouldReturnMinusOne(string path) await That(sut.Attributes).IsEqualTo(expected); } - [Fact] + [Test] public async Task Directory_ShouldReturnParentDirectory() { IFileSystemDirectoryInitializer initialized = @@ -44,7 +44,7 @@ public async Task Directory_ShouldReturnParentDirectory() await That(file!.Directory!.FullName).IsEqualTo(initialized[0].FullName); } - [Fact] + [Test] public async Task DirectoryName_ShouldReturnNameOfParentDirectory() { IFileSystemDirectoryInitializer initialized = @@ -57,10 +57,10 @@ public async Task DirectoryName_ShouldReturnNameOfParentDirectory() await That(file!.DirectoryName).IsEqualTo(initialized[0].FullName); } - [Theory] - [InlineData("foo", "")] - [InlineData("foo.txt", ".txt")] - [InlineData("foo.bar.txt", ".txt")] + [Test] + [Arguments("foo", "")] + [Arguments("foo.txt", ".txt")] + [Arguments("foo.bar.txt", ".txt")] public async Task Extension_ShouldReturnExpectedValue(string fileName, string expectedValue) { IFileInfo sut = FileSystem.FileInfo.New(fileName); @@ -68,7 +68,7 @@ public async Task Extension_ShouldReturnExpectedValue(string fileName, string ex await That(sut.Extension).IsEqualTo(expectedValue); } - [Fact] + [Test] public async Task Extension_WithTrailingDot_ShouldReturnExpectedValue() { IFileInfo sut = FileSystem.FileInfo.New("foo."); @@ -83,8 +83,8 @@ public async Task Extension_WithTrailingDot_ShouldReturnExpectedValue() } } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task IsReadOnly_MissingFile_ShouldBeTrue(string path) { IFileInfo fileInfo = FileSystem.FileInfo.New(path); @@ -92,8 +92,8 @@ public async Task IsReadOnly_MissingFile_ShouldBeTrue(string path) await That(fileInfo.IsReadOnly).IsTrue(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task IsReadOnly_SetToFalse_ShouldRemoveReadOnlyAttribute(string path) { FileSystem.File.WriteAllText(path, null); @@ -106,8 +106,8 @@ public async Task IsReadOnly_SetToFalse_ShouldRemoveReadOnlyAttribute(string pat await That(fileInfo.Attributes).IsEqualTo(FileAttributes.Normal); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task IsReadOnly_SetToTrue_ShouldAddReadOnlyAttribute(string path) { FileSystem.File.WriteAllText(path, null); @@ -129,8 +129,8 @@ public async Task IsReadOnly_SetToTrue_ShouldAddReadOnlyAttribute(string path) await That(fileInfo.Attributes).DoesNotHaveFlag(FileAttributes.ReadOnly); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task IsReadOnly_ShouldChangeWhenSettingReadOnlyAttribute(string path) { FileSystem.File.WriteAllText(path, null); @@ -142,8 +142,8 @@ public async Task IsReadOnly_ShouldChangeWhenSettingReadOnlyAttribute(string pat await That(fileInfo.Attributes).HasFlag(FileAttributes.ReadOnly); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task IsReadOnly_ShouldInitializeToReadOnlyAttribute(string path) { FileSystem.File.WriteAllText(path, null); @@ -153,10 +153,10 @@ public async Task IsReadOnly_ShouldInitializeToReadOnlyAttribute(string path) await That(fileInfo.Attributes).DoesNotHaveFlag(FileAttributes.ReadOnly); } - [Theory] - [InlineData("/foo")] - [InlineData("./foo")] - [InlineData("foo")] + [Test] + [Arguments("/foo")] + [Arguments("./foo")] + [Arguments("foo")] public async Task ToString_ShouldReturnProvidedPath(string path) { IFileInfo fileInfo = FileSystem.FileInfo.New(path); diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/FileInfoFactory/ExceptionTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/FileInfoFactory/ExceptionTests.cs index 7436cf32f..1cb742a3b 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/FileInfoFactory/ExceptionTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/FileInfoFactory/ExceptionTests.cs @@ -5,10 +5,26 @@ namespace Testably.Abstractions.Tests.FileSystem.FileInfoFactory; [FileSystemTests] -public partial class ExceptionTests +public class ExceptionTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [MemberData(nameof(GetFileInfoFactoryCallbacks), "Illegal\tCharacter?InPath")] + public static IEnumerable<(Expression>, string, bool)> + GetFileInfoFactoryCallbacksWithEmptyPath() + => GetFileInfoFactoryCallbacks(""); + + public static IEnumerable<(Expression>, string, bool)> + GetFileInfoFactoryCallbacksWithIllegalPathCharacters() + => GetFileInfoFactoryCallbacks("Illegal\tCharacter?InPath"); + + public static IEnumerable<(Expression>, string, bool)> + GetFileInfoFactoryCallbacksWithNullPath() + => GetFileInfoFactoryCallbacks(null); + + public static IEnumerable<(Expression>, string, bool)> + GetFileInfoFactoryCallbacksWithWhitespacePath() + => GetFileInfoFactoryCallbacks(" "); + + [Test] + [MethodDataSource(nameof(GetFileInfoFactoryCallbacksWithIllegalPathCharacters))] public async Task Operations_WhenValueContainsIllegalPathCharacters_ShouldThrowArgumentException_OnNetFramework( Expression> callback, string paramName, @@ -34,8 +50,8 @@ await That(Act).DoesNotThrow() } } - [Theory] - [MemberData(nameof(GetFileInfoFactoryCallbacks), "")] + [Test] + [MethodDataSource(nameof(GetFileInfoFactoryCallbacksWithEmptyPath))] public async Task Operations_WhenValueIsEmpty_ShouldThrowArgumentException( Expression> callback, string paramName, bool ignoreParamCheck) @@ -52,8 +68,8 @@ await That(Act).Throws() $"\n{callback}\n has empty parameter for '{paramName}' (ignored: {ignoreParamCheck})"); } - [Theory] - [MemberData(nameof(GetFileInfoFactoryCallbacks), (string?)null)] + [Test] + [MethodDataSource(nameof(GetFileInfoFactoryCallbacksWithNullPath))] public async Task Operations_WhenValueIsNull_ShouldThrowArgumentNullException( Expression> callback, string paramName, bool ignoreParamCheck) @@ -69,8 +85,8 @@ await That(Act).Throws() $"\n{callback}\n has `null` parameter for '{paramName}' (ignored: {ignoreParamCheck})"); } - [Theory] - [MemberData(nameof(GetFileInfoFactoryCallbacks), " ")] + [Test] + [MethodDataSource(nameof(GetFileInfoFactoryCallbacksWithWhitespacePath))] public async Task Operations_WhenValueIsWhitespace_ShouldThrowArgumentException( Expression> callback, string paramName, bool ignoreParamCheck) @@ -92,23 +108,20 @@ await That(Act).Throws() #region Helpers #pragma warning disable MA0018 - public static TheoryData>, string, bool> + private static IEnumerable<(Expression>, string, bool)> GetFileInfoFactoryCallbacks(string? path) { - TheoryData>, string, bool> theoryData = new(); foreach ((ExceptionTestHelper.TestTypes TestType, string ParamName, Expression> Callback) item in GetFileInfoFactoryCallbackTestParameters(path!) .Where(item => item.TestType.HasFlag(path.ToTestType()))) { - theoryData.Add( + yield return ( item.Callback, item.ParamName, item.TestType.HasFlag(ExceptionTestHelper.TestTypes.IgnoreParamNameCheck)); } - - return theoryData; } #pragma warning restore MA0018 diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/FileInfoFactory/Tests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/FileInfoFactory/Tests.cs index fdf7a4c02..723904181 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/FileInfoFactory/Tests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/FileInfoFactory/Tests.cs @@ -3,11 +3,11 @@ namespace Testably.Abstractions.Tests.FileSystem.FileInfoFactory; [FileSystemTests] -public partial class Tests +public class Tests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [InlineData(259)] - [InlineData(260)] + [Test] + [Arguments(259)] + [Arguments(260)] public async Task New_PathTooLong_ShouldThrowPathTooLongException_OnNetFramework( int maxLength) { @@ -29,8 +29,8 @@ void Act() } } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task New_ShouldCreateNewFileInfoFromPath(string path) { IFileInfo result = FileSystem.FileInfo.New(path); @@ -39,8 +39,8 @@ public async Task New_ShouldCreateNewFileInfoFromPath(string path) await That(result.Exists).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task New_ShouldOpenWithExistingContent(string path, string contents) { FileSystem.File.WriteAllText(path, contents); @@ -52,8 +52,8 @@ public async Task New_ShouldOpenWithExistingContent(string path, string contents await That(result).IsEqualTo(contents); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task New_ShouldSetLength(string path, byte[] bytes) { FileSystem.File.WriteAllBytes(path, bytes); @@ -69,8 +69,8 @@ public async Task New_ShouldSetLength(string path, byte[] bytes) await That(result).IsEqualTo(bytes.Length); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task New_WithTrailingDirectorySeparatorChar_ShouldHaveEmptyName(string path) { IFileInfo result = @@ -79,7 +79,7 @@ public async Task New_WithTrailingDirectorySeparatorChar_ShouldHaveEmptyName(str await That(result.Name).IsEqualTo(string.Empty); } - [Fact] + [Test] public async Task New_WithUnicodeWhitespace_ShouldNotThrow() { void Act() @@ -97,7 +97,7 @@ void Act() } } - [Fact] + [Test] public async Task New_WithWhitespace_ShouldThrowOnlyOnWindows() { void Act() @@ -115,7 +115,7 @@ void Act() } } - [Fact] + [Test] public async Task Wrap_Null_ShouldReturnNull() { Skip.If(FileSystem is MockFileSystem mockFileSystem && @@ -126,8 +126,8 @@ public async Task Wrap_Null_ShouldReturnNull() await That(result).IsNull(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Wrap_ShouldWrapFromFileInfo(string path) { Skip.If(FileSystem is MockFileSystem mockFileSystem && @@ -141,8 +141,8 @@ public async Task Wrap_ShouldWrapFromFileInfo(string path) await That(result.Exists).IsEqualTo(fileInfo.Exists); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Wrap_WithSimulatedMockFileSystem_ShouldThrowNotSupportedException(string path) { Skip.IfNot(FileSystem is MockFileSystem mockFileSystem && diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/FileStream/AdjustTimesTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/FileStream/AdjustTimesTests.cs index e64cb22e1..1171a077a 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/FileStream/AdjustTimesTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/FileStream/AdjustTimesTests.cs @@ -6,10 +6,10 @@ namespace Testably.Abstractions.Tests.FileSystem.FileStream; [FileSystemTests] -public partial class AdjustTimesTests +public class AdjustTimesTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CopyTo_ShouldAdjustTimes(string path, byte[] bytes) { Skip.If(Test.IsNetFramework && FileSystem is RealFileSystem, @@ -50,8 +50,8 @@ await That(lastWriteTime).IsBetween(creationTimeStart).And(creationTimeEnd) } #if FEATURE_SPAN - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Read_AsSpan_ShouldAdjustTimes(string path, byte[] bytes) { SkipIfLongRunningTestsShouldBeSkipped(); @@ -85,8 +85,8 @@ public async Task Read_AsSpan_ShouldAdjustTimes(string path, byte[] bytes) } #endif - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Read_ShouldAdjustTimes(string path, byte[] bytes) { Skip.If(Test.IsNetFramework && FileSystem is RealFileSystem, @@ -125,21 +125,21 @@ await That(lastWriteTime).IsBetween(creationTimeStart).And(creationTimeEnd) } #if FEATURE_SPAN - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ReadAsync_AsMemory_ShouldAdjustTimes(string path, byte[] bytes) { SkipIfLongRunningTestsShouldBeSkipped(); byte[] buffer = new byte[2]; DateTime creationTimeStart = TimeSystem.DateTime.UtcNow; - await FileSystem.File.WriteAllBytesAsync(path, bytes, TestContext.Current.CancellationToken); + await FileSystem.File.WriteAllBytesAsync(path, bytes, CancellationToken); DateTime creationTimeEnd = TimeSystem.DateTime.UtcNow; - await TimeSystem.Task.Delay(FileTestHelper.AdjustTimesDelay, TestContext.Current.CancellationToken); + await TimeSystem.Task.Delay(FileTestHelper.AdjustTimesDelay, CancellationToken); DateTime updateTime = TimeSystem.DateTime.UtcNow; await using FileSystemStream stream = FileSystem.File.OpenRead(path); - _ = await stream.ReadAsync(buffer.AsMemory(), TestContext.Current.CancellationToken); + _ = await stream.ReadAsync(buffer.AsMemory(), CancellationToken); DateTime lastAccessTime = WaitToBeUpdatedToAfter( () => FileSystem.File.GetLastAccessTimeUtc(path), updateTime); @@ -161,8 +161,8 @@ public async Task ReadAsync_AsMemory_ShouldAdjustTimes(string path, byte[] bytes #endif #if FEATURE_FILESYSTEM_ASYNC - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ReadAsync_ShouldAdjustTimes(string path, byte[] bytes) { Skip.If(Test.IsNetFramework && FileSystem is RealFileSystem, @@ -171,14 +171,14 @@ public async Task ReadAsync_ShouldAdjustTimes(string path, byte[] bytes) byte[] buffer = new byte[2]; DateTime creationTimeStart = TimeSystem.DateTime.UtcNow; - await FileSystem.File.WriteAllBytesAsync(path, bytes, TestContext.Current.CancellationToken); + await FileSystem.File.WriteAllBytesAsync(path, bytes, CancellationToken); DateTime creationTimeEnd = TimeSystem.DateTime.UtcNow; - await TimeSystem.Task.Delay(FileTestHelper.AdjustTimesDelay, TestContext.Current.CancellationToken); + await TimeSystem.Task.Delay(FileTestHelper.AdjustTimesDelay, CancellationToken); DateTime updateTime = TimeSystem.DateTime.UtcNow; await using FileSystemStream stream = FileSystem.File.OpenRead(path); #pragma warning disable CA1835 - _ = await stream.ReadAsync(buffer, 0, 2, TestContext.Current.CancellationToken); + _ = await stream.ReadAsync(buffer, 0, 2, CancellationToken); #pragma warning restore CA1835 DateTime lastAccessTime = WaitToBeUpdatedToAfter( @@ -200,8 +200,8 @@ public async Task ReadAsync_ShouldAdjustTimes(string path, byte[] bytes) } #endif - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ReadByte_ShouldAdjustTimes(string path, byte[] bytes) { Skip.If(Test.IsNetFramework && FileSystem is RealFileSystem, @@ -238,8 +238,8 @@ await That(lastWriteTime).IsBetween(creationTimeStart).And(creationTimeEnd) .Within(TimeComparison.Tolerance); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Seek_ShouldNotAdjustTimes(string path, byte[] bytes) { Skip.If(Test.IsNetFramework && FileSystem is RealFileSystem, @@ -271,8 +271,8 @@ await That(lastWriteTime).IsBetween(creationTimeStart).And(creationTimeEnd) } #if FEATURE_SPAN - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Write_AsSpan_ShouldAdjustTimes(string path, byte[] bytes) { SkipIfLongRunningTestsShouldBeSkipped(); @@ -307,8 +307,8 @@ public async Task Write_AsSpan_ShouldAdjustTimes(string path, byte[] bytes) } #endif - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Write_ShouldAdjustTimes(string path, byte[] bytes) { Skip.If(Test.IsNetFramework && FileSystem is RealFileSystem, @@ -347,21 +347,21 @@ await That(lastAccessTime).IsBetween(creationTimeStart).And(creationTimeEnd) } #if FEATURE_SPAN - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAsync_AsMemory_ShouldAdjustTimes(string path, byte[] bytes) { SkipIfLongRunningTestsShouldBeSkipped(); DateTime creationTimeStart = TimeSystem.DateTime.UtcNow; - await FileSystem.File.WriteAllBytesAsync(path, Array.Empty(), TestContext.Current.CancellationToken); + await FileSystem.File.WriteAllBytesAsync(path, Array.Empty(), CancellationToken); DateTime creationTimeEnd = TimeSystem.DateTime.UtcNow; - await TimeSystem.Task.Delay(FileTestHelper.AdjustTimesDelay, TestContext.Current.CancellationToken); + await TimeSystem.Task.Delay(FileTestHelper.AdjustTimesDelay, CancellationToken); DateTime updateTime = TimeSystem.DateTime.UtcNow; await using (FileSystemStream stream = FileSystem.File.OpenWrite(path)) { - await stream.WriteAsync(bytes.AsMemory(), TestContext.Current.CancellationToken); + await stream.WriteAsync(bytes.AsMemory(), CancellationToken); } DateTime lastWriteTime = WaitToBeUpdatedToAfter( @@ -384,8 +384,8 @@ public async Task WriteAsync_AsMemory_ShouldAdjustTimes(string path, byte[] byte #endif #if FEATURE_FILESYSTEM_ASYNC - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAsync_ShouldAdjustTimes(string path, byte[] bytes) { Skip.If(Test.IsNetFramework && FileSystem is RealFileSystem, @@ -393,15 +393,15 @@ public async Task WriteAsync_ShouldAdjustTimes(string path, byte[] bytes) SkipIfLongRunningTestsShouldBeSkipped(); DateTime creationTimeStart = TimeSystem.DateTime.UtcNow; - await FileSystem.File.WriteAllBytesAsync(path, Array.Empty(), TestContext.Current.CancellationToken); + await FileSystem.File.WriteAllBytesAsync(path, Array.Empty(), CancellationToken); DateTime creationTimeEnd = TimeSystem.DateTime.UtcNow; - await TimeSystem.Task.Delay(FileTestHelper.AdjustTimesDelay, TestContext.Current.CancellationToken); + await TimeSystem.Task.Delay(FileTestHelper.AdjustTimesDelay, CancellationToken); DateTime updateTime = TimeSystem.DateTime.UtcNow; await using (FileSystemStream stream = FileSystem.File.OpenWrite(path)) { #pragma warning disable CA1835 - await stream.WriteAsync(bytes, 0, 2, TestContext.Current.CancellationToken); + await stream.WriteAsync(bytes, 0, 2, CancellationToken); #pragma warning restore CA1835 } @@ -424,8 +424,8 @@ public async Task WriteAsync_ShouldAdjustTimes(string path, byte[] bytes) } #endif - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteByte_ShouldAdjustTimes(string path, byte[] bytes, byte singleByte) { Skip.If(Test.IsNetFramework && FileSystem is RealFileSystem, diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/FileStream/CopyToTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/FileStream/CopyToTests.cs index ec13bc1e0..56c05c0e0 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/FileStream/CopyToTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/FileStream/CopyToTests.cs @@ -5,10 +5,10 @@ namespace Testably.Abstractions.Tests.FileSystem.FileStream; [FileSystemTests] -public partial class CopyToTests +public class CopyToTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CopyTo_BufferSizeZero_ShouldThrowArgumentOutOfRangeException( string path, byte[] bytes) { @@ -25,8 +25,8 @@ void Act() await That(Act).Throws().WithParamName("bufferSize"); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CopyTo_ShouldCopyBytes( string path, byte[] bytes) { @@ -42,19 +42,19 @@ public async Task CopyTo_ShouldCopyBytes( } #if FEATURE_FILESYSTEM_ASYNC - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CopyToAsync_BufferSizeZero_ShouldThrowArgumentOutOfRangeException( string path, byte[] bytes) { byte[] buffer = new byte[bytes.Length]; - await FileSystem.File.WriteAllBytesAsync(path, bytes, TestContext.Current.CancellationToken); + await FileSystem.File.WriteAllBytesAsync(path, bytes, CancellationToken); async Task Act() { await using FileSystemStream stream = FileSystem.File.OpenRead(path); using MemoryStream destination = new(buffer); - await stream.CopyToAsync(destination, 0, TestContext.Current.CancellationToken); + await stream.CopyToAsync(destination, 0, CancellationToken); } await That(Act).Throws().WithParamName("bufferSize"); @@ -62,38 +62,38 @@ async Task Act() #endif #if FEATURE_FILESYSTEM_ASYNC - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CopyToAsync_ShouldCopyBytes( string path, byte[] bytes) { byte[] buffer = new byte[bytes.Length]; - await FileSystem.File.WriteAllBytesAsync(path, bytes, TestContext.Current.CancellationToken); + await FileSystem.File.WriteAllBytesAsync(path, bytes, CancellationToken); await using FileSystemStream stream = FileSystem.File.OpenRead(path); using MemoryStream destination = new(buffer); - await stream.CopyToAsync(destination, TestContext.Current.CancellationToken); + await stream.CopyToAsync(destination, CancellationToken); - await destination.FlushAsync(TestContext.Current.CancellationToken); + await destination.FlushAsync(CancellationToken); await That(buffer).IsEqualTo(bytes).InAnyOrder(); } #endif #if FEATURE_FILESYSTEM_ASYNC - [Theory] - [InlineData(0)] - [InlineData(-1)] + [Test] + [Arguments(0)] + [Arguments(-1)] public async Task CopyToAsync_WhenBufferSizeIsNotPositive_ShouldThrowArgumentNullException( int bufferSize) { - await FileSystem.File.WriteAllTextAsync("foo.txt", "", TestContext.Current.CancellationToken); - await FileSystem.File.WriteAllTextAsync("bar.txt", "", TestContext.Current.CancellationToken); + await FileSystem.File.WriteAllTextAsync("foo.txt", "", CancellationToken); + await FileSystem.File.WriteAllTextAsync("bar.txt", "", CancellationToken); await using FileSystemStream source = FileSystem.FileInfo.New("foo.txt").OpenRead(); await using FileSystemStream destination = FileSystem.FileInfo.New("bar.txt").OpenWrite(); async Task Act() { - await source.CopyToAsync(destination, bufferSize, TestContext.Current.CancellationToken); + await source.CopyToAsync(destination, bufferSize, CancellationToken); } await That(Act).ThrowsExactly(); @@ -101,17 +101,17 @@ async Task Act() #endif #if FEATURE_FILESYSTEM_ASYNC - [Fact] + [Test] public async Task CopyToAsync_WhenDestinationIsClosed_ShouldThrowObjectDisposedException() { - await FileSystem.File.WriteAllTextAsync("foo.txt", "", TestContext.Current.CancellationToken); + await FileSystem.File.WriteAllTextAsync("foo.txt", "", CancellationToken); await using FileSystemStream source = FileSystem.FileInfo.New("foo.txt").OpenRead(); using MemoryStream destination = new(); destination.Close(); async Task Act() { - await source.CopyToAsync(destination, TestContext.Current.CancellationToken); + await source.CopyToAsync(destination, CancellationToken); } await That(Act).ThrowsExactly().WithMessage("Cannot access a*").AsWildcard(); @@ -119,15 +119,15 @@ async Task Act() #endif #if FEATURE_FILESYSTEM_ASYNC - [Fact] + [Test] public async Task CopyToAsync_WhenDestinationIsNull_ShouldThrowArgumentNullException() { - await FileSystem.File.WriteAllTextAsync("foo.txt", "", TestContext.Current.CancellationToken); + await FileSystem.File.WriteAllTextAsync("foo.txt", "", CancellationToken); await using FileSystemStream source = FileSystem.FileInfo.New("foo.txt").OpenRead(); async Task Act() { - await source.CopyToAsync(null!, TestContext.Current.CancellationToken); + await source.CopyToAsync(null!, CancellationToken); } await That(Act).ThrowsExactly().WithMessage("*cannot be null*").AsWildcard(); @@ -135,17 +135,17 @@ async Task Act() #endif #if FEATURE_FILESYSTEM_ASYNC - [Fact] + [Test] public async Task CopyToAsync_WhenDestinationIsReadOnly_ShouldThrowNotSupportedException() { - await FileSystem.File.WriteAllTextAsync("foo.txt", "", TestContext.Current.CancellationToken); - await FileSystem.File.WriteAllTextAsync("bar.txt", "", TestContext.Current.CancellationToken); + await FileSystem.File.WriteAllTextAsync("foo.txt", "", CancellationToken); + await FileSystem.File.WriteAllTextAsync("bar.txt", "", CancellationToken); await using FileSystemStream source = FileSystem.FileInfo.New("foo.txt").OpenRead(); await using FileSystemStream destination = FileSystem.FileInfo.New("bar.txt").OpenRead(); async Task Act() { - await source.CopyToAsync(destination, TestContext.Current.CancellationToken); + await source.CopyToAsync(destination, CancellationToken); } await That(Act).ThrowsExactly().WithMessage("Stream does not support writing*").AsWildcard(); @@ -153,18 +153,18 @@ async Task Act() #endif #if FEATURE_FILESYSTEM_ASYNC - [Fact] + [Test] public async Task CopyToAsync_WhenSourceIsClosed_ShouldThrowObjectDisposedException() { - await FileSystem.File.WriteAllTextAsync("foo.txt", "", TestContext.Current.CancellationToken); - await FileSystem.File.WriteAllTextAsync("bar.txt", "", TestContext.Current.CancellationToken); + await FileSystem.File.WriteAllTextAsync("foo.txt", "", CancellationToken); + await FileSystem.File.WriteAllTextAsync("bar.txt", "", CancellationToken); await using FileSystemStream source = FileSystem.FileInfo.New("foo.txt").OpenRead(); await using FileSystemStream destination = FileSystem.FileInfo.New("bar.txt").OpenWrite(); source.Close(); async Task Act() { - await source.CopyToAsync(destination, TestContext.Current.CancellationToken); + await source.CopyToAsync(destination, CancellationToken); } await That(Act).ThrowsExactly().WithMessage("Cannot access a*").AsWildcard(); @@ -172,17 +172,17 @@ async Task Act() #endif #if FEATURE_FILESYSTEM_ASYNC - [Fact] + [Test] public async Task CopyToAsync_WhenSourceIsWriteOnly_ShouldThrowNotSupportedException() { - await FileSystem.File.WriteAllTextAsync("foo.txt", "", TestContext.Current.CancellationToken); - await FileSystem.File.WriteAllTextAsync("bar.txt", "", TestContext.Current.CancellationToken); + await FileSystem.File.WriteAllTextAsync("foo.txt", "", CancellationToken); + await FileSystem.File.WriteAllTextAsync("bar.txt", "", CancellationToken); await using FileSystemStream source = FileSystem.FileInfo.New("foo.txt").OpenWrite(); await using FileSystemStream destination = FileSystem.FileInfo.New("bar.txt").OpenWrite(); async Task Act() { - await source.CopyToAsync(destination, TestContext.Current.CancellationToken); + await source.CopyToAsync(destination, CancellationToken); } await That(Act).ThrowsExactly().WithMessage("Stream does not support reading*").AsWildcard(); diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/FileStream/DisposeTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/FileStream/DisposeTests.cs index c945ea2bd..785ca4d1e 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/FileStream/DisposeTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/FileStream/DisposeTests.cs @@ -6,10 +6,10 @@ namespace Testably.Abstractions.Tests.FileSystem.FileStream; [FileSystemTests] -public partial class DisposeTests +public class DisposeTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Dispose_CalledTwiceShouldDoNothing( string path, byte[] bytes) { @@ -29,8 +29,8 @@ public async Task Dispose_CalledTwiceShouldDoNothing( await That(FileSystem.File.Exists(path)).IsTrue(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Dispose_ShouldNotResurrectFile(string path, string contents) { FileSystem.File.WriteAllText(path, contents); @@ -50,8 +50,8 @@ public async Task Dispose_ShouldNotResurrectFile(string path, string contents) await That(fileCount3).IsEqualTo(0).Because("Dispose should not have resurrected the file"); } - [Theory] - [MemberData(nameof(GetFileStreamCallbacks))] + [Test] + [MethodDataSource(nameof(GetFileStreamCallbacks))] public async Task Operations_ShouldThrowAfterStreamIsDisposed( Expression> callback) { @@ -71,13 +71,8 @@ await That(Act).ThrowsExactly() #region Helpers - #pragma warning disable MA0018 - public static TheoryData>> GetFileStreamCallbacks() - => new(GetFileStreamCallbackTestParameters()); - #pragma warning restore MA0018 - - private static IEnumerable>> - GetFileStreamCallbackTestParameters() + public static IEnumerable>> + GetFileStreamCallbacks() { yield return fileStream => fileStream.BeginRead(Array.Empty(), 0, 0, null, null); yield return fileStream => fileStream.BeginWrite(Array.Empty(), 0, 0, null, null); @@ -95,14 +90,14 @@ private static IEnumerable>> #pragma warning restore CA2022 #pragma warning restore MA0060 yield return fileStream => fileStream - .ReadAsync(Array.Empty(), 0, 0, TestContext.Current.CancellationToken) + .ReadAsync(Array.Empty(), 0, 0, CancellationToken.None) .GetAwaiter().GetResult(); yield return fileStream => fileStream.ReadByte(); yield return fileStream => fileStream.Seek(0, SeekOrigin.Begin); yield return fileStream => fileStream.SetLength(0); yield return fileStream => fileStream.Write(Array.Empty(), 0, 0); yield return fileStream => fileStream - .WriteAsync(Array.Empty(), 0, 0, TestContext.Current.CancellationToken) + .WriteAsync(Array.Empty(), 0, 0, CancellationToken.None) .GetAwaiter().GetResult(); yield return fileStream => fileStream.WriteByte(0x42); } diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/FileStream/FileAccessTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/FileStream/FileAccessTests.cs index 73520424c..97da69f63 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/FileStream/FileAccessTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/FileStream/FileAccessTests.cs @@ -5,18 +5,18 @@ namespace Testably.Abstractions.Tests.FileSystem.FileStream; [FileSystemTests] -public partial class FileAccessTests +public class FileAccessTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [InlineAutoData(FileAccess.Read, FileShare.Read, + [Test] + [AutoArguments(FileAccess.Read, FileShare.Read, FileAccess.ReadWrite, FileShare.Read)] - [InlineAutoData(FileAccess.ReadWrite, FileShare.Read, + [AutoArguments(FileAccess.ReadWrite, FileShare.Read, FileAccess.Read, FileShare.Read)] - [InlineAutoData(FileAccess.ReadWrite, FileShare.ReadWrite, + [AutoArguments(FileAccess.ReadWrite, FileShare.ReadWrite, FileAccess.ReadWrite, FileShare.Read)] - [InlineAutoData(FileAccess.ReadWrite, FileShare.ReadWrite, + [AutoArguments(FileAccess.ReadWrite, FileShare.ReadWrite, FileAccess.ReadWrite, FileShare.Write)] - [InlineAutoData(FileAccess.Read, FileShare.Read, + [AutoArguments(FileAccess.Read, FileShare.Read, FileAccess.ReadWrite, FileShare.ReadWrite)] public async Task FileAccess_ConcurrentAccessWithInvalidScenarios_ShouldThrowIOException( FileAccess access1, FileShare share1, @@ -49,9 +49,9 @@ await That(Act).Throws() } } - [Theory] - [InlineAutoData(FileAccess.Read, FileShare.Read, FileAccess.Read, FileShare.Read)] - [InlineAutoData(FileAccess.Read, FileShare.ReadWrite, FileAccess.ReadWrite, + [Test] + [AutoArguments(FileAccess.Read, FileShare.Read, FileAccess.Read, FileShare.Read)] + [AutoArguments(FileAccess.Read, FileShare.ReadWrite, FileAccess.ReadWrite, FileShare.Read)] public async Task FileAccess_ConcurrentReadAccessWithValidScenarios_ShouldNotThrowException( FileAccess access1, FileShare share1, @@ -74,9 +74,9 @@ public async Task FileAccess_ConcurrentReadAccessWithValidScenarios_ShouldNotThr await That(result2).IsEqualTo(contents); } - [Theory] - [InlineAutoData(FileAccess.Write, FileShare.Write, FileAccess.Write, FileShare.Write)] - [InlineAutoData(FileAccess.ReadWrite, FileShare.ReadWrite, FileAccess.ReadWrite, + [Test] + [AutoArguments(FileAccess.Write, FileShare.Write, FileAccess.Write, FileShare.Write)] + [AutoArguments(FileAccess.ReadWrite, FileShare.ReadWrite, FileAccess.ReadWrite, FileShare.ReadWrite)] public async Task FileAccess_ConcurrentWriteAccessWithValidScenarios_ShouldNotThrowException( FileAccess access1, FileShare share1, @@ -104,8 +104,8 @@ public async Task FileAccess_ConcurrentWriteAccessWithValidScenarios_ShouldNotTh await That(result).IsEqualTo(contents2); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task FileAccess_ReadAfterFirstAppend_ShouldContainBothContents( string path, string contents1, string contents2) { @@ -130,8 +130,8 @@ public async Task FileAccess_ReadAfterFirstAppend_ShouldContainBothContents( await That(result).IsEqualTo(contents1 + contents2); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task FileAccess_ReadBeforeFirstAppend_ShouldOnlyContainSecondContent( string path, string contents1, string contents2) { @@ -156,8 +156,8 @@ public async Task FileAccess_ReadBeforeFirstAppend_ShouldOnlyContainSecondConten await That(result).IsEqualTo(contents2); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task FileAccess_ReadWhileWriteLockActive_ShouldThrowIOException( string path, string contents) { @@ -183,8 +183,8 @@ await That(Act).Throws() } } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task MultipleParallelReads_ShouldBeAllowed(string path, string contents) { FileSystem.File.WriteAllText(path, contents); @@ -200,15 +200,15 @@ public async Task MultipleParallelReads_ShouldBeAllowed(string path, string cont while (!wait.IsCompleted) { - await Task.Delay(10, TestContext.Current.CancellationToken); + await Task.Delay(10, CancellationToken); } await That(results).HasCount(100); await That(results).All().AreEqualTo(contents); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Read_ShouldCreateValidFileStream(string path, string contents) { FileSystem.File.WriteAllText(path, contents, Encoding.UTF8); @@ -219,8 +219,8 @@ public async Task Read_ShouldCreateValidFileStream(string path, string contents) await That(result).IsEqualTo(contents); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Write_ShouldCreateValidFileStream(string path, string contents) { FileSystemStream stream = FileSystem.FileStream.New(path, FileMode.CreateNew); diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/FileStream/OptionsTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/FileStream/OptionsTests.cs index 62fe60f9e..57b45c787 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/FileStream/OptionsTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/FileStream/OptionsTests.cs @@ -4,10 +4,10 @@ namespace Testably.Abstractions.Tests.FileSystem.FileStream; [FileSystemTests] -public partial class OptionsTests +public class OptionsTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Options_DeleteOnClose_ShouldDeleteFileOnClose( string path, string contents) { @@ -22,8 +22,8 @@ public async Task Options_DeleteOnClose_ShouldDeleteFileOnClose( await That(FileSystem.File.Exists(path)).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Options_DeleteOnClose_ShouldDeleteFileOnDispose( string path, string contents) { @@ -38,8 +38,8 @@ public async Task Options_DeleteOnClose_ShouldDeleteFileOnDispose( await That(FileSystem.File.Exists(path)).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] [SupportedOSPlatform("windows")] public async Task Options_Encrypt_ShouldKeepEncryptionFlag( string path, string contents1, string contents2) @@ -63,8 +63,8 @@ public async Task Options_Encrypt_ShouldKeepEncryptionFlag( await That(FileSystem.File.GetAttributes(path)).HasFlag(FileAttributes.Encrypted); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Options_Encrypt_Unencrypted_ShouldBeIgnored( string path, string contents1, string contents2) { @@ -81,8 +81,8 @@ public async Task Options_Encrypt_Unencrypted_ShouldBeIgnored( await That(FileSystem.File.ReadAllText(path)).IsEqualTo(contents2); } - [Theory] - [AutoData] + [Test] + [AutoArguments] [SupportedOSPlatform("windows")] public async Task Options_EncryptedWithoutEncryptionOption_ShouldKeepEncryptionFlag( string path, string contents1, string contents2) diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/FileStream/ParallelTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/FileStream/ParallelTests.cs index 07891aade..7b07bef29 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/FileStream/ParallelTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/FileStream/ParallelTests.cs @@ -4,10 +4,10 @@ namespace Testably.Abstractions.Tests.FileSystem.FileStream; [FileSystemTests] -public partial class ParallelTests +public class ParallelTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task MultipleFlush_DifferentLength_ShouldKeepAdditionalBytes(string path) { using (FileSystemStream stream1 = FileSystem.File.Open(path, FileMode.OpenOrCreate, @@ -36,8 +36,8 @@ public async Task MultipleFlush_DifferentLength_ShouldKeepAdditionalBytes(string await That(FileSystem.File.ReadAllText(path)).IsEqualTo("foofoo"); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task MultipleFlush_DifferentPosition_ShouldKeepAdditionalBytes(string path) { FileSystem.File.WriteAllText(path, "AAAAAAAAAAAA"); @@ -59,8 +59,8 @@ public async Task MultipleFlush_DifferentPosition_ShouldKeepAdditionalBytes(stri await That(FileSystem.File.ReadAllText(path)).IsEqualTo("AAbCCCbbAAAA"); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task MultipleFlush_DifferentPositionWithGaps_ShouldKeepAdditionalBytes(string path) { FileSystem.File.WriteAllText(path, "AAAAAAAAAAAA"); @@ -84,8 +84,8 @@ public async Task MultipleFlush_DifferentPositionWithGaps_ShouldKeepAdditionalBy await That(FileSystem.File.ReadAllText(path)).IsEqualTo("AAbbbCbbAAAA"); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task MultipleFlush_ShouldKeepLatestChanges(string path) { using (FileSystemStream stream1 = FileSystem.File.Open(path, FileMode.OpenOrCreate, @@ -104,8 +104,8 @@ public async Task MultipleFlush_ShouldKeepLatestChanges(string path) await That(FileSystem.File.ReadAllText(path)).IsEqualTo("foo"); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteEmpty_ShouldNotOverwrite(string path) { using (FileSystemStream stream1 = FileSystem.File.Open(path, FileMode.OpenOrCreate, diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/FileStream/ReadTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/FileStream/ReadTests.cs index df3527880..47ae44ec4 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/FileStream/ReadTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/FileStream/ReadTests.cs @@ -10,10 +10,10 @@ namespace Testably.Abstractions.Tests.FileSystem.FileStream; [FileSystemTests] -public partial class ReadTests +public class ReadTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task BeginRead_CanReadFalse_ShouldThrowNotSupportedException( string path, byte[] bytes) { @@ -31,8 +31,8 @@ void Act() await That(Act).Throws().WithHResult(-2146233067); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task BeginRead_ShouldCopyContentsToBuffer( string path, byte[] bytes) { @@ -56,12 +56,12 @@ public async Task BeginRead_ShouldCopyContentsToBuffer( } }, null); - await That(ms.Wait(ExpectSuccess, TestContext.Current.CancellationToken)).IsTrue(); + await That(ms.Wait(ExpectSuccess, CancellationToken)).IsTrue(); await That(buffer).IsEqualTo(bytes).InAnyOrder(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task EndRead_Null_ShouldThrowArgumentNullException( string path, byte[] bytes) { @@ -77,8 +77,8 @@ void Act() await That(Act).Throws().WithHResult(-2147467261); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task EndRead_ShouldNotAdjustTimes(string path, byte[] bytes) { SkipIfBrittleTestsShouldBeSkipped(Test.RunsOnMac); @@ -107,7 +107,7 @@ public async Task EndRead_ShouldNotAdjustTimes(string path, byte[] bytes) } }, null); - await That(ms.Wait(ExpectSuccess, TestContext.Current.CancellationToken)).IsTrue(); + await That(ms.Wait(ExpectSuccess, CancellationToken)).IsTrue(); } DateTime creationTime = FileSystem.File.GetCreationTimeUtc(path); @@ -123,8 +123,8 @@ await That(lastWriteTime).IsBetween(creationTimeStart).And(creationTimeEnd) } #if FEATURE_SPAN - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Read_AsSpan_CanReadFalse_ShouldThrowNotSupportedException( string path, byte[] bytes) { @@ -144,8 +144,8 @@ void Act() #endif #if FEATURE_SPAN - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Read_AsSpan_ShouldFillBuffer(string path, byte[] bytes) { byte[] buffer = new byte[bytes.Length]; @@ -160,8 +160,8 @@ public async Task Read_AsSpan_ShouldFillBuffer(string path, byte[] bytes) #endif #if FEATURE_SPAN - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Read_AsSpan_ShouldUseSharedBuffer(string path) { List results = []; @@ -187,8 +187,8 @@ public async Task Read_AsSpan_ShouldUseSharedBuffer(string path) } #endif - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Read_CanReadFalse_ShouldThrowNotSupportedException( string path, byte[] bytes) { @@ -206,8 +206,8 @@ void Act() await That(Act).Throws().WithHResult(-2146233067); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Read_ShouldFillBuffer(string path, byte[] bytes) { byte[] buffer = new byte[bytes.Length]; @@ -221,8 +221,8 @@ public async Task Read_ShouldFillBuffer(string path, byte[] bytes) } #if FEATURE_FILESYSTEM_ASYNC - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ReadAsync_CanReadFalse_ShouldThrowNotSupportedException( string path, byte[] bytes) { @@ -246,8 +246,8 @@ async Task Act() #endif #if FEATURE_FILESYSTEM_ASYNC - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ReadAsync_Memory_CanReadFalse_ShouldThrowNotSupportedException( string path, byte[] bytes) { @@ -271,8 +271,8 @@ async Task Act() #endif #if FEATURE_FILESYSTEM_ASYNC - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ReadAsync_ShouldFillBuffer(string path, byte[] bytes) { using CancellationTokenSource cts = new(ExpectSuccess); @@ -289,8 +289,8 @@ public async Task ReadAsync_ShouldFillBuffer(string path, byte[] bytes) } #endif - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ReadByte_CanReadFalse_ShouldThrowNotSupportedException( string path, byte[] bytes) { @@ -307,8 +307,8 @@ void Act() await That(Act).Throws().WithHResult(-2146233067); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ReadByte_ShouldReadSingleByteAndAdvancePosition( string path, byte[] bytes) { @@ -324,8 +324,8 @@ public async Task ReadByte_ShouldReadSingleByteAndAdvancePosition( await That(result2).IsEqualTo(bytes[1]); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ReadTimeout_ShouldThrowInvalidOperationException( string path, string contents) { diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/FileStream/Tests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/FileStream/Tests.cs index 63eb18719..bfc6a097e 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/FileStream/Tests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/FileStream/Tests.cs @@ -8,10 +8,10 @@ namespace Testably.Abstractions.Tests.FileSystem.FileStream; [FileSystemTests] -public partial class Tests +public class Tests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CanSeek_ShouldReturnTrue( string path, string contents) { @@ -22,8 +22,8 @@ public async Task CanSeek_ShouldReturnTrue( await That(stream.CanSeek).IsTrue(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CanTimeout_ShouldReturnFalse( string path, string contents) { @@ -34,8 +34,8 @@ public async Task CanTimeout_ShouldReturnFalse( await That(stream.CanTimeout).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Close_CalledMultipleTimes_ShouldNotThrow( string path, string contents) { @@ -52,8 +52,8 @@ void Act() await That(Act).DoesNotThrow(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Extensibility_ShouldWrapFileStreamOnRealFileSystem( string path) { @@ -75,8 +75,8 @@ public async Task Extensibility_ShouldWrapFileStreamOnRealFileSystem( } } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Flush_ShouldNotChangePosition( string path, byte[] bytes) { @@ -90,8 +90,8 @@ public async Task Flush_ShouldNotChangePosition( await That(stream.Position).IsEqualTo(2); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Flush_ShouldNotUpdateFileContentWhenAlreadyFlushed( string path, byte[] bytes1, byte[] bytes2) { @@ -118,9 +118,9 @@ public async Task Flush_ShouldNotUpdateFileContentWhenAlreadyFlushed( await That(FileSystem.File.ReadAllBytes(path)).IsEqualTo(bytes2); } - [Theory] - [InlineAutoData(false)] - [InlineAutoData(true)] + [Test] + [AutoArguments(false)] + [AutoArguments(true)] public async Task Flush_WriteToDisk_ShouldNotChangePosition( bool flushToDisk, string path, byte[] bytes) { @@ -134,8 +134,8 @@ public async Task Flush_WriteToDisk_ShouldNotChangePosition( await That(stream.Position).IsEqualTo(2); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task FlushAsync_Cancelled_ShouldThrowTaskCanceledException( string path) { @@ -152,8 +152,8 @@ async Task Act() await That(Act).Throws().WithHResult(-2146233029); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task FlushAsync_ShouldNotChangePosition( string path, byte[] bytes) { @@ -163,13 +163,13 @@ public async Task FlushAsync_ShouldNotChangePosition( stream.Seek(2, SeekOrigin.Begin); await That(stream.Position).IsEqualTo(2); - await stream.FlushAsync(TestContext.Current.CancellationToken); + await stream.FlushAsync(CancellationToken); await That(stream.Position).IsEqualTo(2); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Name_ShouldReturnFullPath(string path) { string expectedName = FileSystem.Path.GetFullPath(path); @@ -178,8 +178,8 @@ public async Task Name_ShouldReturnFullPath(string path) await That(stream.Name).IsEqualTo(expectedName); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Position_ShouldChangeWhenReading( string path, string contents) { @@ -193,8 +193,8 @@ public async Task Position_ShouldChangeWhenReading( } #if FEATURE_SPAN - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Position_ShouldNotChangeSharedBufferStreamsWhenWriting( string path, string contents, string changedContents) { @@ -222,8 +222,8 @@ public async Task Position_ShouldNotChangeSharedBufferStreamsWhenWriting( } #endif - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Seek_Begin_ShouldSetAbsolutePositionFromBegin( string path, string contents) { @@ -236,8 +236,8 @@ public async Task Seek_Begin_ShouldSetAbsolutePositionFromBegin( await That(stream.Position).IsEqualTo(4); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Seek_Current_ShouldSetRelativePosition(string path, string contents) { FileSystem.File.WriteAllText(path, contents); @@ -253,8 +253,8 @@ public async Task Seek_Current_ShouldSetRelativePosition(string path, string con await That(stream.Position).IsEqualTo(6); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Seek_End_ShouldSetAbsolutePositionFromEnd(string path, string contents) { FileSystem.File.WriteAllText(path, contents); @@ -266,8 +266,8 @@ public async Task Seek_End_ShouldSetAbsolutePositionFromEnd(string path, string await That(stream.Position).IsEqualTo(contents.Length - 4); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task SetLength(string path, int length) { using FileSystemStream stream = FileSystem.File.Create(path); @@ -277,8 +277,8 @@ public async Task SetLength(string path, int length) await That(stream.Length).IsEqualTo(length); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task SetLength_ReadOnlyStream_ShouldThrowNotSupportedException( string path, int length) { diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/FileStream/WriteTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/FileStream/WriteTests.cs index 188fe4c01..7e4109819 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/FileStream/WriteTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/FileStream/WriteTests.cs @@ -7,10 +7,10 @@ namespace Testably.Abstractions.Tests.FileSystem.FileStream; [FileSystemTests] -public partial class WriteTests +public class WriteTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task BeginWrite_CanWriteFalse_ShouldThrowNotSupportedException( string path, byte[] bytes) { @@ -28,8 +28,8 @@ void Act() await That(Act).Throws().WithHResult(-2146233067); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task BeginWrite_ShouldCopyContentsToFile( string path, byte[] bytes) { @@ -53,15 +53,15 @@ public async Task BeginWrite_ShouldCopyContentsToFile( } }, null); - await That(ms.Wait(ExpectSuccess, TestContext.Current.CancellationToken)).IsTrue(); + await That(ms.Wait(ExpectSuccess, CancellationToken)).IsTrue(); } await That(FileSystem.File.Exists(path)).IsTrue(); await That(FileSystem.File.ReadAllBytes(path)).IsEqualTo(bytes); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task EndWrite_Null_ShouldThrowArgumentNullException(string path) { using FileSystemStream stream = FileSystem.File.Create(path); @@ -75,8 +75,8 @@ void Act() await That(Act).Throws().WithHResult(-2147467261); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task EndWrite_ShouldAdjustTimes(string path, byte[] bytes) { using ManualResetEventSlim ms = new(); @@ -104,7 +104,7 @@ public async Task EndWrite_ShouldAdjustTimes(string path, byte[] bytes) } }, null); - await That(ms.Wait(ExpectSuccess, TestContext.Current.CancellationToken)).IsTrue(); + await That(ms.Wait(ExpectSuccess, CancellationToken)).IsTrue(); } DateTime creationTime = FileSystem.File.GetCreationTimeUtc(path); @@ -127,8 +127,8 @@ await That(lastAccessTime).IsBetween(creationTimeStart).And(creationTimeEnd) } #if FEATURE_SPAN - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Write_AsSpan_CanWriteFalse_ShouldThrowNotSupportedException( string path, byte[] bytes) { @@ -149,8 +149,8 @@ void Act() #endif #if FEATURE_SPAN - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Write_AsSpan_ShouldFillBuffer(string path, byte[] bytes) { using (FileSystemStream stream = FileSystem.File.Create(path)) @@ -163,8 +163,8 @@ public async Task Write_AsSpan_ShouldFillBuffer(string path, byte[] bytes) } #endif - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Write_CanWriteFalse_ShouldThrowNotSupportedException( string path, byte[] bytes) { @@ -183,8 +183,8 @@ void Act() await That(Act).Throws().WithHResult(-2146233067); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Write_ShouldFillBuffer(string path, byte[] bytes) { using (FileSystemStream stream = FileSystem.File.Create(path)) @@ -197,8 +197,8 @@ public async Task Write_ShouldFillBuffer(string path, byte[] bytes) } #if FEATURE_FILESYSTEM_ASYNC - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAsync_CanWriteFalse_ShouldThrowNotSupportedException( string path, byte[] bytes) { @@ -222,8 +222,8 @@ async Task Act() #endif #if FEATURE_FILESYSTEM_ASYNC - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteAsync_ShouldFillBuffer(string path, byte[] bytes) { using CancellationTokenSource cts = new(ExpectSuccess); @@ -240,8 +240,8 @@ public async Task WriteAsync_ShouldFillBuffer(string path, byte[] bytes) } #endif - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteByte_HiddenFile_ShouldNotThrow( string path, byte[] bytes) { @@ -260,8 +260,8 @@ void Act() await That(Act).DoesNotThrow(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteByte_ShouldWriteSingleByteAndAdvancePosition( string path, byte byte1, byte byte2) { @@ -277,8 +277,8 @@ public async Task WriteByte_ShouldWriteSingleByteAndAdvancePosition( await That(FileSystem.File.ReadAllBytes(path)).IsEqualTo([byte1, byte2]); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task WriteTimeout_ShouldThrowInvalidOperationException( string path, string contents) { diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/FileStreamFactory/ExceptionTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/FileStreamFactory/ExceptionTests.cs index 532a78251..f8c586db1 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/FileStreamFactory/ExceptionTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/FileStreamFactory/ExceptionTests.cs @@ -6,11 +6,26 @@ namespace Testably.Abstractions.Tests.FileSystem.FileStreamFactory; [FileSystemTests] -public partial class ExceptionTests +public class ExceptionTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [MemberData(nameof(GetFileStreamFactoryCallbacks), - "Illegal\tCharacter?InPath")] + public static IEnumerable<(Expression>, string, bool)> + GetFileStreamFactoryCallbacksWithEmptyPath() + => GetFileStreamFactoryCallbacks(""); + + public static IEnumerable<(Expression>, string, bool)> + GetFileStreamFactoryCallbacksWithIllegalPathCharacters() + => GetFileStreamFactoryCallbacks("Illegal\tCharacter?InPath"); + + public static IEnumerable<(Expression>, string, bool)> + GetFileStreamFactoryCallbacksWithNullPath() + => GetFileStreamFactoryCallbacks(null); + + public static IEnumerable<(Expression>, string, bool)> + GetFileStreamFactoryCallbacksWithWhitespacePath() + => GetFileStreamFactoryCallbacks(" "); + + [Test] + [MethodDataSource(nameof(GetFileStreamFactoryCallbacksWithIllegalPathCharacters))] public async Task Operations_WhenValueContainsIllegalPathCharacters_ShouldThrowCorrectException_OnWindows( Expression> callback, string paramName, @@ -49,8 +64,8 @@ await That(Act).Throws() } } - [Theory] - [MemberData(nameof(GetFileStreamFactoryCallbacks), "")] + [Test] + [MethodDataSource(nameof(GetFileStreamFactoryCallbacksWithEmptyPath))] public async Task Operations_WhenValueIsEmpty_ShouldThrowArgumentException( Expression> callback, string paramName, bool ignoreParamCheck) @@ -67,8 +82,8 @@ await That(Act).Throws() $"\n{callback}\n has empty parameter for '{paramName}' (ignored: {ignoreParamCheck})"); } - [Theory] - [MemberData(nameof(GetFileStreamFactoryCallbacks), (string?)null)] + [Test] + [MethodDataSource(nameof(GetFileStreamFactoryCallbacksWithNullPath))] public async Task Operations_WhenValueIsNull_ShouldThrowArgumentNullException( Expression> callback, string paramName, bool ignoreParamCheck) @@ -84,8 +99,8 @@ await That(Act).Throws() $"\n{callback}\n has `null` parameter for '{paramName}' (ignored: {ignoreParamCheck})"); } - [Theory] - [MemberData(nameof(GetFileStreamFactoryCallbacks), " ")] + [Test] + [MethodDataSource(nameof(GetFileStreamFactoryCallbacksWithWhitespacePath))] public async Task Operations_WhenValueIsWhitespace_ShouldThrowArgumentException( Expression> callback, string paramName, bool ignoreParamCheck) @@ -107,23 +122,20 @@ await That(Act).Throws() #region Helpers #pragma warning disable MA0018 - public static TheoryData>, string, bool> + private static IEnumerable<(Expression>, string, bool)> GetFileStreamFactoryCallbacks(string? path) { - TheoryData>, string, bool> theoryData = new(); foreach ((ExceptionTestHelper.TestTypes TestType, string ParamName, Expression> Callback) item in GetFileStreamFactoryCallbackTestParameters(path!) .Where(item => item.TestType.HasFlag(path.ToTestType()))) { - theoryData.Add( + yield return ( item.Callback, item.ParamName, item.TestType.HasFlag(ExceptionTestHelper.TestTypes.IgnoreParamNameCheck)); } - - return theoryData; } #pragma warning restore MA0018 diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/FileStreamFactory/SafeFileHandleTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/FileStreamFactory/SafeFileHandleTests.cs index df5e3d159..f74995f00 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/FileStreamFactory/SafeFileHandleTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/FileStreamFactory/SafeFileHandleTests.cs @@ -7,10 +7,10 @@ namespace Testably.Abstractions.Tests.FileSystem.FileStreamFactory; [FileSystemTests] -public partial class SafeFileHandleTests +public class SafeFileHandleTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task New_SafeFileHandle_InvalidHandle_ShouldThrowArgumentException( string filename) { @@ -27,8 +27,8 @@ await That(Act).Throws() .WithParamName("handle"); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task New_SafeFileHandle_InvalidHandle_WithBufferSize_ShouldThrowArgumentException( string filename) { @@ -45,8 +45,8 @@ await That(Act).Throws() .WithParamName("handle"); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task New_SafeFileHandle_InvalidHandle_WithBufferSizeAndAsync_ShouldThrowArgumentException( string filename) @@ -64,8 +64,8 @@ await That(Act).Throws() .WithParamName("handle"); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task New_SafeFileHandle_Valid_ShouldCreateWritableStream( string filename, string contents) { @@ -98,8 +98,8 @@ public async Task New_SafeFileHandle_Valid_ShouldCreateWritableStream( } } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task New_SafeFileHandle_Valid_WithBufferSize_ShouldCreateWritableStream( string filename, string contents) { @@ -133,8 +133,8 @@ public async Task New_SafeFileHandle_Valid_WithBufferSize_ShouldCreateWritableSt } } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task New_SafeFileHandle_Valid_WithBufferSizeAndAsync_ShouldCreateWritableStream( string filename, string contents) diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/FileStreamFactory/Tests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/FileStreamFactory/Tests.cs index a18716631..5a82ef9b5 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/FileStreamFactory/Tests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/FileStreamFactory/Tests.cs @@ -3,10 +3,10 @@ namespace Testably.Abstractions.Tests.FileSystem.FileStreamFactory; [FileSystemTests] -public partial class Tests +public class Tests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task New_AppendAccessWithReadWriteMode_ShouldThrowArgumentException( string path) { @@ -21,8 +21,8 @@ await That(Act).Throws() .WithParamName(Test.IsNetFramework ? null : "access"); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task New_ExistingFileWithCreateMode_ShouldIgnoreContent( string path) { @@ -33,8 +33,8 @@ public async Task New_ExistingFileWithCreateMode_ShouldIgnoreContent( await That(FileSystem.File.ReadAllText(path)).IsEmpty(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task New_ExistingFileWithCreateNewMode_ShouldThrowIOException( string path) { @@ -50,8 +50,8 @@ await That(Act).Throws() .WithHResult(Test.RunsOnWindows ? -2147024816 : 17); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task New_ExistingFileWithTruncateMode_ShouldIgnoreContent( string path) { @@ -62,12 +62,12 @@ public async Task New_ExistingFileWithTruncateMode_ShouldIgnoreContent( await That(FileSystem.File.ReadAllText(path)).IsEmpty(); } - [Theory] - [InlineAutoData(FileMode.Append)] - [InlineAutoData(FileMode.Truncate)] - [InlineAutoData(FileMode.Create)] - [InlineAutoData(FileMode.CreateNew)] - [InlineAutoData(FileMode.Append)] + [Test] + [AutoArguments(FileMode.Append)] + [AutoArguments(FileMode.Truncate)] + [AutoArguments(FileMode.Create)] + [AutoArguments(FileMode.CreateNew)] + [AutoArguments(FileMode.Append)] public async Task New_InvalidModeForReadAccess_ShouldThrowArgumentException( FileMode mode, string path) { @@ -85,9 +85,9 @@ await That(Act).Throws() it => it.Contains(mode.ToString()).And.Contains(access.ToString())); } - [Theory] - [InlineAutoData(FileMode.Open)] - [InlineAutoData(FileMode.Truncate)] + [Test] + [AutoArguments(FileMode.Open)] + [AutoArguments(FileMode.Truncate)] public async Task New_MissingFileWithIncorrectMode_ShouldThrowFileNotFoundException( FileMode mode, string path) { @@ -101,8 +101,8 @@ await That(Act).Throws() .WithHResult(-2147024894); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task New_MissingFileWithTruncateMode_ShouldThrowFileNotFoundException( string path) { @@ -116,10 +116,10 @@ await That(Act).Throws() .WithHResult(-2147024894); } - [Theory] - [InlineAutoData(FileAccess.Read)] - [InlineAutoData(FileAccess.ReadWrite)] - [InlineAutoData(FileAccess.Write)] + [Test] + [AutoArguments(FileAccess.Read)] + [AutoArguments(FileAccess.ReadWrite)] + [AutoArguments(FileAccess.Write)] public async Task New_ReadOnlyFlag_ShouldThrowUnauthorizedAccessException_WhenAccessContainsWrite( FileAccess access, @@ -143,8 +143,8 @@ void Act() } } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task New_SamePathAsExistingDirectory_ShouldThrowCorrectException( string path) { @@ -169,9 +169,9 @@ await That(Act).Throws() } } - [Theory] - [InlineAutoData(false)] - [InlineAutoData(true)] + [Test] + [AutoArguments(false)] + [AutoArguments(true)] public async Task New_WithUseAsyncSet_ShouldSetProperty(bool useAsync, string path) { using FileSystemStream stream = FileSystem.FileStream.New( diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemInfo/CreateAsSymbolicLinkTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemInfo/CreateAsSymbolicLinkTests.cs index bb6b3e048..37c4b8b5e 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemInfo/CreateAsSymbolicLinkTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemInfo/CreateAsSymbolicLinkTests.cs @@ -4,10 +4,10 @@ namespace Testably.Abstractions.Tests.FileSystem.FileSystemInfo; [FileSystemTests] -public partial class CreateAsSymbolicLinkTests +public class CreateAsSymbolicLinkTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateAsSymbolicLink_ShouldCreateSymbolicLink( string path, string pathToTarget) { @@ -20,8 +20,8 @@ await That(FileSystem.File.GetAttributes(path)) .HasFlag(FileAttributes.ReparsePoint); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task CreateAsSymbolicLink_SourceFileAlreadyExists_ShouldThrowIOException( string path, string pathToTarget) { diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemInfo/ExceptionTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemInfo/ExceptionTests.cs index dd4538c13..cb844f58e 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemInfo/ExceptionTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemInfo/ExceptionTests.cs @@ -6,10 +6,18 @@ namespace Testably.Abstractions.Tests.FileSystem.FileSystemInfo; [FileSystemTests] -public partial class ExceptionTests +public class ExceptionTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [MemberData(nameof(GetFileSystemInfoCallbacks), "")] + public static IEnumerable<(Expression>, string, bool)> + GetFileSystemInfoCallbacksWithEmptyPath() + => GetFileSystemInfoCallbacks(""); + + public static IEnumerable<(Expression>, string, bool)> + GetFileSystemInfoCallbacksWithNullPath() + => GetFileSystemInfoCallbacks(null); + + [Test] + [MethodDataSource(nameof(GetFileSystemInfoCallbacksWithEmptyPath))] public async Task Operations_WhenValueIsEmpty_ShouldThrowArgumentException( Expression> callback, string paramName, bool ignoreParamCheck) @@ -25,8 +33,8 @@ await That(Act).Throws() .Because($"\n{callback}\n has empty parameter for '{paramName}' (ignored: {ignoreParamCheck})"); } - [Theory] - [MemberData(nameof(GetFileSystemInfoCallbacks), (string?)null)] + [Test] + [MethodDataSource(nameof(GetFileSystemInfoCallbacksWithNullPath))] public async Task Operations_WhenValueIsNull_ShouldThrowArgumentNullException( Expression> callback, string paramName, bool ignoreParamCheck) @@ -44,23 +52,20 @@ await That(Act).Throws() #region Helpers #pragma warning disable MA0018 - public static TheoryData>, string, bool> + public static IEnumerable<(Expression>, string, bool)> GetFileSystemInfoCallbacks(string? path) { - TheoryData>, string, bool> theoryData = new(); foreach ((ExceptionTestHelper.TestTypes TestType, string ParamName, Expression> Callback) item in GetFileSystemInfoCallbackTestParameters(path!) .Where(item => item.TestType.HasFlag(path.ToTestType()))) { - theoryData.Add( + yield return ( item.Callback, item.ParamName, item.TestType.HasFlag(ExceptionTestHelper.TestTypes.IgnoreParamNameCheck)); } - - return theoryData; } #pragma warning restore MA0018 diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemInfo/ResolveLinkTargetTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemInfo/ResolveLinkTargetTests.cs index cbd61e18e..117673d63 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemInfo/ResolveLinkTargetTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemInfo/ResolveLinkTargetTests.cs @@ -5,7 +5,7 @@ namespace Testably.Abstractions.Tests.FileSystem.FileSystemInfo; [FileSystemTests] -public partial class ResolveLinkTargetTests +public class ResolveLinkTargetTests(FileSystemTestData testData) : FileSystemTestBase(testData) { #region Test Setup @@ -18,8 +18,8 @@ public partial class ResolveLinkTargetTests #endregion - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ResolveLinkTarget_FileWithDifferentCase_ShouldReturnPathToMissingFile( string path, string pathToTarget, string contents) { @@ -44,8 +44,8 @@ public async Task ResolveLinkTarget_FileWithDifferentCase_ShouldReturnPathToMiss } } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ResolveLinkTarget_FinalTarget_ShouldFollowSymbolicLinkToFinalTarget( string path, string pathToFinalTarget) { @@ -68,8 +68,8 @@ public async Task ResolveLinkTarget_FinalTarget_ShouldFollowSymbolicLinkToFinalT await That(target!.FullName).IsEqualTo(FileSystem.Path.GetFullPath(pathToFinalTarget)); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ResolveLinkTarget_FinalTargetWithTooManyLevels_ShouldThrowIOException( string path, string pathToFinalTarget) { @@ -96,8 +96,8 @@ await That(Act).Throws() .WithMessageContaining($"'{fileInfo.FullName}'"); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ResolveLinkTarget_MissingFileInLinkChain_ShouldReturnPathToMissingFile( string path, string pathToFinalTarget, string pathToMissingFile) { @@ -113,8 +113,8 @@ public async Task ResolveLinkTarget_MissingFileInLinkChain_ShouldReturnPathToMis await That(target!.FullName).IsEqualTo(FileSystem.Path.GetFullPath(pathToMissingFile)); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ResolveLinkTarget_NormalDirectory_ShouldReturnNull( string path) { @@ -126,8 +126,8 @@ public async Task ResolveLinkTarget_NormalDirectory_ShouldReturnNull( await That(target).IsNull(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ResolveLinkTarget_NormalFile_ShouldReturnNull( string path) { @@ -139,8 +139,8 @@ public async Task ResolveLinkTarget_NormalFile_ShouldReturnNull( await That(target).IsNull(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ResolveLinkTarget_ShouldFollowSymbolicLink( string path, string pathToTarget) { @@ -155,8 +155,8 @@ public async Task ResolveLinkTarget_ShouldFollowSymbolicLink( await That(target.Exists).IsTrue(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ResolveLinkTarget_TargetDeletedAfterLinkCreation_ShouldReturnNull( string path, string pathToTarget) { diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemInfo/Tests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemInfo/Tests.cs index 50318b5ab..e19a9347e 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemInfo/Tests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemInfo/Tests.cs @@ -4,10 +4,10 @@ namespace Testably.Abstractions.Tests.FileSystem.FileSystemInfo; [FileSystemTests] -public partial class Tests +public class Tests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Extensibility_ShouldWrapFileSystemInfoOnRealFileSystem( string path) { @@ -32,8 +32,8 @@ public async Task Extensibility_ShouldWrapFileSystemInfoOnRealFileSystem( } #if FEATURE_FILESYSTEM_LINK - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task LinkTarget_ShouldBeSetByCreateAsSymbolicLink( string path, string pathToTarget) { @@ -47,8 +47,8 @@ public async Task LinkTarget_ShouldBeSetByCreateAsSymbolicLink( } #endif - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task SetAttributes_Hidden_OnFileStartingWithDot_ShouldBeSet(string path) { Skip.IfNot(Test.RunsOnLinux); @@ -64,8 +64,8 @@ public async Task SetAttributes_Hidden_OnFileStartingWithDot_ShouldBeSet(string await That(result2).IsEqualTo(FileAttributes.Hidden); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task SetAttributes_Hidden_OnNormalFile_ShouldBeIgnored(string path) { Skip.IfNot(Test.RunsOnLinux); @@ -80,13 +80,13 @@ public async Task SetAttributes_Hidden_OnNormalFile_ShouldBeIgnored(string path) await That(result2).IsEqualTo(FileAttributes.Normal); } - [Theory] - [InlineAutoData(FileAttributes.Compressed)] - [InlineAutoData(FileAttributes.Device)] - [InlineAutoData(FileAttributes.Encrypted)] - [InlineAutoData(FileAttributes.IntegrityStream)] - [InlineAutoData(FileAttributes.SparseFile)] - [InlineAutoData(FileAttributes.ReparsePoint)] + [Test] + [AutoArguments(FileAttributes.Compressed)] + [AutoArguments(FileAttributes.Device)] + [AutoArguments(FileAttributes.Encrypted)] + [AutoArguments(FileAttributes.IntegrityStream)] + [AutoArguments(FileAttributes.SparseFile)] + [AutoArguments(FileAttributes.ReparsePoint)] public async Task SetAttributes_ShouldBeIgnoredOnAllPlatforms(FileAttributes attributes, string path) { @@ -98,8 +98,8 @@ public async Task SetAttributes_ShouldBeIgnoredOnAllPlatforms(FileAttributes att await That(result).IsEqualTo(FileAttributes.Normal); } - [Theory] - [InlineAutoData(FileAttributes.Hidden)] + [Test] + [AutoArguments(FileAttributes.Hidden)] public async Task SetAttributes_ShouldBeIgnoredOnLinux(FileAttributes attributes, string path) { @@ -118,8 +118,8 @@ public async Task SetAttributes_ShouldBeIgnoredOnLinux(FileAttributes attributes } } - [Theory] - [InlineAutoData(FileAttributes.ReadOnly)] + [Test] + [AutoArguments(FileAttributes.ReadOnly)] public async Task SetAttributes_ShouldBeSupportedOnAllPlatforms( FileAttributes attributes, string path) @@ -132,13 +132,13 @@ public async Task SetAttributes_ShouldBeSupportedOnAllPlatforms( await That(result).IsEqualTo(attributes); } - [Theory] - [InlineAutoData(FileAttributes.Archive)] - [InlineAutoData(FileAttributes.NoScrubData)] - [InlineAutoData(FileAttributes.NotContentIndexed)] - [InlineAutoData(FileAttributes.Offline)] - [InlineAutoData(FileAttributes.System)] - [InlineAutoData(FileAttributes.Temporary)] + [Test] + [AutoArguments(FileAttributes.Archive)] + [AutoArguments(FileAttributes.NoScrubData)] + [AutoArguments(FileAttributes.NotContentIndexed)] + [AutoArguments(FileAttributes.Offline)] + [AutoArguments(FileAttributes.System)] + [AutoArguments(FileAttributes.Temporary)] public async Task SetAttributes_ShouldOnlyWork_OnWindows(FileAttributes attributes, string path) { @@ -157,8 +157,8 @@ public async Task SetAttributes_ShouldOnlyWork_OnWindows(FileAttributes attribut } } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Attributes_WhenDotFile_ShouldHaveHiddenFlag(bool isFile) { Skip.If(Test.RunsOnWindows); diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemInfo/UnixFileModeTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemInfo/UnixFileModeTests.cs index afad84062..13df88724 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemInfo/UnixFileModeTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemInfo/UnixFileModeTests.cs @@ -4,10 +4,10 @@ namespace Testably.Abstractions.Tests.FileSystem.FileSystemInfo; [FileSystemTests] -public partial class UnixFileModeTests +public class UnixFileModeTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task UnixFileMode_MissingFile_ShouldBeInitializedToMinusOne( string path) { @@ -17,8 +17,8 @@ public async Task UnixFileMode_MissingFile_ShouldBeInitializedToMinusOne( await That(fileSystemInfo.UnixFileMode).IsEqualTo(expected); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task UnixFileMode_SetterShouldThrowPlatformNotSupportedException_OnWindows( string path, UnixFileMode unixFileMode) { @@ -36,8 +36,8 @@ void Act() await That(Act).Throws().WithHResult(-2146233031); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task UnixFileMode_ShouldBeInitializedCorrectly( string path) { @@ -53,8 +53,8 @@ public async Task UnixFileMode_ShouldBeInitializedCorrectly( await That(fileSystemInfo.UnixFileMode).IsEqualTo(expected); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task UnixFileMode_ShouldBeSettableOnLinux( string path, UnixFileMode unixFileMode) { diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemTests.Extensibility.cs b/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemTests.Extensibility.cs index e269f0a6b..2d9077b1f 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemTests.Extensibility.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemTests.Extensibility.cs @@ -4,8 +4,8 @@ namespace Testably.Abstractions.Tests.FileSystem; public partial class FileSystemTests { - [Theory] - [AutoData] + [Test] + [Arguments("foo")] public async Task Extensibility_HasWrappedInstance_WithCorrectType_ShouldReturnTrueOnRealFileSystem( string name) @@ -27,8 +27,8 @@ public async Task } } - [Theory] - [AutoData] + [Test] + [Arguments("foo")] public async Task Extensibility_HasWrappedInstance_WithIncorrectType_ShouldReturnAlwaysFalse( string name) { @@ -43,11 +43,12 @@ public async Task Extensibility_HasWrappedInstance_WithIncorrectType_ShouldRetur await That(directoryInfo).IsNull(); } - [Theory] - [AutoData] + [Test] + [Arguments("foo")] public async Task Extensibility_RetrieveMetadata_CorrectKeyAndType_ShouldReturnStoredValue( - string name, DateTime time) + string name) { + var time = DateTime.Now.AddHours(42); IFileInfo entity = FileSystem.FileInfo.New(name); IFileSystemExtensibility sut = entity as IFileSystemExtensibility ?? throw new NotSupportedException( @@ -59,8 +60,8 @@ public async Task Extensibility_RetrieveMetadata_CorrectKeyAndType_ShouldReturnS await That(result).IsEqualTo(time); } - [Theory] - [AutoData] + [Test] + [Arguments("foo")] public async Task Extensibility_RetrieveMetadata_DifferentKey_ShouldReturnNull( string name) { @@ -75,8 +76,8 @@ public async Task Extensibility_RetrieveMetadata_DifferentKey_ShouldReturnNull( await That(result).IsNull(); } - [Theory] - [AutoData] + [Test] + [Arguments("foo")] public async Task Extensibility_RetrieveMetadata_DifferentType_ShouldReturnNull( string name) { @@ -91,8 +92,8 @@ public async Task Extensibility_RetrieveMetadata_DifferentType_ShouldReturnNull( await That(result).IsNull(); } - [Theory] - [AutoData] + [Test] + [Arguments("foo")] public async Task Extensibility_RetrieveMetadata_NotRegisteredKey_ShouldReturnNull( string name) { diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemTests.cs index 97fe51cd6..bcb32d07a 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemTests.cs @@ -1,9 +1,9 @@ namespace Testably.Abstractions.Tests.FileSystem; [FileSystemTests] -public partial class FileSystemTests +public partial class FileSystemTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Fact] + [Test] public async Task Paths_UnderWindows_ShouldUseNormalSlashAndBackslashInterchangeable() { Skip.IfNot(Test.RunsOnWindows); diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcher/EnableRaisingEventsTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcher/EnableRaisingEventsTests.cs index 67f6f6b0a..7dce13e35 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcher/EnableRaisingEventsTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcher/EnableRaisingEventsTests.cs @@ -3,10 +3,10 @@ namespace Testably.Abstractions.Tests.FileSystem.FileSystemWatcher; [FileSystemTests] -public partial class EnableRaisingEventsTests +public class EnableRaisingEventsTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task EnableRaisingEvents_SetToFalse_ShouldStop(string path1, string path2) { FileSystem.Initialize().WithSubdirectory(path1).WithSubdirectory(path2); @@ -27,17 +27,17 @@ public async Task EnableRaisingEvents_SetToFalse_ShouldStop(string path1, string }; fileSystemWatcher.EnableRaisingEvents = true; FileSystem.Directory.Delete(path1); - await That(ms.Wait(ExpectSuccess, TestContext.Current.CancellationToken)).IsTrue(); + await That(ms.Wait(ExpectSuccess, CancellationToken)).IsTrue(); ms.Reset(); fileSystemWatcher.EnableRaisingEvents = false; FileSystem.Directory.Delete(path2); - await That(ms.Wait(ExpectTimeout, TestContext.Current.CancellationToken)).IsFalse(); + await That(ms.Wait(ExpectTimeout, CancellationToken)).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task EnableRaisingEvents_ShouldBeInitializedAsFalse(string path) { FileSystem.Initialize().WithSubdirectory(path); @@ -59,6 +59,6 @@ public async Task EnableRaisingEvents_ShouldBeInitializedAsFalse(string path) FileSystem.Directory.Delete(path); - await That(ms.Wait(ExpectTimeout, TestContext.Current.CancellationToken)).IsFalse(); + await That(ms.Wait(ExpectTimeout, CancellationToken)).IsFalse(); } } diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcher/EventTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcher/EventTests.cs index c0a709af9..8ab470e3e 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcher/EventTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcher/EventTests.cs @@ -7,10 +7,11 @@ namespace Testably.Abstractions.Tests.FileSystem.FileSystemWatcher; [FileSystemTests] -public partial class EventTests +[NotInParallel(nameof(EventTests))] +public class EventTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Changed_ShouldTriggerUntilEventIsRemoved(string path) { int callCount = 0; @@ -83,8 +84,8 @@ void FileSystemWatcherOnChanged(object sender, FileSystemEventArgs e) cts.Cancel(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Created_ShouldTriggerUntilEventIsRemoved(string path) { int callCount = 0; @@ -153,8 +154,8 @@ void FileSystemWatcherOnCreated(object sender, FileSystemEventArgs e) cts.Cancel(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Deleted_ShouldTriggerUntilEventIsRemoved(string path) { int callCount = 0; @@ -223,8 +224,8 @@ void FileSystemWatcherOnDeleted(object sender, FileSystemEventArgs e) cts.Cancel(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Renamed_ShouldTriggerUntilEventIsRemoved(string path) { int callCount = 0; diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcher/FilterTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcher/FilterTests.cs index 2ef97fb27..6e433335c 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcher/FilterTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcher/FilterTests.cs @@ -8,10 +8,10 @@ namespace Testably.Abstractions.Tests.FileSystem.FileSystemWatcher; [FileSystemTests] -public partial class FilterTests +public class FilterTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Filter_Matching_ShouldTriggerNotification(string path) { FileSystem.Initialize().WithSubdirectory(path); @@ -35,7 +35,7 @@ public async Task Filter_Matching_ShouldTriggerNotification(string path) fileSystemWatcher.Filter = path; fileSystemWatcher.EnableRaisingEvents = true; FileSystem.Directory.Delete(path); - await That(ms.Wait(ExpectSuccess, TestContext.Current.CancellationToken)).IsTrue(); + await That(ms.Wait(ExpectSuccess, CancellationToken)).IsTrue(); await That(result).IsNotNull(); await That(result!.FullPath).IsEqualTo(FileSystem.Path.GetFullPath(path)); @@ -43,8 +43,8 @@ public async Task Filter_Matching_ShouldTriggerNotification(string path) await That(result.Name).IsEqualTo(FileSystem.Path.GetFileName(path)); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Filter_NotMatching_ShouldNotTriggerNotification( string path, string filter) { @@ -71,14 +71,14 @@ public async Task Filter_NotMatching_ShouldNotTriggerNotification( fileSystemWatcher.Filter = filter; fileSystemWatcher.EnableRaisingEvents = true; FileSystem.Directory.Delete(path); - await That(ms.Wait(ExpectTimeout, TestContext.Current.CancellationToken)).IsFalse(); + await That(ms.Wait(ExpectTimeout, CancellationToken)).IsFalse(); await That(result).IsNull(); } #if FEATURE_FILESYSTEMWATCHER_ADVANCED - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Filters_ShouldMatchAnyOfTheSpecifiedFilters( string[] filteredPaths, string[] otherPaths) { @@ -107,7 +107,7 @@ public async Task Filters_ShouldMatchAnyOfTheSpecifiedFilters( FileSystem.Directory.Delete(path); } - await That(ms.Wait(ExpectSuccess, TestContext.Current.CancellationToken)).IsTrue(); + await That(ms.Wait(ExpectSuccess, CancellationToken)).IsTrue(); foreach (string path in otherPaths) { diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcher/IncludeSubdirectoriesTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcher/IncludeSubdirectoriesTests.cs index 32999384f..bf3a96b89 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcher/IncludeSubdirectoriesTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcher/IncludeSubdirectoriesTests.cs @@ -4,10 +4,10 @@ namespace Testably.Abstractions.Tests.FileSystem.FileSystemWatcher; [FileSystemTests] -public partial class IncludeSubdirectoriesTests +public class IncludeSubdirectoriesTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task IncludeSubdirectories_SetToFalse_ShouldNotTriggerNotification( string baseDirectory, string path @@ -37,13 +37,13 @@ string path fileSystemWatcher.IncludeSubdirectories = false; fileSystemWatcher.EnableRaisingEvents = true; FileSystem.Directory.Delete(FileSystem.Path.Combine(baseDirectory, path)); - await That(ms.Wait(ExpectTimeout, TestContext.Current.CancellationToken)).IsFalse(); + await That(ms.Wait(ExpectSuccess, CancellationToken)).IsFalse(); await That(result).IsNull(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task IncludeSubdirectories_SetToTrue_ShouldOnlyTriggerNotificationOnSubdirectories( string baseDirectory, string subdirectoryName, @@ -77,13 +77,13 @@ string otherDirectory fileSystemWatcher.IncludeSubdirectories = true; fileSystemWatcher.EnableRaisingEvents = true; FileSystem.Directory.Delete(otherDirectory); - await That(ms.Wait(ExpectTimeout, TestContext.Current.CancellationToken)).IsFalse(); + await That(ms.Wait(ExpectSuccess, CancellationToken)).IsFalse(); await That(result).IsNull(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task IncludeSubdirectories_SetToTrue_ShouldTriggerNotificationOnSubdirectories( string baseDirectory, string subdirectoryName @@ -114,7 +114,7 @@ string subdirectoryName fileSystemWatcher.IncludeSubdirectories = true; fileSystemWatcher.EnableRaisingEvents = true; FileSystem.Directory.Delete(subdirectoryPath); - await That(ms.Wait(ExpectSuccess, TestContext.Current.CancellationToken)).IsTrue(); + await That(ms.Wait(ExpectSuccess, CancellationToken)).IsTrue(); await That(result).IsNotNull(); await That(result!.FullPath).IsEqualTo(FileSystem.Path.GetFullPath(subdirectoryPath)); @@ -122,9 +122,9 @@ string subdirectoryName await That(result!.ChangeType).IsEqualTo(WatcherChangeTypes.Deleted); } - [Theory] - [InlineAutoData(true)] - [InlineAutoData(false)] + [Test] + [AutoArguments(true)] + [AutoArguments(false)] public async Task IncludeSubdirectories_SetToTrue_Created_ArgsNameShouldContainRelativePath( bool watchRootedPath, string baseDirectory, @@ -179,16 +179,16 @@ string fileName // Assert - await That(createdMre.Wait(ExpectTimeout, TestContext.Current.CancellationToken)).IsTrue(); + await That(createdMre.Wait(ExpectSuccess, CancellationToken)).IsTrue(); await That(createdArgs).IsNotNull().And .Satisfies(args => string.Equals(args?.Name, expectedFileName, StringComparison.Ordinal) ); } - [Theory] - [InlineAutoData(true)] - [InlineAutoData(false)] + [Test] + [AutoArguments(true)] + [AutoArguments(false)] public async Task IncludeSubdirectories_SetToTrue_Changed_ArgsNameShouldContainRelativePath( bool watchRootedPath, string baseDirectory, @@ -250,16 +250,16 @@ string fileName // Assert - await That(changedMre.Wait(ExpectTimeout, TestContext.Current.CancellationToken)).IsTrue(); + await That(changedMre.Wait(ExpectSuccess, CancellationToken)).IsTrue(); await That(changedArgs).IsNotNull().And .Satisfies(args => string.Equals(args?.Name, expectedFileName, StringComparison.Ordinal) ); } - [Theory] - [InlineAutoData(true)] - [InlineAutoData(false)] + [Test] + [AutoArguments(true)] + [AutoArguments(false)] public async Task IncludeSubdirectories_SetToTrue_Renamed_ArgsNameShouldContainRelativePath( bool watchRootedPath, string baseDirectory, @@ -319,7 +319,7 @@ string fileName // Assert - await That(renamedMre.Wait(ExpectTimeout, TestContext.Current.CancellationToken)).IsTrue(); + await That(renamedMre.Wait(ExpectSuccess, CancellationToken)).IsTrue(); await That(renamedArgs).IsNotNull().And .Satisfies(args => string.Equals( @@ -331,9 +331,9 @@ await That(renamedArgs).IsNotNull().And ); } - [Theory] - [InlineAutoData(true)] - [InlineAutoData(false)] + [Test] + [AutoArguments(true)] + [AutoArguments(false)] public async Task IncludeSubdirectories_SetToTrue_Deleted_ArgsNameShouldContainRelativePath( bool watchRootedPath, string baseDirectory, @@ -389,7 +389,7 @@ string fileName // Assert - await That(deletedMre.Wait(ExpectTimeout, TestContext.Current.CancellationToken)).IsTrue(); + await That(deletedMre.Wait(ExpectSuccess, CancellationToken)).IsTrue(); await That(deletedArgs).IsNotNull().And.Satisfies(args => string.Equals( args?.Name, expectedFileName, diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcher/MoveTests.Unix.cs b/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcher/MoveTests.Unix.cs index ccdf9162f..96e239307 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcher/MoveTests.Unix.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcher/MoveTests.Unix.cs @@ -6,11 +6,11 @@ namespace Testably.Abstractions.Tests.FileSystem.FileSystemWatcher; public partial class MoveTests { - [Theory] - [InlineData(true, "nested")] - [InlineData(false, "nested")] - [InlineData(true, "nested", "deep")] - [InlineData(false, "nested", "deep")] + [Test] + [Arguments(true, "nested")] + [Arguments(false, "nested")] + [Arguments(true, "nested", "deep")] + [Arguments(false, "nested", "deep")] public async Task Unix_MoveOutsideToNested_ShouldInvokeNothingOrCreated( bool includeSubdirectories, params string[] paths @@ -63,12 +63,12 @@ out ConcurrentBag createdBag // Assert - await That(createdMs.Wait(ExpectTimeout, TestContext.Current.CancellationToken)) + await That(createdMs.Wait(ExpectTimeout, CancellationToken)) .IsEqualTo(includeSubdirectories); - await That(deletedMs.Wait(ExpectTimeout, TestContext.Current.CancellationToken)).IsFalse(); - await That(changedMs.Wait(ExpectTimeout, TestContext.Current.CancellationToken)).IsFalse(); - await That(renamedMs.Wait(ExpectTimeout, TestContext.Current.CancellationToken)).IsFalse(); + await That(deletedMs.Wait(ExpectTimeout, CancellationToken)).IsFalse(); + await That(changedMs.Wait(ExpectTimeout, CancellationToken)).IsFalse(); + await That(renamedMs.Wait(ExpectTimeout, CancellationToken)).IsFalse(); await ThatIsSingleOrEmpty(createdBag, !includeSubdirectories); @@ -85,11 +85,11 @@ await That(createdEvent!) } } - [Theory] - [InlineData(true, "nested")] - [InlineData(false, "nested")] - [InlineData(true, "nested", "deep")] - [InlineData(false, "nested", "deep")] + [Test] + [Arguments(true, "nested")] + [Arguments(false, "nested")] + [Arguments(true, "nested", "deep")] + [Arguments(false, "nested", "deep")] public async Task Unix_MoveInsideToNested_ShouldInvokeDeletedOrRenamed( bool includeSubdirectories, params string[] paths @@ -147,15 +147,15 @@ out ConcurrentBag deletedBag // Assert - await That(deletedMs.Wait(ExpectTimeout, TestContext.Current.CancellationToken)) + await That(deletedMs.Wait(ExpectTimeout, CancellationToken)) .IsEqualTo(!isRenamed); - await That(renamedMs.Wait(ExpectTimeout, TestContext.Current.CancellationToken)) + await That(renamedMs.Wait(ExpectTimeout, CancellationToken)) .IsEqualTo(isRenamed); - await That(changedMs.Wait(ExpectTimeout, TestContext.Current.CancellationToken)).IsFalse(); + await That(changedMs.Wait(ExpectTimeout, CancellationToken)).IsFalse(); - await That(createdMs.Wait(ExpectTimeout, TestContext.Current.CancellationToken)).IsFalse(); + await That(createdMs.Wait(ExpectTimeout, CancellationToken)).IsFalse(); await ThatIsSingleOrEmpty(deletedBag, isRenamed); await ThatIsSingleOrEmpty(renamedBag, !isRenamed); @@ -186,11 +186,11 @@ await That(createdEvent!) } } - [Theory] - [InlineData(true)] - [InlineData(false)] - [InlineData(true, "deep")] - [InlineData(false, "deep")] + [Test] + [Arguments(true)] + [Arguments(false)] + [Arguments(true, "deep")] + [Arguments(false, "deep")] public async Task Unix_MoveNestedTo_ShouldInvokeCreatedOrRenamed( bool includeSubdirectories, string? path = null @@ -255,14 +255,14 @@ out ConcurrentBag createdBag // Assert - await That(createdMs.Wait(ExpectTimeout, TestContext.Current.CancellationToken)) + await That(createdMs.Wait(ExpectTimeout, CancellationToken)) .IsEqualTo(isCreated); - await That(renamedMs.Wait(ExpectTimeout, TestContext.Current.CancellationToken)) + await That(renamedMs.Wait(ExpectTimeout, CancellationToken)) .IsEqualTo(includeSubdirectories); - await That(changedMs.Wait(ExpectTimeout, TestContext.Current.CancellationToken)).IsFalse(); - await That(deletedMs.Wait(ExpectTimeout, TestContext.Current.CancellationToken)).IsFalse(); + await That(changedMs.Wait(ExpectTimeout, CancellationToken)).IsFalse(); + await That(deletedMs.Wait(ExpectTimeout, CancellationToken)).IsFalse(); await ThatIsSingleOrEmpty(createdBag, !isCreated); @@ -295,11 +295,11 @@ await That(renamedEvent!) } } - [Theory] - [InlineData(true)] - [InlineData(false)] - [InlineData(true, "nested")] - [InlineData(false, "nested")] + [Test] + [Arguments(true)] + [Arguments(false)] + [Arguments(true, "nested")] + [Arguments(false, "nested")] public async Task Unix_MoveDeepNestedTo_ShouldInvokeRenamedOrCreated( bool includeSubdirectories, string? path = null @@ -360,14 +360,14 @@ out ConcurrentBag createdBag // Assert - await That(createdMs.Wait(ExpectTimeout, TestContext.Current.CancellationToken)) + await That(createdMs.Wait(ExpectTimeout, CancellationToken)) .IsEqualTo(isCreated); - await That(renamedMs.Wait(ExpectTimeout, TestContext.Current.CancellationToken)) + await That(renamedMs.Wait(ExpectTimeout, CancellationToken)) .IsEqualTo(includeSubdirectories); - await That(changedMs.Wait(ExpectTimeout, TestContext.Current.CancellationToken)).IsFalse(); - await That(deletedMs.Wait(ExpectTimeout, TestContext.Current.CancellationToken)).IsFalse(); + await That(changedMs.Wait(ExpectTimeout, CancellationToken)).IsFalse(); + await That(deletedMs.Wait(ExpectTimeout, CancellationToken)).IsFalse(); await ThatIsSingleOrEmpty(createdBag, !isCreated); await ThatIsSingleOrEmpty(renamedBag, !includeSubdirectories); diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcher/MoveTests.Windows.cs b/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcher/MoveTests.Windows.cs index 50d3203be..74d2d7963 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcher/MoveTests.Windows.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcher/MoveTests.Windows.cs @@ -6,11 +6,11 @@ namespace Testably.Abstractions.Tests.FileSystem.FileSystemWatcher; public partial class MoveTests { - [Theory] - [InlineData(true, "nested")] - [InlineData(false, "nested")] - [InlineData(true, "nested", "deep")] - [InlineData(false, "nested", "deep")] + [Test] + [Arguments(true, "nested")] + [Arguments(false, "nested")] + [Arguments(true, "nested", "deep")] + [Arguments(false, "nested", "deep")] public async Task Windows_MoveOutsideToNested_ShouldInvokeCreatedAndChanged( bool includeSubdirectories, params string[] paths @@ -59,11 +59,11 @@ out ConcurrentBag createdBag // Assert - await That(createdMs.Wait(ExpectTimeout, TestContext.Current.CancellationToken)) + await That(createdMs.Wait(ExpectTimeout, CancellationToken)) .IsEqualTo(includeSubdirectories); - await That(deletedMs.Wait(ExpectTimeout, TestContext.Current.CancellationToken)).IsFalse(); - await That(renamedMs.Wait(ExpectTimeout, TestContext.Current.CancellationToken)).IsFalse(); + await That(deletedMs.Wait(ExpectTimeout, CancellationToken)).IsFalse(); + await That(renamedMs.Wait(ExpectTimeout, CancellationToken)).IsFalse(); await ThatIsSingleOrEmpty(createdBag, !includeSubdirectories); @@ -80,11 +80,11 @@ await That(createdEvent!) } } - [Theory] - [InlineData(true, "nested")] - [InlineData(false, "nested")] - [InlineData(true, "nested", "deep")] - [InlineData(false, "nested", "deep")] + [Test] + [Arguments(true, "nested")] + [Arguments(false, "nested")] + [Arguments(true, "nested", "deep")] + [Arguments(false, "nested", "deep")] public async Task Windows_MoveInsideToNested_ShouldInvokeDeletedCreatedAndChanged( bool includeSubdirectories, params string[] paths @@ -133,12 +133,12 @@ out ConcurrentBag createdBag // Assert - await That(deletedMs.Wait(ExpectTimeout, TestContext.Current.CancellationToken)).IsTrue(); + await That(deletedMs.Wait(ExpectTimeout, CancellationToken)).IsTrue(); - await That(createdMs.Wait(ExpectTimeout, TestContext.Current.CancellationToken)) + await That(createdMs.Wait(ExpectTimeout, CancellationToken)) .IsEqualTo(includeSubdirectories); - await That(renamedMs.Wait(ExpectTimeout, TestContext.Current.CancellationToken)).IsFalse(); + await That(renamedMs.Wait(ExpectTimeout, CancellationToken)).IsFalse(); await That(deletedBag).HasSingle(); @@ -166,11 +166,11 @@ await That(createdEvent!) } } - [Theory] - [InlineData(true)] - [InlineData(false)] - [InlineData(true, "deep")] - [InlineData(false, "deep")] + [Test] + [Arguments(true)] + [Arguments(false)] + [Arguments(true, "deep")] + [Arguments(false, "deep")] public async Task Windows_MoveNestedTo_ShouldInvokeDeletedCreatedAndChanged( bool includeSubdirectories, string? path = null @@ -229,13 +229,13 @@ out ConcurrentBag deletedBag // Assert - await That(createdMs.Wait(ExpectTimeout, TestContext.Current.CancellationToken)) + await That(createdMs.Wait(ExpectTimeout, CancellationToken)) .IsEqualTo(isCreated); - await That(deletedMs.Wait(ExpectTimeout, TestContext.Current.CancellationToken)) + await That(deletedMs.Wait(ExpectTimeout, CancellationToken)) .IsEqualTo(includeSubdirectories); - await That(renamedMs.Wait(ExpectTimeout, TestContext.Current.CancellationToken)).IsFalse(); + await That(renamedMs.Wait(ExpectTimeout, CancellationToken)).IsFalse(); await ThatIsSingleOrEmpty(createdBag, !isCreated); await ThatIsSingleOrEmpty(deletedBag, !includeSubdirectories); @@ -265,11 +265,11 @@ await That(deletedEvent!) } } - [Theory] - [InlineData(true)] - [InlineData(false)] - [InlineData(true, "nested")] - [InlineData(false, "nested")] + [Test] + [Arguments(true)] + [Arguments(false)] + [Arguments(true, "nested")] + [Arguments(false, "nested")] public async Task Windows_MoveDeepNestedTo_ShouldInvokeDeletedCreatedAndChanged( bool includeSubdirectories, string? path = null @@ -333,13 +333,13 @@ out ConcurrentBag deletedBag // Assert - await That(createdMs.Wait(ExpectTimeout, TestContext.Current.CancellationToken)) + await That(createdMs.Wait(ExpectTimeout, CancellationToken)) .IsEqualTo(isCreated); - await That(deletedMs.Wait(ExpectTimeout, TestContext.Current.CancellationToken)) + await That(deletedMs.Wait(ExpectTimeout, CancellationToken)) .IsEqualTo(includeSubdirectories); - await That(renamedMs.Wait(ExpectTimeout, TestContext.Current.CancellationToken)).IsFalse(); + await That(renamedMs.Wait(ExpectTimeout, CancellationToken)).IsFalse(); await ThatIsSingleOrEmpty(createdBag, !isCreated); await ThatIsSingleOrEmpty(deletedBag, !includeSubdirectories); diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcher/MoveTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcher/MoveTests.cs index 15992e86f..7e7e7bf9d 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcher/MoveTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcher/MoveTests.cs @@ -6,11 +6,13 @@ namespace Testably.Abstractions.Tests.FileSystem.FileSystemWatcher; [FileSystemTests] -public partial class MoveTests +// TODO #956: Investigate, why these tests are not stable when run in parallel +[NotInParallel(nameof(MoveTests))] +public partial class MoveTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [InlineData(true)] - [InlineData(false)] + [Test] + [Arguments(true)] + [Arguments(false)] public async Task MoveOutsideToInside_ShouldInvokeCreated(bool includeSubdirectories) { // Arrange @@ -49,10 +51,10 @@ out ConcurrentBag createdBag // Assert - await That(createdMs.Wait(ExpectTimeout, TestContext.Current.CancellationToken)).IsTrue(); + await That(createdMs.Wait(ExpectTimeout, CancellationToken)).IsTrue(); - await That(deletedMs.Wait(ExpectTimeout, TestContext.Current.CancellationToken)).IsFalse(); - await That(renamedMs.Wait(ExpectTimeout, TestContext.Current.CancellationToken)).IsFalse(); + await That(deletedMs.Wait(ExpectTimeout, CancellationToken)).IsFalse(); + await That(renamedMs.Wait(ExpectTimeout, CancellationToken)).IsFalse(); await That(createdBag).HasSingle().Which .For(x => x.ChangeType, it => it.IsEqualTo(WatcherChangeTypes.Created)) @@ -62,13 +64,13 @@ await That(createdBag).HasSingle().Which .For(x => x.FullPath, it => it.IsEqualTo(insideTarget)); } - [Theory] - [InlineData(true)] - [InlineData(false)] - [InlineData(true, "nested")] - [InlineData(false, "nested")] - [InlineData(true, "nested", "deep")] - [InlineData(false, "nested", "deep")] + [Test] + [Arguments(true)] + [Arguments(false)] + [Arguments(true, "nested")] + [Arguments(false, "nested")] + [Arguments(true, "nested", "deep")] + [Arguments(false, "nested", "deep")] public async Task MoveToOutside_ShouldInvokeDeleted( bool includeSubdirectories, params string[] paths @@ -120,12 +122,12 @@ out ConcurrentBag deletedBag // Assert - await That(deletedMs.Wait(ExpectTimeout, TestContext.Current.CancellationToken)) + await That(deletedMs.Wait(ExpectTimeout, CancellationToken)) .IsEqualTo(shouldInvokeDeleted); - await That(createdMs.Wait(ExpectTimeout, TestContext.Current.CancellationToken)).IsFalse(); + await That(createdMs.Wait(ExpectTimeout, CancellationToken)).IsFalse(); - await That(renamedMs.Wait(ExpectTimeout, TestContext.Current.CancellationToken)).IsFalse(); + await That(renamedMs.Wait(ExpectTimeout, CancellationToken)).IsFalse(); await ThatIsSingleOrEmpty(deletedBag, !shouldInvokeDeleted); @@ -142,13 +144,13 @@ await That(deletedEvent!) } } - [Theory] - [InlineData(true)] - [InlineData(false)] - [InlineData(true, "nested")] - [InlineData(false, "nested")] - [InlineData(true, "nested", "deep")] - [InlineData(false, "nested", "deep")] + [Test] + [Arguments(true)] + [Arguments(false)] + [Arguments(true, "nested")] + [Arguments(false, "nested")] + [Arguments(true, "nested", "deep")] + [Arguments(false, "nested", "deep")] public async Task MoveToSameDirectory_ShouldInvokeRenamed( bool includeSubdirectories, params string[] paths @@ -204,12 +206,12 @@ params string[] paths // Assert - await That(renamedMs.Wait(ExpectTimeout, TestContext.Current.CancellationToken)) + await That(renamedMs.Wait(ExpectTimeout, CancellationToken)) .IsEqualTo(shouldInvokeRenamed); - await That(deletedMs.Wait(ExpectTimeout, TestContext.Current.CancellationToken)).IsFalse(); + await That(deletedMs.Wait(ExpectTimeout, CancellationToken)).IsFalse(); - await That(createdMs.Wait(ExpectTimeout, TestContext.Current.CancellationToken)).IsFalse(); + await That(createdMs.Wait(ExpectTimeout, CancellationToken)).IsFalse(); await ThatIsSingleOrEmpty(renamedBag, !shouldInvokeRenamed); diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcher/NotifyFiltersTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcher/NotifyFiltersTests.cs index dd58e9cdd..95e64bf4e 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcher/NotifyFiltersTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcher/NotifyFiltersTests.cs @@ -4,10 +4,10 @@ namespace Testably.Abstractions.Tests.FileSystem.FileSystemWatcher; [FileSystemTests] -public partial class NotifyFiltersTests +public class NotifyFiltersTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task NotifyFilter_AppendFile_ShouldNotNotifyOnOtherFilters(string fileName) { // This test is brittle on MacOS @@ -53,16 +53,16 @@ public async Task NotifyFilter_AppendFile_ShouldNotNotifyOnOtherFilters(string f FileSystem.File.AppendAllText(fileName, "foo"); - await That(ms.Wait(EnsureTimeout, TestContext.Current.CancellationToken)).IsFalse(); + await That(ms.Wait(EnsureTimeout, CancellationToken)).IsFalse(); await That(result).IsNull(); } - [Theory] - [InlineAutoData(NotifyFilters.CreationTime)] - [InlineAutoData(NotifyFilters.LastAccess)] - [InlineAutoData(NotifyFilters.LastWrite)] - [InlineAutoData(NotifyFilters.Security)] - [InlineAutoData(NotifyFilters.Size)] + [Test] + [AutoArguments(NotifyFilters.CreationTime)] + [AutoArguments(NotifyFilters.LastAccess)] + [AutoArguments(NotifyFilters.LastWrite)] + [AutoArguments(NotifyFilters.Security)] + [AutoArguments(NotifyFilters.Size)] public async Task NotifyFilter_AppendFile_ShouldTriggerChangedEventOnNotifyFilters( NotifyFilters notifyFilter, string fileName) { @@ -109,15 +109,15 @@ public async Task NotifyFilter_AppendFile_ShouldTriggerChangedEventOnNotifyFilte FileSystem.File.AppendAllText(fileName, "foo"); - await That(ms.Wait(ExpectSuccess, TestContext.Current.CancellationToken)).IsTrue(); + await That(ms.Wait(ExpectSuccess, CancellationToken)).IsTrue(); await That(result).IsNotNull(); await That(result!.FullPath).IsEqualTo(FileSystem.Path.GetFullPath(fileName)); await That(result.ChangeType).IsEqualTo(WatcherChangeTypes.Changed); await That(result.Name).IsEqualTo(FileSystem.Path.GetFileName(fileName)); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task NotifyFilter_CreateDirectory_ShouldNotNotifyOnOtherFilters(string path) { // This test is brittle on MacOS @@ -154,12 +154,12 @@ public async Task NotifyFilter_CreateDirectory_ShouldNotNotifyOnOtherFilters(str FileSystem.Directory.CreateDirectory(path); - await That(ms.Wait(EnsureTimeout, TestContext.Current.CancellationToken)).IsFalse(); + await That(ms.Wait(EnsureTimeout, CancellationToken)).IsFalse(); await That(result).IsNull(); } - [Theory] - [InlineAutoData(NotifyFilters.DirectoryName)] + [Test] + [AutoArguments(NotifyFilters.DirectoryName)] public async Task NotifyFilter_CreateDirectory_ShouldTriggerCreatedEventOnNotifyFilters( NotifyFilters notifyFilter, string path) { @@ -188,15 +188,15 @@ public async Task NotifyFilter_CreateDirectory_ShouldTriggerCreatedEventOnNotify FileSystem.Directory.CreateDirectory(path); - await That(ms.Wait(ExpectSuccess, TestContext.Current.CancellationToken)).IsTrue(); + await That(ms.Wait(ExpectSuccess, CancellationToken)).IsTrue(); await That(result).IsNotNull(); await That(result!.FullPath).IsEqualTo(FileSystem.Path.GetFullPath(path)); await That(result.ChangeType).IsEqualTo(WatcherChangeTypes.Created); await That(result.Name).IsEqualTo(FileSystem.Path.GetFileName(path)); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task NotifyFilter_CreateFile_ShouldNotNotifyOnOtherFilters(string path) { // This test is brittle on MacOS @@ -233,12 +233,12 @@ public async Task NotifyFilter_CreateFile_ShouldNotNotifyOnOtherFilters(string p FileSystem.File.WriteAllText(path, "foo"); - await That(ms.Wait(EnsureTimeout, TestContext.Current.CancellationToken)).IsFalse(); + await That(ms.Wait(EnsureTimeout, CancellationToken)).IsFalse(); await That(result).IsNull(); } - [Theory] - [InlineAutoData(NotifyFilters.FileName)] + [Test] + [AutoArguments(NotifyFilters.FileName)] public async Task NotifyFilter_CreateFile_ShouldTriggerCreatedEventOnNotifyFilters( NotifyFilters notifyFilter, string path) { @@ -267,15 +267,15 @@ public async Task NotifyFilter_CreateFile_ShouldTriggerCreatedEventOnNotifyFilte FileSystem.File.WriteAllText(path, "foo"); - await That(ms.Wait(ExpectSuccess, TestContext.Current.CancellationToken)).IsTrue(); + await That(ms.Wait(ExpectSuccess, CancellationToken)).IsTrue(); await That(result).IsNotNull(); await That(result!.FullPath).IsEqualTo(FileSystem.Path.GetFullPath(path)); await That(result.ChangeType).IsEqualTo(WatcherChangeTypes.Created); await That(result.Name).IsEqualTo(FileSystem.Path.GetFileName(path)); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task NotifyFilter_DeleteDirectory_ShouldNotNotifyOnOtherFilters(string path) { // This test is brittle on MacOS @@ -312,12 +312,12 @@ public async Task NotifyFilter_DeleteDirectory_ShouldNotNotifyOnOtherFilters(str FileSystem.Directory.Delete(path); - await That(ms.Wait(EnsureTimeout, TestContext.Current.CancellationToken)).IsFalse(); + await That(ms.Wait(EnsureTimeout, CancellationToken)).IsFalse(); await That(result).IsNull(); } - [Theory] - [InlineAutoData(NotifyFilters.DirectoryName)] + [Test] + [AutoArguments(NotifyFilters.DirectoryName)] public async Task NotifyFilter_DeleteDirectory_ShouldTriggerDeletedEventOnNotifyFilters( NotifyFilters notifyFilter, string path) { @@ -346,15 +346,15 @@ public async Task NotifyFilter_DeleteDirectory_ShouldTriggerDeletedEventOnNotify FileSystem.Directory.Delete(path); - await That(ms.Wait(ExpectSuccess, TestContext.Current.CancellationToken)).IsTrue(); + await That(ms.Wait(ExpectSuccess, CancellationToken)).IsTrue(); await That(result).IsNotNull(); await That(result!.FullPath).IsEqualTo(FileSystem.Path.GetFullPath(path)); await That(result.ChangeType).IsEqualTo(WatcherChangeTypes.Deleted); await That(result.Name).IsEqualTo(FileSystem.Path.GetFileName(path)); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task NotifyFilter_DeleteFile_ShouldNotNotifyOnOtherFilters(string path) { // This test is brittle on MacOS @@ -391,12 +391,12 @@ public async Task NotifyFilter_DeleteFile_ShouldNotNotifyOnOtherFilters(string p FileSystem.File.Delete(path); - await That(ms.Wait(EnsureTimeout, TestContext.Current.CancellationToken)).IsFalse(); + await That(ms.Wait(EnsureTimeout, CancellationToken)).IsFalse(); await That(result).IsNull(); } - [Theory] - [InlineAutoData(NotifyFilters.FileName)] + [Test] + [AutoArguments(NotifyFilters.FileName)] public async Task NotifyFilter_DeleteFile_ShouldTriggerDeletedEventOnNotifyFilters( NotifyFilters notifyFilter, string path) { @@ -425,15 +425,15 @@ public async Task NotifyFilter_DeleteFile_ShouldTriggerDeletedEventOnNotifyFilte FileSystem.File.Delete(path); - await That(ms.Wait(ExpectSuccess, TestContext.Current.CancellationToken)).IsTrue(); + await That(ms.Wait(ExpectSuccess, CancellationToken)).IsTrue(); await That(result).IsNotNull(); await That(result!.FullPath).IsEqualTo(FileSystem.Path.GetFullPath(path)); await That(result.ChangeType).IsEqualTo(WatcherChangeTypes.Deleted); await That(result.Name).IsEqualTo(FileSystem.Path.GetFileName(path)); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task NotifyFilter_MoveFile_DifferentDirectories_ShouldNotifyOnLinuxOrMac( string sourcePath, string sourceName, string destinationPath, string destinationName) @@ -470,7 +470,7 @@ public async Task NotifyFilter_MoveFile_DifferentDirectories_ShouldNotifyOnLinux FileSystem.Path.Combine(sourcePath, sourceName), FileSystem.Path.Combine(destinationPath, destinationName)); - await That(ms.Wait(ExpectSuccess, TestContext.Current.CancellationToken)).IsTrue(); + await That(ms.Wait(ExpectSuccess, CancellationToken)).IsTrue(); await That(result).IsNotNull(); await That(result!.ChangeType).IsEqualTo(WatcherChangeTypes.Renamed); await That(result.FullPath) @@ -482,8 +482,8 @@ await That(result.OldFullPath) await That(result.OldName).IsEqualTo(FileSystem.Path.Combine(sourcePath, sourceName)); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task NotifyFilter_MoveFile_DifferentDirectories_ShouldNotNotify_OnWindows( string sourcePath, string sourceName, string destinationPath, string destinationName) @@ -520,13 +520,13 @@ public async Task NotifyFilter_MoveFile_DifferentDirectories_ShouldNotNotify_OnW FileSystem.Path.Combine(sourcePath, sourceName), FileSystem.Path.Combine(destinationPath, destinationName)); - await That(ms.Wait(EnsureTimeout, TestContext.Current.CancellationToken)).IsFalse(); + await That(ms.Wait(EnsureTimeout, CancellationToken)).IsFalse(); await That(result).IsNull(); } - [Theory] - [InlineAutoData(true)] - [InlineAutoData(false)] + [Test] + [AutoArguments(true)] + [AutoArguments(false)] public async Task NotifyFilter_MoveFileOutOfTheWatchedDirectory_ShouldTriggerDeleted_OnWindows( bool includeSubdirectories, string sourcePath, string sourceName, string destinationPath, string destinationName) @@ -563,16 +563,16 @@ public async Task NotifyFilter_MoveFileOutOfTheWatchedDirectory_ShouldTriggerDel FileSystem.Path.Combine(sourcePath, sourceName), FileSystem.Path.Combine(destinationPath, destinationName)); - await That(ms.Wait(ExpectSuccess, TestContext.Current.CancellationToken)).IsTrue(); + await That(ms.Wait(ExpectSuccess, CancellationToken)).IsTrue(); await That(result).IsNotNull(); await That(result!.ChangeType).IsEqualTo(WatcherChangeTypes.Deleted); await That(result.FullPath).IsEqualTo(FileSystem.Path.Combine(sourcePath, sourceName)); await That(result.Name).IsEqualTo(sourceName); } - [Theory] - [InlineAutoData(true)] - [InlineAutoData(false)] + [Test] + [AutoArguments(true)] + [AutoArguments(false)] public async Task NotifyFilter_MoveFileInToTheWatchedDirectory_ShouldTriggerCreated_OnWindows( bool includeSubdirectories, string sourcePath, string sourceName, string destinationPath, string destinationName) @@ -609,15 +609,15 @@ public async Task NotifyFilter_MoveFileInToTheWatchedDirectory_ShouldTriggerCrea FileSystem.Path.Combine(sourcePath, sourceName), FileSystem.Path.Combine(destinationPath, destinationName)); - await That(ms.Wait(ExpectSuccess, TestContext.Current.CancellationToken)).IsTrue(); + await That(ms.Wait(ExpectSuccess, CancellationToken)).IsTrue(); await That(result).IsNotNull(); await That(result!.ChangeType).IsEqualTo(WatcherChangeTypes.Created); await That(result.FullPath).IsEqualTo(FileSystem.Path.Combine(destinationPath, destinationName)); await That(result.Name).IsEqualTo(destinationName); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task NotifyFilter_MoveFile_ShouldNotNotifyOnOtherFilters( string sourceName, string destinationName) { @@ -657,12 +657,12 @@ public async Task NotifyFilter_MoveFile_ShouldNotNotifyOnOtherFilters( FileSystem.File.Move(sourceName, destinationName); - await That(ms.Wait(EnsureTimeout, TestContext.Current.CancellationToken)).IsFalse(); + await That(ms.Wait(EnsureTimeout, CancellationToken)).IsFalse(); await That(result).IsNull(); } - [Theory] - [InlineAutoData(NotifyFilters.FileName)] + [Test] + [AutoArguments(NotifyFilters.FileName)] public async Task NotifyFilter_MoveFile_ShouldTriggerRenamedEventOnNotifyFilters( NotifyFilters notifyFilter, string sourceName, string destinationName) { @@ -694,7 +694,7 @@ public async Task NotifyFilter_MoveFile_ShouldTriggerRenamedEventOnNotifyFilters FileSystem.File.Move(sourceName, destinationName); - await That(ms.Wait(ExpectSuccess, TestContext.Current.CancellationToken)).IsTrue(); + await That(ms.Wait(ExpectSuccess, CancellationToken)).IsTrue(); await That(result).IsNotNull(); await That(result!.ChangeType).IsEqualTo(WatcherChangeTypes.Renamed); await That(result.FullPath).IsEqualTo(FileSystem.Path.GetFullPath(destinationName)); @@ -703,8 +703,8 @@ public async Task NotifyFilter_MoveFile_ShouldTriggerRenamedEventOnNotifyFilters await That(result.OldName).IsEqualTo(FileSystem.Path.GetFileName(sourceName)); } - [Theory] - [InlineAutoData(NotifyFilters.DirectoryName)] + [Test] + [AutoArguments(NotifyFilters.DirectoryName)] public async Task NotifyFilter_MoveDirectory_ShouldTriggerRenamedEventOnNotifyFilters( NotifyFilters notifyFilter, string sourceName, string destinationName) { @@ -736,7 +736,7 @@ public async Task NotifyFilter_MoveDirectory_ShouldTriggerRenamedEventOnNotifyFi FileSystem.Directory.Move(sourceName, destinationName); - await That(ms.Wait(ExpectSuccess, TestContext.Current.CancellationToken)).IsTrue(); + await That(ms.Wait(ExpectSuccess, CancellationToken)).IsTrue(); await That(result).IsNotNull(); await That(result!.ChangeType).IsEqualTo(WatcherChangeTypes.Renamed); await That(result.FullPath).IsEqualTo(FileSystem.Path.GetFullPath(destinationName)); @@ -745,9 +745,9 @@ public async Task NotifyFilter_MoveDirectory_ShouldTriggerRenamedEventOnNotifyFi await That(result.OldName).IsEqualTo(FileSystem.Path.GetFileName(sourceName)); } - [Theory] - [InlineAutoData(NotifyFilters.DirectoryName, true)] - [InlineAutoData(NotifyFilters.DirectoryName, false)] + [Test] + [AutoArguments(NotifyFilters.DirectoryName, true)] + [AutoArguments(NotifyFilters.DirectoryName, false)] public async Task NotifyFilter_MoveDirectoryOutOfTheWatchedDirectory_ShouldTriggerDeletedEventOnNotifyFilters_OnWindows( NotifyFilters notifyFilter, bool includeSubdirectories, string sourceName, string destinationName) { @@ -781,16 +781,16 @@ public async Task NotifyFilter_MoveDirectoryOutOfTheWatchedDirectory_ShouldTrigg FileSystem.Directory.Move(sourcePath, destinationName); - await That(ms.Wait(ExpectSuccess, TestContext.Current.CancellationToken)).IsTrue(); + await That(ms.Wait(ExpectSuccess, CancellationToken)).IsTrue(); await That(result).IsNotNull(); await That(result!.ChangeType).IsEqualTo(WatcherChangeTypes.Deleted); await That(result.FullPath).IsEqualTo(sourcePath); await That(result.Name).IsEqualTo(sourceName); } - [Theory] - [InlineAutoData(NotifyFilters.DirectoryName, true)] - [InlineAutoData(NotifyFilters.DirectoryName, false)] + [Test] + [AutoArguments(NotifyFilters.DirectoryName, true)] + [AutoArguments(NotifyFilters.DirectoryName, false)] public async Task NotifyFilter_MoveDirectoryInToTheWatchedDirectory_ShouldTriggerCreatedEventOnNotifyFilters_OnWindows( NotifyFilters notifyFilter, bool includeSubdirectories, string sourceName, string destinationName) { @@ -824,15 +824,15 @@ public async Task NotifyFilter_MoveDirectoryInToTheWatchedDirectory_ShouldTrigge FileSystem.Directory.Move(sourceName, destinationPath); - await That(ms.Wait(ExpectSuccess, TestContext.Current.CancellationToken)).IsTrue(); + await That(ms.Wait(ExpectSuccess, CancellationToken)).IsTrue(); await That(result).IsNotNull(); await That(result!.ChangeType).IsEqualTo(WatcherChangeTypes.Created); await That(result.FullPath).IsEqualTo(destinationPath); await That(result.Name).IsEqualTo(destinationName); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task NotifyFilter_WriteFile_ShouldNotNotifyOnOtherFilters(string fileName) { // This test is brittle on MacOS @@ -879,16 +879,16 @@ public async Task NotifyFilter_WriteFile_ShouldNotNotifyOnOtherFilters(string fi FileSystem.File.WriteAllText(fileName, "foo"); - await That(ms.Wait(EnsureTimeout, TestContext.Current.CancellationToken)).IsFalse(); + await That(ms.Wait(EnsureTimeout, CancellationToken)).IsFalse(); await That(result).IsNull(); } - [Theory] - [InlineAutoData(NotifyFilters.CreationTime)] - [InlineAutoData(NotifyFilters.LastAccess)] - [InlineAutoData(NotifyFilters.LastWrite)] - [InlineAutoData(NotifyFilters.Security)] - [InlineAutoData(NotifyFilters.Size)] + [Test] + [AutoArguments(NotifyFilters.CreationTime)] + [AutoArguments(NotifyFilters.LastAccess)] + [AutoArguments(NotifyFilters.LastWrite)] + [AutoArguments(NotifyFilters.Security)] + [AutoArguments(NotifyFilters.Size)] public async Task NotifyFilter_WriteFile_ShouldTriggerChangedEventOnNotifyFilters( NotifyFilters notifyFilter, string fileName) { @@ -935,7 +935,7 @@ public async Task NotifyFilter_WriteFile_ShouldTriggerChangedEventOnNotifyFilter FileSystem.File.WriteAllText(fileName, "foo"); - await That(ms.Wait(ExpectSuccess, TestContext.Current.CancellationToken)).IsTrue(); + await That(ms.Wait(ExpectSuccess, CancellationToken)).IsTrue(); await That(result).IsNotNull(); await That(result!.FullPath).IsEqualTo(FileSystem.Path.GetFullPath(fileName)); await That(result.ChangeType).IsEqualTo(WatcherChangeTypes.Changed); diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcher/PathTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcher/PathTests.cs index 5bf09b098..789cda693 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcher/PathTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcher/PathTests.cs @@ -1,9 +1,9 @@ namespace Testably.Abstractions.Tests.FileSystem.FileSystemWatcher; [FileSystemTests] -public partial class PathTests +public class PathTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Fact] + [Test] public async Task Path_Empty_ShouldNotThrowException() { using IFileSystemWatcher fileSystemWatcher = @@ -18,7 +18,7 @@ void Act() await That(Act).DoesNotThrow(); } - [Fact] + [Test] public async Task Path_Null_ShouldNotThrowException() { using IFileSystemWatcher fileSystemWatcher = @@ -33,8 +33,8 @@ void Act() await That(Act).DoesNotThrow(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Path_SetToNotExistingPath_ShouldThrowArgumentException(string path) { using IFileSystemWatcher fileSystemWatcher = @@ -51,7 +51,7 @@ await That(Act).Throws() .WithMessageContaining(path); } - [Fact] + [Test] public async Task Path_Whitespace_ShouldThrowArgumentException() { using IFileSystemWatcher fileSystemWatcher = diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcher/Tests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcher/Tests.cs index f826e1573..1f44e9e05 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcher/Tests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcher/Tests.cs @@ -5,10 +5,10 @@ namespace Testably.Abstractions.Tests.FileSystem.FileSystemWatcher; [FileSystemTests] -public partial class Tests +public class Tests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task BeginInit_ShouldStopListening(string path) { FileSystem.Initialize(); @@ -31,7 +31,7 @@ public async Task BeginInit_ShouldStopListening(string path) { while (!ms.IsSet) { - await Task.Delay(10, TestContext.Current.CancellationToken); + await Task.Delay(10, CancellationToken); FileSystem.Directory.CreateDirectory(path); FileSystem.Directory.Delete(path); } @@ -40,7 +40,7 @@ public async Task BeginInit_ShouldStopListening(string path) { // Ignore any ObjectDisposedException } - }, TestContext.Current.CancellationToken); + }, CancellationToken); IWaitForChangedResult result = fileSystemWatcher.WaitForChanged(WatcherChangeTypes.Created, 250); @@ -56,7 +56,7 @@ public async Task BeginInit_ShouldStopListening(string path) } } - [Fact] + [Test] public async Task Container_ShouldBeInitializedWithNull() { FileSystem.Initialize(); @@ -66,8 +66,8 @@ public async Task Container_ShouldBeInitializedWithNull() await That(fileSystemWatcher.Container).IsNull(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task EndInit_ShouldRestartListening(string path) { FileSystem.Initialize(); @@ -89,7 +89,7 @@ public async Task EndInit_ShouldRestartListening(string path) { while (!ms.IsSet) { - await Task.Delay(10, TestContext.Current.CancellationToken); + await Task.Delay(10, CancellationToken); FileSystem.Directory.CreateDirectory(path); FileSystem.Directory.Delete(path); } @@ -98,7 +98,7 @@ public async Task EndInit_ShouldRestartListening(string path) { // Ignore any ObjectDisposedException } - }, TestContext.Current.CancellationToken); + }, CancellationToken); IWaitForChangedResult result = fileSystemWatcher.WaitForChanged(WatcherChangeTypes.Created, ExpectSuccess); @@ -111,10 +111,10 @@ public async Task EndInit_ShouldRestartListening(string path) } } - [Theory] - [InlineData(-1, 4096)] - [InlineData(4095, 4096)] - [InlineData(4097, 4097)] + [Test] + [Arguments(-1, 4096)] + [Arguments(4095, 4096)] + [Arguments(4097, 4097)] public async Task InternalBufferSize_ShouldAtLeastHave4096Bytes( int bytes, int expectedBytes) { @@ -127,7 +127,7 @@ public async Task InternalBufferSize_ShouldAtLeastHave4096Bytes( await That(fileSystemWatcher.InternalBufferSize).IsEqualTo(expectedBytes); } - [Fact] + [Test] public async Task Site_ShouldBeInitializedWithNull() { FileSystem.Initialize(); @@ -137,7 +137,7 @@ public async Task Site_ShouldBeInitializedWithNull() await That(fileSystemWatcher.Site).IsNull(); } - [Fact] + [Test] public async Task Site_ShouldBeWritable() { ISite site = new MockSite(); @@ -150,7 +150,7 @@ public async Task Site_ShouldBeWritable() await That(fileSystemWatcher.Site).IsEqualTo(site); } - [Fact] + [Test] public async Task SynchronizingObject_ShouldBeInitializedWithNull() { FileSystem.Initialize(); @@ -160,7 +160,7 @@ public async Task SynchronizingObject_ShouldBeInitializedWithNull() await That(fileSystemWatcher.SynchronizingObject).IsNull(); } - [Fact] + [Test] public async Task SynchronizingObject_ShouldBeWritable() { ISynchronizeInvoke synchronizingObject = new MockSynchronizeInvoke(); diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcher/WaitForChangedTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcher/WaitForChangedTests.cs index ea78d7e96..3ad27fb73 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcher/WaitForChangedTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcher/WaitForChangedTests.cs @@ -1,13 +1,29 @@ +using System.Collections.Generic; using System.IO; using System.Threading; namespace Testably.Abstractions.Tests.FileSystem.FileSystemWatcher; [FileSystemTests] -public partial class WaitForChangedTests +public class WaitForChangedTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + #pragma warning disable MA0018 + public static IEnumerable<(string, Func)> + GetWaitForChangedTimeoutParameters() + { + yield return ("foo.dll", fileSystemWatcher + => fileSystemWatcher.WaitForChanged(WatcherChangeTypes.Changed, 100)); +#if FEATURE_FILESYSTEM_NET_7_OR_GREATER + yield return ("bar.txt", + fileSystemWatcher + => fileSystemWatcher.WaitForChanged(WatcherChangeTypes.Changed, + TimeSpan.FromMilliseconds(100)) + ); +#endif + } + #pragma warning restore MA0018 + [Test] + [AutoArguments] public async Task WaitForChanged_ShouldBlockUntilEventHappens(string path) { SkipIfBrittleTestsShouldBeSkipped(); @@ -24,7 +40,7 @@ public async Task WaitForChanged_ShouldBlockUntilEventHappens(string path) { while (!ms.IsSet) { - await Task.Delay(10, TestContext.Current.CancellationToken); + await Task.Delay(10, CancellationToken); FileSystem.Directory.CreateDirectory(path); FileSystem.Directory.Delete(path); } @@ -33,7 +49,7 @@ public async Task WaitForChanged_ShouldBlockUntilEventHappens(string path) { // Ignore any ObjectDisposedException } - }, TestContext.Current.CancellationToken); + }, CancellationToken); using (CancellationTokenSource cts = new(ExpectSuccess)) { @@ -53,8 +69,8 @@ public async Task WaitForChanged_ShouldBlockUntilEventHappens(string path) } } - [Theory] - [MemberData(nameof(GetWaitForChangedTimeoutParameters))] + [Test] + [MethodDataSource(nameof(GetWaitForChangedTimeoutParameters))] public async Task WaitForChanged_Timeout_ShouldReturnTimedOut(string path, Func callback) { @@ -73,7 +89,7 @@ public async Task WaitForChanged_Timeout_ShouldReturnTimedOut(string path, { while (!ms.IsSet) { - await Task.Delay(10, TestContext.Current.CancellationToken); + await Task.Delay(10, CancellationToken); FileSystem.Directory.CreateDirectory(fullPath); FileSystem.Directory.Delete(fullPath); } @@ -82,7 +98,7 @@ public async Task WaitForChanged_Timeout_ShouldReturnTimedOut(string path, { // Ignore any ObjectDisposedException } - }, TestContext.Current.CancellationToken); + }, CancellationToken); IWaitForChangedResult result = callback(fileSystemWatcher); await That(fileSystemWatcher.EnableRaisingEvents).IsTrue(); @@ -96,31 +112,4 @@ public async Task WaitForChanged_Timeout_ShouldReturnTimedOut(string path, ms.Set(); } } - - #region Helpers - - #pragma warning disable MA0018 - public static TheoryData> - GetWaitForChangedTimeoutParameters() - { - TheoryData> theoryData = new() - { - { - "foo.dll", fileSystemWatcher - => fileSystemWatcher.WaitForChanged(WatcherChangeTypes.Changed, 100) - }, - }; -#if FEATURE_FILESYSTEM_NET_7_OR_GREATER - theoryData.Add( - "bar.txt", - fileSystemWatcher - => fileSystemWatcher.WaitForChanged(WatcherChangeTypes.Changed, - TimeSpan.FromMilliseconds(100)) - ); -#endif - return theoryData; - } - #pragma warning restore MA0018 - - #endregion } diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcherFactory/ExceptionTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcherFactory/ExceptionTests.cs index c0a4fd6ea..8c957db1a 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcherFactory/ExceptionTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcherFactory/ExceptionTests.cs @@ -6,10 +6,26 @@ namespace Testably.Abstractions.Tests.FileSystem.FileSystemWatcherFactory; [FileSystemTests] -public partial class ExceptionTests +public class ExceptionTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [MemberData(nameof(GetFileSystemWatcherFactoryCallbacks), "Illegal\tCharacter?InPath")] + public static IEnumerable<(Expression>, string, bool)> + GetFileSystemWatcherFactoryCallbacksWithEmptyPath() + => GetFileSystemWatcherFactoryCallbacks(""); + + public static IEnumerable<(Expression>, string, bool)> + GetFileSystemWatcherFactoryCallbacksWithIllegalPathCharacters() + => GetFileSystemWatcherFactoryCallbacks("Illegal\tCharacter?InPath"); + + public static IEnumerable<(Expression>, string, bool)> + GetFileSystemWatcherFactoryCallbacksWithNullPath() + => GetFileSystemWatcherFactoryCallbacks(null); + + public static IEnumerable<(Expression>, string, bool)> + GetFileSystemWatcherFactoryCallbacksWithWhitespacePath() + => GetFileSystemWatcherFactoryCallbacks(" "); + + [Test] + [MethodDataSource(nameof(GetFileSystemWatcherFactoryCallbacksWithIllegalPathCharacters))] public async Task Operations_WhenValueContainsIllegalPathCharacters_ShouldThrowCorrectException_OnWindows( Expression> callback, string paramName, @@ -38,8 +54,8 @@ await That(Act).Throws() } } - [Theory] - [MemberData(nameof(GetFileSystemWatcherFactoryCallbacks), "")] + [Test] + [MethodDataSource(nameof(GetFileSystemWatcherFactoryCallbacksWithEmptyPath))] public async Task Operations_WhenValueIsEmpty_ShouldThrowArgumentException( Expression> callback, string paramName, bool ignoreParamCheck) @@ -56,8 +72,8 @@ await That(Act).Throws() $"\n{callback}\n has empty parameter for '{paramName}' (ignored: {ignoreParamCheck})"); } - [Theory] - [MemberData(nameof(GetFileSystemWatcherFactoryCallbacks), (string?)null)] + [Test] + [MethodDataSource(nameof(GetFileSystemWatcherFactoryCallbacksWithNullPath))] public async Task Operations_WhenValueIsNull_ShouldThrowArgumentNullException( Expression> callback, string paramName, bool ignoreParamCheck) @@ -73,8 +89,8 @@ await That(Act).Throws() $"\n{callback}\n has `null` parameter for '{paramName}' (ignored: {ignoreParamCheck})"); } - [Theory] - [MemberData(nameof(GetFileSystemWatcherFactoryCallbacks), " ")] + [Test] + [MethodDataSource(nameof(GetFileSystemWatcherFactoryCallbacksWithWhitespacePath))] public async Task Operations_WhenValueIsWhitespace_ShouldThrowArgumentException( Expression> callback, string paramName, bool ignoreParamCheck) @@ -95,26 +111,21 @@ await That(Act).Throws() #region Helpers - #pragma warning disable MA0018 - public static TheoryData>, string, bool> + private static IEnumerable<(Expression>, string, bool)> GetFileSystemWatcherFactoryCallbacks(string? path) { - TheoryData>, string, bool> theoryData = new(); foreach ((ExceptionTestHelper.TestTypes TestType, string ParamName, Expression> Callback) item in GetFileSystemWatcherFactoryCallbackTestParameters(path!) .Where(item => item.TestType.HasFlag(path.ToTestType()))) { - theoryData.Add( + yield return ( item.Callback, item.ParamName, item.TestType.HasFlag(ExceptionTestHelper.TestTypes.IgnoreParamNameCheck)); } - - return theoryData; } - #pragma warning restore MA0018 private static IEnumerable<(ExceptionTestHelper.TestTypes TestType, string ParamName, Expression> Callback)> diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcherFactory/Tests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcherFactory/Tests.cs index 17dffe87b..ce7399f0d 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcherFactory/Tests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/FileSystemWatcherFactory/Tests.cs @@ -3,9 +3,9 @@ namespace Testably.Abstractions.Tests.FileSystem.FileSystemWatcherFactory; [FileSystemTests] -public partial class Tests +public class Tests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Fact] + [Test] public async Task New_ShouldInitializeWithDefaultValues() { using IFileSystemWatcher result = @@ -25,8 +25,8 @@ await That(result.NotifyFilter).IsEqualTo(NotifyFilters.FileName | await That(result.EnableRaisingEvents).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task New_WithPath_ShouldInitializeWithDefaultValues(string path) { FileSystem.Directory.CreateDirectory(path); @@ -47,8 +47,8 @@ await That(result.NotifyFilter).IsEqualTo(NotifyFilters.FileName | await That(result.EnableRaisingEvents).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task New_WithPathAndFilter_ShouldInitializeWithDefaultValues( string path, string filter) { @@ -66,7 +66,7 @@ await That(result.NotifyFilter).IsEqualTo(NotifyFilters.FileName | await That(result.EnableRaisingEvents).IsFalse(); } - [Fact] + [Test] public async Task Wrap_Null_ShouldReturnNull() { using IFileSystemWatcher? result = FileSystem.FileSystemWatcher.Wrap(null); diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/FileVersionInfo/Tests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/FileVersionInfo/Tests.cs index e54a49886..2d67df85e 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/FileVersionInfo/Tests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/FileVersionInfo/Tests.cs @@ -1,10 +1,10 @@ namespace Testably.Abstractions.Tests.FileSystem.FileVersionInfo; [FileSystemTests] -public partial class Tests +public class Tests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ToString_ShouldReturnProvidedPath(string fileName) { FileSystem.File.WriteAllText(fileName, ""); diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/FileVersionInfoFactory/ExceptionTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/FileVersionInfoFactory/ExceptionTests.cs index cba73cbed..be482806b 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/FileVersionInfoFactory/ExceptionTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/FileVersionInfoFactory/ExceptionTests.cs @@ -5,10 +5,26 @@ namespace Testably.Abstractions.Tests.FileSystem.FileVersionInfoFactory; [FileSystemTests] -public partial class ExceptionTests +public class ExceptionTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [MemberData(nameof(GetFileVersionInfoFactoryCallbacks), "")] + public static IEnumerable<(Expression>, string, bool)> + GetFileVersionInfoFactoryCallbacksWithEmptyPath() + => GetFileVersionInfoFactoryCallbacks(""); + + public static IEnumerable<(Expression>, string, bool)> + GetFileVersionInfoFactoryCallbacksWithIllegalPathCharacters() + => GetFileVersionInfoFactoryCallbacks("Illegal\tCharacter?InPath"); + + public static IEnumerable<(Expression>, string, bool)> + GetFileVersionInfoFactoryCallbacksWithNullPath() + => GetFileVersionInfoFactoryCallbacks(null); + + public static IEnumerable<(Expression>, string, bool)> + GetFileVersionInfoFactoryCallbacksWithWhitespacePath() + => GetFileVersionInfoFactoryCallbacks(" "); + + [Test] + [MethodDataSource(nameof(GetFileVersionInfoFactoryCallbacksWithEmptyPath))] public async Task Operations_WhenValueIsEmpty_ShouldThrowArgumentException( Expression> callback, string paramName, bool ignoreParamCheck) @@ -25,8 +41,8 @@ await That(Act).Throws() $"\n{callback}\n has empty parameter for '{paramName}' (ignored: {ignoreParamCheck})"); } - [Theory] - [MemberData(nameof(GetFileVersionInfoFactoryCallbacks), (string?)null)] + [Test] + [MethodDataSource(nameof(GetFileVersionInfoFactoryCallbacksWithNullPath))] public async Task Operations_WhenValueIsNull_ShouldThrowArgumentNullException( Expression> callback, string paramName, bool ignoreParamCheck) @@ -42,8 +58,8 @@ await That(Act).Throws() $"\n{callback}\n has `null` parameter for '{paramName}' (ignored: {ignoreParamCheck})"); } - [Theory] - [MemberData(nameof(GetFileVersionInfoFactoryCallbacks), " ")] + [Test] + [MethodDataSource(nameof(GetFileVersionInfoFactoryCallbacksWithWhitespacePath))] public async Task Operations_WhenValueIsWhitespace_ShouldThrowArgumentException( Expression> callback, string paramName, bool ignoreParamCheck) @@ -65,23 +81,20 @@ await That(Act).Throws() #region Helpers #pragma warning disable MA0018 - public static TheoryData>, string, bool> + private static IEnumerable<(Expression>, string, bool)> GetFileVersionInfoFactoryCallbacks(string? path) { - TheoryData>, string, bool> theoryData = new(); foreach ((ExceptionTestHelper.TestTypes TestType, string ParamName, Expression> Callback) item in GetFileVersionInfoFactoryCallbackTestParameters(path!) .Where(item => item.TestType.HasFlag(path.ToTestType()))) { - theoryData.Add( + yield return ( item.Callback, item.ParamName, item.TestType.HasFlag(ExceptionTestHelper.TestTypes.IgnoreParamNameCheck)); } - - return theoryData; } #pragma warning restore MA0018 diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/FileVersionInfoFactory/Tests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/FileVersionInfoFactory/Tests.cs index dfeddffe5..e2568438d 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/FileVersionInfoFactory/Tests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/FileVersionInfoFactory/Tests.cs @@ -3,10 +3,10 @@ namespace Testably.Abstractions.Tests.FileSystem.FileVersionInfoFactory; [FileSystemTests] -public partial class Tests +public class Tests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetVersionInfo_ArbitraryFile_ShouldHaveFileNameSet(string fileName) { string filePath = FileSystem.Path.GetFullPath(fileName); @@ -22,8 +22,8 @@ public async Task GetVersionInfo_ArbitraryFile_ShouldHaveFileNameSet(string file await That(result.FileName).IsEqualTo(filePath); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetVersionInfo_MissingFile_ShouldThrowFileNotFoundException( string path) { diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/Path/ChangeExtensionTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/Path/ChangeExtensionTests.cs index 4a126af6c..e5010ccc5 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/Path/ChangeExtensionTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/Path/ChangeExtensionTests.cs @@ -1,10 +1,10 @@ namespace Testably.Abstractions.Tests.FileSystem.Path; [FileSystemTests] -public partial class ChangeExtensionTests +public class ChangeExtensionTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ChangeExtension_EmptyPath_ShouldReturnEmptyString(string extension) { string result = FileSystem.Path.ChangeExtension(string.Empty, extension); @@ -12,8 +12,8 @@ public async Task ChangeExtension_EmptyPath_ShouldReturnEmptyString(string exten await That(result).IsEmpty(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ChangeExtension_NullPath_ShouldReturnNull(string extension) { string? result = FileSystem.Path.ChangeExtension(null, extension); @@ -21,8 +21,8 @@ public async Task ChangeExtension_NullPath_ShouldReturnNull(string extension) await That(result).IsNull(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ChangeExtension_WhenExtensionIsNull_ShouldRemovePreviousExtension( string fileName) { @@ -34,8 +34,8 @@ public async Task ChangeExtension_WhenExtensionIsNull_ShouldRemovePreviousExtens await That(result).IsEqualTo(expectedResult); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ChangeExtension_WithDirectory_ShouldIncludeDirectory( string directory, string fileName, string extension) { @@ -48,8 +48,8 @@ public async Task ChangeExtension_WithDirectory_ShouldIncludeDirectory( await That(result).IsEqualTo(expectedResult); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ChangeExtension_WithDotOnlyInDirectory_ShouldAppendExtensionToPath( string directory, string fileName, string extension) { @@ -62,8 +62,8 @@ public async Task ChangeExtension_WithDotOnlyInDirectory_ShouldAppendExtensionTo await That(result).IsEqualTo(expectedResult); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ChangeExtension_WithFileStartingWithDot_ShouldAppendExtensionToPath( string fileName, string extension) { @@ -75,8 +75,8 @@ public async Task ChangeExtension_WithFileStartingWithDot_ShouldAppendExtensionT await That(result).IsEqualTo(expectedResult); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task ChangeExtension_WithLeadingDotInExtension_ShouldNotIncludeTwoDots( string fileName, string extension) { diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/Path/CombineTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/Path/CombineTests.cs index ffe369e0b..5ed1e6b20 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/Path/CombineTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/Path/CombineTests.cs @@ -1,10 +1,10 @@ namespace Testably.Abstractions.Tests.FileSystem.Path; [FileSystemTests] -public partial class CombineTests +public class CombineTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Combine_2Paths_OneEmpty_ShouldReturnCombinationOfOtherParts( string path) { @@ -15,8 +15,8 @@ public async Task Combine_2Paths_OneEmpty_ShouldReturnCombinationOfOtherParts( await That(result2).IsEqualTo(path); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Combine_2Paths_OneNull_ShouldThrowArgumentNullException(string pathA) { void Act1() => @@ -31,8 +31,8 @@ await That(Act2).Throws().WithParamName("path1").And .WithHResult(-2147467261); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Combine_2Paths_Rooted_ShouldReturnLastRootedPath( string path1, string path2) { @@ -44,14 +44,14 @@ public async Task Combine_2Paths_Rooted_ShouldReturnLastRootedPath( await That(result).IsEqualTo(path2); } - [Theory] - [InlineData("", "", "")] - [InlineData("/foo/", "/bar/", "/bar/")] - [InlineData("foo/", "/bar", "/bar")] - [InlineData("foo/", "bar", "foo/bar")] - [InlineData("foo", "/bar", "/bar")] - [InlineData("foo", "bar", "foo/bar")] - [InlineData("/foo", "bar/", "/foo/bar/")] + [Test] + [Arguments("", "", "")] + [Arguments("/foo/", "/bar/", "/bar/")] + [Arguments("foo/", "/bar", "/bar")] + [Arguments("foo/", "bar", "foo/bar")] + [Arguments("foo", "/bar", "/bar")] + [Arguments("foo", "bar", "foo/bar")] + [Arguments("/foo", "bar/", "/foo/bar/")] public async Task Combine_2Paths_ShouldReturnExpectedResult( string path1, string path2, string expectedResult) { @@ -64,10 +64,10 @@ public async Task Combine_2Paths_ShouldReturnExpectedResult( await That(result).IsEqualTo(expectedResult); } - [Theory] - [InlineAutoData] - [InlineAutoData(" ")] - [InlineAutoData("foo", " ")] + [Test] + [AutoArguments] + [AutoArguments(" ")] + [AutoArguments("foo", " ")] public async Task Combine_2Paths_ShouldReturnPathsCombinedByDirectorySeparatorChar( string path1, string path2) { @@ -79,8 +79,8 @@ public async Task Combine_2Paths_ShouldReturnPathsCombinedByDirectorySeparatorCh await That(result).IsEqualTo(expectedPath); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Combine_3Paths_OneEmpty_ShouldReturnCombinationOfOtherParts( string pathA, string pathB) { @@ -95,8 +95,8 @@ public async Task Combine_3Paths_OneEmpty_ShouldReturnCombinationOfOtherParts( await That(result3).IsEqualTo(expectedPath); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Combine_3Paths_OneNull_ShouldThrowArgumentNullException(string pathA, string pathB) { @@ -117,8 +117,8 @@ await That(Act3).Throws().WithParamName("path2").And .WithHResult(-2147467261); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Combine_3Paths_Rooted_ShouldReturnLastRootedPath( string path1, string path2, string path3) { @@ -131,15 +131,15 @@ public async Task Combine_3Paths_Rooted_ShouldReturnLastRootedPath( await That(result).IsEqualTo(path3); } - [Theory] - [InlineData("", "", "", "")] - [InlineData("/foo/", "/bar/", "/baz/", "/baz/")] - [InlineData("foo/", "/bar/", "/baz", "/baz")] - [InlineData("foo/", "bar", "/baz", "/baz")] - [InlineData("foo", "/bar", "/baz", "/baz")] - [InlineData("foo", "/bar/", "baz", "/bar/baz")] - [InlineData("foo", "bar", "baz", "foo/bar/baz")] - [InlineData("/foo", "bar", "baz/", "/foo/bar/baz/")] + [Test] + [Arguments("", "", "", "")] + [Arguments("/foo/", "/bar/", "/baz/", "/baz/")] + [Arguments("foo/", "/bar/", "/baz", "/baz")] + [Arguments("foo/", "bar", "/baz", "/baz")] + [Arguments("foo", "/bar", "/baz", "/baz")] + [Arguments("foo", "/bar/", "baz", "/bar/baz")] + [Arguments("foo", "bar", "baz", "foo/bar/baz")] + [Arguments("/foo", "bar", "baz/", "/foo/bar/baz/")] public async Task Combine_3Paths_ShouldReturnExpectedResult( string path1, string path2, string path3, string expectedResult) { @@ -153,11 +153,11 @@ public async Task Combine_3Paths_ShouldReturnExpectedResult( await That(result).IsEqualTo(expectedResult); } - [Theory] - [InlineAutoData] - [InlineAutoData(" ")] - [InlineAutoData("foo", " ")] - [InlineAutoData("foo", "bar", " ")] + [Test] + [AutoArguments] + [AutoArguments(" ")] + [AutoArguments("foo", " ")] + [AutoArguments("foo", "bar", " ")] public async Task Combine_3Paths_ShouldReturnPathsCombinedByDirectorySeparatorChar( string path1, string path2, string path3) { @@ -170,8 +170,8 @@ public async Task Combine_3Paths_ShouldReturnPathsCombinedByDirectorySeparatorCh await That(result).IsEqualTo(expectedPath); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Combine_4Paths_OneEmpty_ShouldReturnCombinationOfOtherParts( string pathA, string pathB, string pathC) { @@ -188,8 +188,8 @@ public async Task Combine_4Paths_OneEmpty_ShouldReturnCombinationOfOtherParts( await That(result4).IsEqualTo(expectedPath); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Combine_4Paths_OneNull_ShouldThrowArgumentNullException(string pathA, string pathB, string pathC) @@ -216,8 +216,8 @@ await That(Act4).Throws().WithParamName("path3").And .WithHResult(-2147467261); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Combine_4Paths_Rooted_ShouldReturnLastRootedPath( string path1, string path2, string path3, string path4) { @@ -231,15 +231,15 @@ public async Task Combine_4Paths_Rooted_ShouldReturnLastRootedPath( await That(result).IsEqualTo(path4); } - [Theory] - [InlineData("", "", "", "", "")] - [InlineData("/foo/", "/bar/", "/baz/", "/muh/", "/muh/")] - [InlineData("foo/", "/bar/", "/baz/", "/muh", "/muh")] - [InlineData("foo/", "bar", "/baz", "/muh", "/muh")] - [InlineData("foo", "/bar", "/baz", "/muh", "/muh")] - [InlineData("foo", "/bar/", "baz/", "muh", "/bar/baz/muh")] - [InlineData("foo", "bar", "baz", "muh", "foo/bar/baz/muh")] - [InlineData("/foo", "bar", "baz", "muh/", "/foo/bar/baz/muh/")] + [Test] + [Arguments("", "", "", "", "")] + [Arguments("/foo/", "/bar/", "/baz/", "/muh/", "/muh/")] + [Arguments("foo/", "/bar/", "/baz/", "/muh", "/muh")] + [Arguments("foo/", "bar", "/baz", "/muh", "/muh")] + [Arguments("foo", "/bar", "/baz", "/muh", "/muh")] + [Arguments("foo", "/bar/", "baz/", "muh", "/bar/baz/muh")] + [Arguments("foo", "bar", "baz", "muh", "foo/bar/baz/muh")] + [Arguments("/foo", "bar", "baz", "muh/", "/foo/bar/baz/muh/")] public async Task Combine_4Paths_ShouldReturnExpectedResult( string path1, string path2, string path3, string path4, string expectedResult) { @@ -254,12 +254,12 @@ public async Task Combine_4Paths_ShouldReturnExpectedResult( await That(result).IsEqualTo(expectedResult); } - [Theory] - [InlineAutoData] - [InlineAutoData(" ")] - [InlineAutoData("foo", " ")] - [InlineAutoData("foo", "bar", " ")] - [InlineAutoData("foo", "bar", "baz", " ")] + [Test] + [AutoArguments] + [AutoArguments(" ")] + [AutoArguments("foo", " ")] + [AutoArguments("foo", "bar", " ")] + [AutoArguments("foo", "bar", "baz", " ")] public async Task Combine_4Paths_ShouldReturnPathsCombinedByDirectorySeparatorChar( string path1, string path2, string path3, string path4) { @@ -273,7 +273,7 @@ public async Task Combine_4Paths_ShouldReturnPathsCombinedByDirectorySeparatorCh await That(result).IsEqualTo(expectedPath); } - [Fact] + [Test] public async Task Combine_ParamPaths_Null_ShouldThrowArgumentNullException() { void Act() => @@ -283,8 +283,8 @@ await That(Act).Throws().WithParamName("paths").And .WithHResult(-2147467261); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Combine_ParamPaths_OneEmpty_ShouldReturnCombinationOfOtherParts( string path1, string path2, string path3, string path4) { @@ -308,8 +308,8 @@ public async Task Combine_ParamPaths_OneEmpty_ShouldReturnCombinationOfOtherPart await That(result5).IsEqualTo(expectedPath); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Combine_ParamPaths_OneNull_ShouldThrowArgumentNullException( string pathA, string pathB, string pathC, string pathD) { @@ -340,8 +340,8 @@ await That(Act5).Throws().WithParamName("paths").And .WithHResult(-2147467261); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Combine_ParamPaths_Rooted_ShouldReturnLastRootedPath( string path1, string path2, string path3, string path4, string path5) { @@ -356,15 +356,15 @@ public async Task Combine_ParamPaths_Rooted_ShouldReturnLastRootedPath( await That(result).IsEqualTo(path5); } - [Theory] - [InlineData("", "", "", "", "", "")] - [InlineData("/foo/", "/bar/", "/baz/", "/muh/", "/maeh/", "/maeh/")] - [InlineData("foo/", "/bar/", "/baz/", "/muh", "/maeh", "/maeh")] - [InlineData("foo/", "bar", "/baz", "/muh", "/maeh", "/maeh")] - [InlineData("foo", "/bar", "/baz", "/muh", "/maeh", "/maeh")] - [InlineData("foo", "/bar/", "baz/", "muh/", "maeh", "/bar/baz/muh/maeh")] - [InlineData("foo", "bar", "baz", "muh", "maeh", "foo/bar/baz/muh/maeh")] - [InlineData("/foo", "bar", "baz", "muh", "maeh/", "/foo/bar/baz/muh/maeh/")] + [Test] + [Arguments("", "", "", "", "", "")] + [Arguments("/foo/", "/bar/", "/baz/", "/muh/", "/maeh/", "/maeh/")] + [Arguments("foo/", "/bar/", "/baz/", "/muh", "/maeh", "/maeh")] + [Arguments("foo/", "bar", "/baz", "/muh", "/maeh", "/maeh")] + [Arguments("foo", "/bar", "/baz", "/muh", "/maeh", "/maeh")] + [Arguments("foo", "/bar/", "baz/", "muh/", "maeh", "/bar/baz/muh/maeh")] + [Arguments("foo", "bar", "baz", "muh", "maeh", "foo/bar/baz/muh/maeh")] + [Arguments("/foo", "bar", "baz", "muh", "maeh/", "/foo/bar/baz/muh/maeh/")] public async Task Combine_ParamPaths_ShouldReturnExpectedResult( string path1, string path2, string path3, string path4, string path5, string expectedResult) { @@ -380,13 +380,13 @@ public async Task Combine_ParamPaths_ShouldReturnExpectedResult( await That(result).IsEqualTo(expectedResult); } - [Theory] - [InlineAutoData] - [InlineAutoData(" ")] - [InlineAutoData("foo", " ")] - [InlineAutoData("foo", "bar", " ")] - [InlineAutoData("foo", "bar", "baz", " ")] - [InlineAutoData("foo", "bar", "baz", "muh", " ")] + [Test] + [AutoArguments] + [AutoArguments(" ")] + [AutoArguments("foo", " ")] + [AutoArguments("foo", "bar", " ")] + [AutoArguments("foo", "bar", "baz", " ")] + [AutoArguments("foo", "bar", "baz", "muh", " ")] public async Task Combine_ParamPaths_ShouldReturnPathsCombinedByDirectorySeparatorChar( string path1, string path2, string path3, string path4, string path5) { @@ -402,8 +402,8 @@ public async Task Combine_ParamPaths_ShouldReturnPathsCombinedByDirectorySeparat } #if FEATURE_PATH_SPAN - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Combine_ReadOnlySpanPaths_OneEmpty_ShouldReturnCombinationOfOtherParts( string path1, string path2, string path3, string path4) { @@ -427,8 +427,8 @@ public async Task Combine_ReadOnlySpanPaths_OneEmpty_ShouldReturnCombinationOfOt await That(result5).IsEqualTo(expectedPath); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Combine_ReadOnlySpanPaths_OneNull_ShouldThrowArgumentNullException( string pathA, string pathB, string pathC, string pathD) { @@ -450,8 +450,8 @@ void Act5() => await That(Act5).Throws().WithParamName("paths").And.WithHResult(-2147467261); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Combine_ReadOnlySpanPaths_Rooted_ShouldReturnLastRootedPath( string path1, string path2, string path3, string path4, string path5) { @@ -466,15 +466,15 @@ public async Task Combine_ReadOnlySpanPaths_Rooted_ShouldReturnLastRootedPath( await That(result).IsEqualTo(path5); } - [Theory] - [InlineData("", "", "", "", "", "")] - [InlineData("/foo/", "/bar/", "/baz/", "/muh/", "/maeh/", "/maeh/")] - [InlineData("foo/", "/bar/", "/baz/", "/muh", "/maeh", "/maeh")] - [InlineData("foo/", "bar", "/baz", "/muh", "/maeh", "/maeh")] - [InlineData("foo", "/bar", "/baz", "/muh", "/maeh", "/maeh")] - [InlineData("foo", "/bar/", "baz/", "muh/", "maeh", "/bar/baz/muh/maeh")] - [InlineData("foo", "bar", "baz", "muh", "maeh", "foo/bar/baz/muh/maeh")] - [InlineData("/foo", "bar", "baz", "muh", "maeh/", "/foo/bar/baz/muh/maeh/")] + [Test] + [Arguments("", "", "", "", "", "")] + [Arguments("/foo/", "/bar/", "/baz/", "/muh/", "/maeh/", "/maeh/")] + [Arguments("foo/", "/bar/", "/baz/", "/muh", "/maeh", "/maeh")] + [Arguments("foo/", "bar", "/baz", "/muh", "/maeh", "/maeh")] + [Arguments("foo", "/bar", "/baz", "/muh", "/maeh", "/maeh")] + [Arguments("foo", "/bar/", "baz/", "muh/", "maeh", "/bar/baz/muh/maeh")] + [Arguments("foo", "bar", "baz", "muh", "maeh", "foo/bar/baz/muh/maeh")] + [Arguments("/foo", "bar", "baz", "muh", "maeh/", "/foo/bar/baz/muh/maeh/")] public async Task Combine_ReadOnlySpanPaths_ShouldReturnExpectedResult( string path1, string path2, string path3, string path4, string path5, string expectedResult) { @@ -490,13 +490,13 @@ public async Task Combine_ReadOnlySpanPaths_ShouldReturnExpectedResult( await That(result).IsEqualTo(expectedResult); } - [Theory] - [InlineAutoData] - [InlineAutoData(" ")] - [InlineAutoData("foo", " ")] - [InlineAutoData("foo", "bar", " ")] - [InlineAutoData("foo", "bar", "baz", " ")] - [InlineAutoData("foo", "bar", "baz", "muh", " ")] + [Test] + [AutoArguments] + [AutoArguments(" ")] + [AutoArguments("foo", " ")] + [AutoArguments("foo", "bar", " ")] + [AutoArguments("foo", "bar", "baz", " ")] + [AutoArguments("foo", "bar", "baz", "muh", " ")] public async Task Combine_ReadOnlySpanPaths_ShouldReturnPathsCombinedByDirectorySeparatorChar( string path1, string path2, string path3, string path4, string path5) { diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/Path/EndsInDirectorySeparatorTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/Path/EndsInDirectorySeparatorTests.cs index 42d386811..5fdeb53ad 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/Path/EndsInDirectorySeparatorTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/Path/EndsInDirectorySeparatorTests.cs @@ -2,9 +2,9 @@ namespace Testably.Abstractions.Tests.FileSystem.Path; [FileSystemTests] -public partial class EndsInDirectorySeparatorTests +public class EndsInDirectorySeparatorTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Fact] + [Test] public async Task EndsInDirectorySeparator_Empty_ShouldReturnExpectedResult() { bool result = FileSystem.Path.EndsInDirectorySeparator(string.Empty); @@ -12,7 +12,7 @@ public async Task EndsInDirectorySeparator_Empty_ShouldReturnExpectedResult() await That(result).IsFalse(); } - [Fact] + [Test] public async Task EndsInDirectorySeparator_Null_ShouldReturnExpectedResult() { bool result = FileSystem.Path.EndsInDirectorySeparator(null!); @@ -20,7 +20,7 @@ public async Task EndsInDirectorySeparator_Null_ShouldReturnExpectedResult() await That(result).IsFalse(); } - [Fact] + [Test] public async Task EndsInDirectorySeparator_Span_Empty_ShouldReturnExpectedResult() { bool result = FileSystem.Path.EndsInDirectorySeparator(string.Empty.AsSpan()); @@ -28,9 +28,9 @@ public async Task EndsInDirectorySeparator_Span_Empty_ShouldReturnExpectedResult await That(result).IsFalse(); } - [Theory] - [InlineAutoData('.')] - [InlineAutoData('a')] + [Test] + [AutoArguments('.')] + [AutoArguments('a')] public async Task EndsInDirectorySeparator_Span_WithoutTrailingDirectorySeparator_ShouldReturnFalse( char lastCharacter, string path) { @@ -41,8 +41,8 @@ public async Task EndsInDirectorySeparator_Span_WithoutTrailingDirectorySeparato await That(result).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task EndsInDirectorySeparator_Span_WithTrailingAltDirectorySeparator_ShouldReturnTrue( string path) { @@ -53,8 +53,8 @@ public async Task EndsInDirectorySeparator_Span_WithTrailingAltDirectorySeparato await That(result).IsTrue(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task EndsInDirectorySeparator_Span_WithTrailingDirectorySeparator_ShouldReturnTrue( string path) { @@ -65,9 +65,9 @@ public async Task EndsInDirectorySeparator_Span_WithTrailingDirectorySeparator_S await That(result).IsTrue(); } - [Theory] - [InlineAutoData('.')] - [InlineAutoData('a')] + [Test] + [AutoArguments('.')] + [AutoArguments('a')] public async Task EndsInDirectorySeparator_WithoutTrailingDirectorySeparator_ShouldReturnFalse( char lastCharacter, string path) { @@ -78,8 +78,8 @@ public async Task EndsInDirectorySeparator_WithoutTrailingDirectorySeparator_Sho await That(result).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task EndsInDirectorySeparator_WithTrailingAltDirectorySeparator_ShouldReturnTrue( string path) { @@ -90,8 +90,8 @@ public async Task EndsInDirectorySeparator_WithTrailingAltDirectorySeparator_Sho await That(result).IsTrue(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task EndsInDirectorySeparator_WithTrailingDirectorySeparator_ShouldReturnTrue( string path) { diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/Path/ExceptionTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/Path/ExceptionTests.cs index f904b954f..b66b6716a 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/Path/ExceptionTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/Path/ExceptionTests.cs @@ -5,10 +5,22 @@ namespace Testably.Abstractions.Tests.FileSystem.Path; [FileSystemTests] -public partial class ExceptionTests +public class ExceptionTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [MemberData(nameof(GetPathCallbacks), "")] + public static IEnumerable<(Expression>, string, bool)> + GetPathCallbacksWithEmptyPath() + => GetPathCallbacks(""); + + public static IEnumerable<(Expression>, string, bool)> + GetPathCallbacksWithNullPath() + => GetPathCallbacks(null); + + public static IEnumerable<(Expression>, string, bool)> + GetPathCallbacksWithWhitespacePath() + => GetPathCallbacks(" "); + + [Test] + [MethodDataSource(nameof(GetPathCallbacksWithEmptyPath))] public async Task Operations_WhenValueIsEmpty_ShouldThrowArgumentException( Expression> callback, string paramName, bool ignoreParamCheck) @@ -25,8 +37,8 @@ await That(Act).Throws() $"\n{callback}\n has empty parameter for '{paramName}' (ignored: {ignoreParamCheck})"); } - [Theory] - [MemberData(nameof(GetPathCallbacks), (string?)null)] + [Test] + [MethodDataSource(nameof(GetPathCallbacksWithNullPath))] public async Task Operations_WhenValueIsNull_ShouldThrowArgumentNullException( Expression> callback, string paramName, bool ignoreParamCheck) @@ -42,8 +54,8 @@ await That(Act).Throws() $"\n{callback}\n has `null` parameter for '{paramName}' (ignored: {ignoreParamCheck})"); } - [Theory] - [MemberData(nameof(GetPathCallbacks), " ")] + [Test] + [MethodDataSource(nameof(GetPathCallbacksWithWhitespacePath))] public async Task Operations_WhenValueIsWhitespace_ShouldThrowArgumentException( Expression> callback, string paramName, bool ignoreParamCheck) @@ -65,21 +77,18 @@ await That(Act).Throws() #region Helpers #pragma warning disable MA0018 - public static TheoryData>, string, bool> GetPathCallbacks(string? path) + private static IEnumerable<(Expression>, string, bool)> GetPathCallbacks(string? path) { - TheoryData>, string, bool> theoryData = new(); foreach ((ExceptionTestHelper.TestTypes TestType, string ParamName, Expression> Callback) item in GetPathCallbackTestParameters(path!) .Where(item => item.TestType.HasFlag(path.ToTestType()))) { - theoryData.Add( + yield return ( item.Callback, item.ParamName, item.TestType.HasFlag(ExceptionTestHelper.TestTypes.IgnoreParamNameCheck)); } - - return theoryData; } #pragma warning restore MA0018 diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/Path/ExistsTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/Path/ExistsTests.cs index 5336b7e28..031936239 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/Path/ExistsTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/Path/ExistsTests.cs @@ -2,10 +2,10 @@ namespace Testably.Abstractions.Tests.FileSystem.Path; [FileSystemTests] -public partial class ExistsTests +public class ExistsTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Exists_ExistingDirectory_ShouldReturnTrue(string path) { FileSystem.Directory.CreateDirectory(path); @@ -15,8 +15,8 @@ public async Task Exists_ExistingDirectory_ShouldReturnTrue(string path) await That(result).IsTrue(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Exists_ExistingFile_ShouldReturnTrue(string path) { FileSystem.File.WriteAllText(path, "some content"); @@ -26,8 +26,8 @@ public async Task Exists_ExistingFile_ShouldReturnTrue(string path) await That(result).IsTrue(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Exists_ExistingFileOrDirectory_ShouldReturnTrue(string path) { bool result = FileSystem.Path.Exists(path); @@ -35,7 +35,7 @@ public async Task Exists_ExistingFileOrDirectory_ShouldReturnTrue(string path) await That(result).IsFalse(); } - [Fact] + [Test] public async Task Exists_Null_ShouldReturnFalse() { bool result = FileSystem.Path.Exists(null); @@ -43,8 +43,8 @@ public async Task Exists_Null_ShouldReturnFalse() await That(result).IsFalse(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Exists_ShouldWorkWithAbsolutePaths(string path) { string absolutePath = FileSystem.Path.GetFullPath(path); diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/Path/GetDirectoryNameTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/Path/GetDirectoryNameTests.cs index 41741aa8a..7576fbfdb 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/Path/GetDirectoryNameTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/Path/GetDirectoryNameTests.cs @@ -1,12 +1,12 @@ namespace Testably.Abstractions.Tests.FileSystem.Path; [FileSystemTests] -public partial class GetDirectoryNameTests +public class GetDirectoryNameTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [InlineData((string?)null)] + [Test] + [Arguments((string?)null)] #if !NETFRAMEWORK - [InlineData("")] + [Arguments("")] #endif public async Task GetDirectoryName_NullOrEmpty_ShouldReturnNull(string? path) { @@ -16,12 +16,12 @@ public async Task GetDirectoryName_NullOrEmpty_ShouldReturnNull(string? path) } #if NETFRAMEWORK - [Theory] - [InlineData("")] - [InlineData(" ")] - [InlineData(" ")] - [InlineData("\t")] - [InlineData("\n")] + [Test] + [Arguments("")] + [Arguments(" ")] + [Arguments(" ")] + [Arguments("\t")] + [Arguments("\n")] public async Task GetDirectoryName_EmptyOrWhiteSpace_ShouldThrowArgumentException(string path) { void Act() @@ -34,9 +34,9 @@ void Act() #endif #if !NETFRAMEWORK - [Theory] - [InlineData(" ")] - [InlineData(" ")] + [Test] + [Arguments(" ")] + [Arguments(" ")] public async Task GetDirectoryName_Spaces_ShouldReturnNullOnWindowsOtherwiseEmpty(string? path) { string? result = FileSystem.Path.GetDirectoryName(path); @@ -53,11 +53,11 @@ public async Task GetDirectoryName_Spaces_ShouldReturnNullOnWindowsOtherwiseEmpt #endif #if !NETFRAMEWORK - [Theory] - [InlineData("\t")] - [InlineData("\n")] - [InlineData(" \t")] - [InlineData("\n ")] + [Test] + [Arguments("\t")] + [Arguments("\n")] + [Arguments(" \t")] + [Arguments("\n ")] public async Task GetDirectoryName_TabOrNewline_ShouldReturnEmptyString(string? path) { string? result = FileSystem.Path.GetDirectoryName(path); @@ -66,8 +66,8 @@ public async Task GetDirectoryName_TabOrNewline_ShouldReturnEmptyString(string? } #endif - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetDirectoryName_ShouldReturnDirectory( string directory, string filename, string extension) { @@ -79,8 +79,8 @@ public async Task GetDirectoryName_ShouldReturnDirectory( await That(result).IsEqualTo(directory); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetDirectoryName_ShouldReplaceAltDirectorySeparator( string parentDirectory, string directory, string filename) { @@ -93,12 +93,12 @@ public async Task GetDirectoryName_ShouldReplaceAltDirectorySeparator( await That(result).IsEqualTo(expected); } - [Theory] - [InlineData("foo//bar/file", "foo/bar", TestOS.All)] - [InlineData("foo///bar/file", "foo/bar", TestOS.All)] - [InlineData("//foo//bar/file", "/foo/bar", TestOS.Linux | TestOS.Mac)] - [InlineData(@"foo\\bar/file", "foo/bar", TestOS.Windows)] - [InlineData(@"foo\\\bar/file", "foo/bar", TestOS.Windows)] + [Test] + [Arguments("foo//bar/file", "foo/bar", TestOS.All)] + [Arguments("foo///bar/file", "foo/bar", TestOS.All)] + [Arguments("//foo//bar/file", "/foo/bar", TestOS.Linux | TestOS.Mac)] + [Arguments(@"foo\\bar/file", "foo/bar", TestOS.Windows)] + [Arguments(@"foo\\\bar/file", "foo/bar", TestOS.Windows)] public async Task GetDirectoryName_ShouldNormalizeDirectorySeparators( string path, string expected, TestOS operatingSystem) { @@ -112,8 +112,8 @@ public async Task GetDirectoryName_ShouldNormalizeDirectorySeparators( } #if FEATURE_SPAN - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetDirectoryName_Span_ShouldReturnDirectory( string directory, string filename, string extension) { @@ -126,56 +126,56 @@ public async Task GetDirectoryName_Span_ShouldReturnDirectory( } #endif - [Theory] - [InlineData("//", null, TestOS.Windows)] - [InlineData(@"\\", null, TestOS.Windows)] - [InlineData(@"\\", "", TestOS.Linux | TestOS.Mac)] - [InlineData(@"\", "", TestOS.Linux | TestOS.Mac)] - [InlineData(@"/", null, TestOS.Linux | TestOS.Mac)] - [InlineData(@"/a", "/", TestOS.Linux | TestOS.Mac)] - [InlineData(@"/a\b", @"/", TestOS.Linux | TestOS.Mac)] - [InlineData(@"/a\b/c", @"/a\b", TestOS.Linux | TestOS.Mac)] - [InlineData(@"/a/b/c", @"/a/b", TestOS.Linux | TestOS.Mac)] - [InlineData(@"/a/b", "/a", TestOS.Linux | TestOS.Mac)] - [InlineData("//?/G:/", null, TestOS.Windows)] - [InlineData("/??/H:/", @"\??\H:", TestOS.Windows)] - [InlineData("//?/I:/a", @"\\?\I:\", TestOS.Windows)] - [InlineData("/??/J:/a", @"\??\J:", TestOS.Windows)] - [InlineData(@"\\?\K:\", null, TestOS.Windows)] - [InlineData(@"\??\L:\", null, TestOS.Windows)] - [InlineData(@"\\?\M:\a", @"\\?\M:\", TestOS.Windows)] - [InlineData(@"\??\N:\a", @"\??\N:\", TestOS.Windows)] - [InlineData(@"\\?\UNC\", null, TestOS.Windows)] - [InlineData(@"//?/UNC/", null, TestOS.Windows)] - [InlineData(@"\??\UNC\", null, TestOS.Windows)] - [InlineData(@"/??/UNC/", @"\??\UNC", TestOS.Windows)] - [InlineData(@"\\?\UNC\a", null, TestOS.Windows)] - [InlineData(@"//?/UNC/a", null, TestOS.Windows)] - [InlineData(@"\??\UNC\a", null, TestOS.Windows)] - [InlineData(@"/??/UNC/a", @"\??\UNC", TestOS.Windows)] - [InlineData(@"\\?\ABC\", null, TestOS.Windows)] - [InlineData(@"//?/ABC/", null, TestOS.Windows)] - [InlineData(@"\??\XYZ\", null, TestOS.Windows)] - [InlineData(@"/??/XYZ/", @"\??\XYZ", TestOS.Windows)] - [InlineData(@"\\?\unc\a", @"\\?\unc\", TestOS.Windows)] - [InlineData(@"//?/unc/a", @"\\?\unc\", TestOS.Windows)] - [InlineData(@"\??\unc\a", @"\??\unc\", TestOS.Windows)] - [InlineData(@"/??/unc/a", @"\??\unc", TestOS.Windows)] - [InlineData("//./", null, TestOS.Windows)] - [InlineData(@"\\.\", null, TestOS.Windows)] - [InlineData("//?/", null, TestOS.Windows)] - [InlineData(@"\\?\", null, TestOS.Windows)] - [InlineData("//a/", null, TestOS.Windows)] - [InlineData(@"\\a\", null, TestOS.Windows)] - [InlineData(@"C:", null, TestOS.Windows)] - [InlineData(@"D:\", null, TestOS.Windows)] - [InlineData(@"E:/", null, TestOS.Windows)] - [InlineData(@"F:\a", @"F:\", TestOS.Windows)] - [InlineData(@"F:\b\c", @"F:\b", TestOS.Windows)] - [InlineData(@"F:\d/e", @"F:\d", TestOS.Windows)] - [InlineData(@"G:/f", @"G:\", TestOS.Windows)] - [InlineData(@"F:/g\h", @"F:\g", TestOS.Windows)] - [InlineData(@"G:/i/j", @"G:\i", TestOS.Windows)] + [Test] + [Arguments("//", null, TestOS.Windows)] + [Arguments(@"\\", null, TestOS.Windows)] + [Arguments(@"\\", "", TestOS.Linux | TestOS.Mac)] + [Arguments(@"\", "", TestOS.Linux | TestOS.Mac)] + [Arguments(@"/", null, TestOS.Linux | TestOS.Mac)] + [Arguments(@"/a", "/", TestOS.Linux | TestOS.Mac)] + [Arguments(@"/a\b", @"/", TestOS.Linux | TestOS.Mac)] + [Arguments(@"/a\b/c", @"/a\b", TestOS.Linux | TestOS.Mac)] + [Arguments(@"/a/b/c", @"/a/b", TestOS.Linux | TestOS.Mac)] + [Arguments(@"/a/b", "/a", TestOS.Linux | TestOS.Mac)] + [Arguments("//?/G:/", null, TestOS.Windows)] + [Arguments("/??/H:/", @"\??\H:", TestOS.Windows)] + [Arguments("//?/I:/a", @"\\?\I:\", TestOS.Windows)] + [Arguments("/??/J:/a", @"\??\J:", TestOS.Windows)] + [Arguments(@"\\?\K:\", null, TestOS.Windows)] + [Arguments(@"\??\L:\", null, TestOS.Windows)] + [Arguments(@"\\?\M:\a", @"\\?\M:\", TestOS.Windows)] + [Arguments(@"\??\N:\a", @"\??\N:\", TestOS.Windows)] + [Arguments(@"\\?\UNC\", null, TestOS.Windows)] + [Arguments(@"//?/UNC/", null, TestOS.Windows)] + [Arguments(@"\??\UNC\", null, TestOS.Windows)] + [Arguments(@"/??/UNC/", @"\??\UNC", TestOS.Windows)] + [Arguments(@"\\?\UNC\a", null, TestOS.Windows)] + [Arguments(@"//?/UNC/a", null, TestOS.Windows)] + [Arguments(@"\??\UNC\a", null, TestOS.Windows)] + [Arguments(@"/??/UNC/a", @"\??\UNC", TestOS.Windows)] + [Arguments(@"\\?\ABC\", null, TestOS.Windows)] + [Arguments(@"//?/ABC/", null, TestOS.Windows)] + [Arguments(@"\??\XYZ\", null, TestOS.Windows)] + [Arguments(@"/??/XYZ/", @"\??\XYZ", TestOS.Windows)] + [Arguments(@"\\?\unc\a", @"\\?\unc\", TestOS.Windows)] + [Arguments(@"//?/unc/a", @"\\?\unc\", TestOS.Windows)] + [Arguments(@"\??\unc\a", @"\??\unc\", TestOS.Windows)] + [Arguments(@"/??/unc/a", @"\??\unc", TestOS.Windows)] + [Arguments("//./", null, TestOS.Windows)] + [Arguments(@"\\.\", null, TestOS.Windows)] + [Arguments("//?/", null, TestOS.Windows)] + [Arguments(@"\\?\", null, TestOS.Windows)] + [Arguments("//a/", null, TestOS.Windows)] + [Arguments(@"\\a\", null, TestOS.Windows)] + [Arguments(@"C:", null, TestOS.Windows)] + [Arguments(@"D:\", null, TestOS.Windows)] + [Arguments(@"E:/", null, TestOS.Windows)] + [Arguments(@"F:\a", @"F:\", TestOS.Windows)] + [Arguments(@"F:\b\c", @"F:\b", TestOS.Windows)] + [Arguments(@"F:\d/e", @"F:\d", TestOS.Windows)] + [Arguments(@"G:/f", @"G:\", TestOS.Windows)] + [Arguments(@"F:/g\h", @"F:\g", TestOS.Windows)] + [Arguments(@"G:/i/j", @"G:\i", TestOS.Windows)] public async Task GetDirectoryName_SpecialCases_ShouldReturnExpectedValue( string path, string? expected, TestOS operatingSystem) { diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/Path/GetExtensionTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/Path/GetExtensionTests.cs index 9fd7803b6..0f81b16d4 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/Path/GetExtensionTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/Path/GetExtensionTests.cs @@ -1,9 +1,9 @@ namespace Testably.Abstractions.Tests.FileSystem.Path; [FileSystemTests] -public partial class GetExtensionTests +public class GetExtensionTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Fact] + [Test] public async Task GetExtension_Empty_ShouldReturnEmpty() { string? result = FileSystem.Path.GetExtension(string.Empty); @@ -11,7 +11,7 @@ public async Task GetExtension_Empty_ShouldReturnEmpty() await That(result).IsEmpty(); } - [Fact] + [Test] public async Task GetExtension_Null_ShouldReturnNull() { string? result = FileSystem.Path.GetExtension(null); @@ -19,8 +19,8 @@ public async Task GetExtension_Null_ShouldReturnNull() await That(result).IsNull(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetExtension_ShouldReturnExtensionWithLeadingDot( string directory, string filename, string extension) { @@ -33,8 +33,8 @@ public async Task GetExtension_ShouldReturnExtensionWithLeadingDot( } #if FEATURE_SPAN - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetExtension_Span_ShouldReturnExtensionWithLeadingDot( string directory, string filename, string extension) { @@ -47,8 +47,8 @@ public async Task GetExtension_Span_ShouldReturnExtensionWithLeadingDot( } #endif - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetExtension_StartingDot_ShouldReturnCompleteFileName( string directory, string filename) { @@ -59,8 +59,8 @@ public async Task GetExtension_StartingDot_ShouldReturnCompleteFileName( await That(result).IsEqualTo("." + filename); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetExtension_TrailingDot_ShouldReturnEmptyString( string directory, string filename) { diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/Path/GetFileNameTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/Path/GetFileNameTests.cs index 3f7b0608a..f0644e430 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/Path/GetFileNameTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/Path/GetFileNameTests.cs @@ -1,9 +1,9 @@ namespace Testably.Abstractions.Tests.FileSystem.Path; [FileSystemTests] -public partial class GetFileNameTests +public class GetFileNameTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Fact] + [Test] public async Task GetFileName_EmptyString_ShouldReturnEmptyString() { string result = FileSystem.Path.GetFileName(string.Empty); @@ -11,7 +11,7 @@ public async Task GetFileName_EmptyString_ShouldReturnEmptyString() await That(result).IsEqualTo(string.Empty); } - [Fact] + [Test] public async Task GetFileName_Null_ShouldReturnNull() { string? result = FileSystem.Path.GetFileName(null); @@ -19,8 +19,8 @@ public async Task GetFileName_Null_ShouldReturnNull() await That(result).IsNull(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetFileName_ShouldReturnFilename(string directory, string filename, string extension) { @@ -33,8 +33,8 @@ public async Task GetFileName_ShouldReturnFilename(string directory, string file } #if FEATURE_SPAN - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetFileName_Span_ShouldReturnDirectory( string directory, string filename, string extension) @@ -48,11 +48,11 @@ public async Task GetFileName_Span_ShouldReturnDirectory( } #endif - [Theory] - [InlineData("foo/", "", TestOS.All)] - [InlineData("bar\\", "", TestOS.Windows)] - [InlineData("/foo", "foo", TestOS.All)] - [InlineData("\\bar", "bar", TestOS.Windows)] + [Test] + [Arguments("foo/", "", TestOS.All)] + [Arguments("bar\\", "", TestOS.Windows)] + [Arguments("/foo", "foo", TestOS.All)] + [Arguments("\\bar", "bar", TestOS.Windows)] public async Task GetFileName_SpecialCases_ShouldReturnExpectedResult( string? path, string? expected, TestOS operatingSystem) { @@ -63,8 +63,8 @@ public async Task GetFileName_SpecialCases_ShouldReturnExpectedResult( await That(result).IsEqualTo(expected); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetFileName_WithoutDirectory_ShouldReturnFilename(string filename) { string result = FileSystem.Path.GetFileName(filename); diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/Path/GetFileNameWithoutExtensionTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/Path/GetFileNameWithoutExtensionTests.cs index cc26fd7f1..6182aaecd 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/Path/GetFileNameWithoutExtensionTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/Path/GetFileNameWithoutExtensionTests.cs @@ -1,10 +1,10 @@ namespace Testably.Abstractions.Tests.FileSystem.Path; [FileSystemTests] -public partial class GetFileNameWithoutExtensionTests +public class GetFileNameWithoutExtensionTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetFileNameWithoutExtension_MultipleDots_ShouldReturnOnlyRemoveTheLastExtension( string directory, string filename1, string filename2, string extension) @@ -18,7 +18,7 @@ public async Task await That(result).IsEqualTo(filename); } - [Fact] + [Test] public async Task GetFileNameWithoutExtension_Null_ShouldReturnNull() { string? result = FileSystem.Path.GetFileNameWithoutExtension(null); @@ -26,8 +26,8 @@ public async Task GetFileNameWithoutExtension_Null_ShouldReturnNull() await That(result).IsNull(); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetFileNameWithoutExtension_ShouldReturnFileNameWithoutExtension( string directory, string filename, string extension) { @@ -40,8 +40,8 @@ public async Task GetFileNameWithoutExtension_ShouldReturnFileNameWithoutExtensi } #if FEATURE_SPAN - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetFileNameWithoutExtension_Span_ShouldReturnFileNameWithoutExtension( string directory, string filename, string extension) { @@ -55,8 +55,8 @@ public async Task GetFileNameWithoutExtension_Span_ShouldReturnFileNameWithoutEx } #endif - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetFileNameWithoutExtension_StartingDot_ShouldReturnEmptyString( string directory, string filename) { @@ -67,8 +67,8 @@ public async Task GetFileNameWithoutExtension_StartingDot_ShouldReturnEmptyStrin await That(result).IsEqualTo(""); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetFileNameWithoutExtension_TrailingDot_ShouldReturnFilenameWithoutTrailingDot( string directory, string filename) diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/Path/GetFullPathTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/Path/GetFullPathTests.cs index d229019a9..1f5559475 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/Path/GetFullPathTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/Path/GetFullPathTests.cs @@ -1,9 +1,9 @@ namespace Testably.Abstractions.Tests.FileSystem.Path; [FileSystemTests] -public partial class GetFullPathTests +public class GetFullPathTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Fact] + [Test] public async Task GetFullPath_Dot_ShouldReturnToCurrentDirectory() { string expectedFullPath = FileSystem.Directory.GetCurrentDirectory(); @@ -13,16 +13,16 @@ public async Task GetFullPath_Dot_ShouldReturnToCurrentDirectory() await That(result).IsEqualTo(expectedFullPath); } - [Theory] - [InlineData(@"C:\..", @"C:\", TestOS.Windows)] - [InlineData(@"C:\foo", @"C:\foo", TestOS.Windows)] - [InlineData(@"C:\foo\", @"C:\foo\", TestOS.Windows)] - [InlineData(@"\\?\", @"\\?\", TestOS.Windows)] - [InlineData(@"\\?\foo", @"\\?\foo", TestOS.Windows)] - [InlineData(@"\??\", @"\??\", TestOS.Windows)] - [InlineData(@"\??\BAR", @"\??\BAR", TestOS.Windows)] - [InlineData("/foo", "/foo", TestOS.Linux | TestOS.Mac)] - [InlineData("/foo/", "/foo/", TestOS.Linux | TestOS.Mac)] + [Test] + [Arguments(@"C:\..", @"C:\", TestOS.Windows)] + [Arguments(@"C:\foo", @"C:\foo", TestOS.Windows)] + [Arguments(@"C:\foo\", @"C:\foo\", TestOS.Windows)] + [Arguments(@"\\?\", @"\\?\", TestOS.Windows)] + [Arguments(@"\\?\foo", @"\\?\foo", TestOS.Windows)] + [Arguments(@"\??\", @"\??\", TestOS.Windows)] + [Arguments(@"\??\BAR", @"\??\BAR", TestOS.Windows)] + [Arguments("/foo", "/foo", TestOS.Linux | TestOS.Mac)] + [Arguments("/foo/", "/foo/", TestOS.Linux | TestOS.Mac)] public async Task GetFullPath_EdgeCases_ShouldReturnExpectedValue( string path, string expected, TestOS operatingSystem) { @@ -38,9 +38,9 @@ public async Task GetFullPath_EdgeCases_ShouldReturnExpectedValue( await That(result).IsEqualTo(expected); } - [Theory] - [InlineData(@"C:\..", @"C:\", TestOS.Windows)] - [InlineData("/..", "/", TestOS.Linux | TestOS.Mac)] + [Test] + [Arguments(@"C:\..", @"C:\", TestOS.Windows)] + [Arguments("/..", "/", TestOS.Linux | TestOS.Mac)] public async Task GetFullPath_ParentOfRoot_ShouldReturnRoot(string path, string expected, TestOS operatingSystem) { @@ -52,7 +52,7 @@ public async Task GetFullPath_ParentOfRoot_ShouldReturnRoot(string path, } #if FEATURE_PATH_RELATIVE - [Fact] + [Test] public async Task GetFullPath_Relative_NullBasePath_ShouldThrowArgumentNullException() { void Act() @@ -65,7 +65,7 @@ void Act() #endif #if FEATURE_PATH_RELATIVE - [Fact] + [Test] public async Task GetFullPath_Relative_RelativeBasePath_ShouldThrowArgumentException() { string relativeBasePath = "not-fully-qualified-base-path"; @@ -83,10 +83,10 @@ await That(Act).Throws() #endif #if FEATURE_PATH_RELATIVE - [Theory] - [InlineData("top/../most/file", "foo/bar", "foo/bar/most/file")] - [InlineData("top/../most/../dir/file", "foo", "foo/dir/file")] - [InlineData("top/../../most/file", "foo/bar", "foo/most/file")] + [Test] + [Arguments("top/../most/file", "foo/bar", "foo/bar/most/file")] + [Arguments("top/../most/../dir/file", "foo", "foo/dir/file")] + [Arguments("top/../../most/file", "foo/bar", "foo/most/file")] public async Task GetFullPath_Relative_ShouldRemoveRelativeSegments(string input, string basePath, string expected) { @@ -102,10 +102,10 @@ public async Task GetFullPath_Relative_ShouldRemoveRelativeSegments(string input #endif #if FEATURE_PATH_RELATIVE - [Theory] - [InlineData(@"C:\top\..\most\file", @"C:\foo\bar", @"C:\most\file", TestOS.Windows)] - [InlineData(@"C:\top\..\most\file", @"D:\foo\bar", @"C:\most\file", TestOS.Windows)] - [InlineData("/top/../most/file", "/foo/bar", "/most/file", TestOS.Linux | TestOS.Mac)] + [Test] + [Arguments(@"C:\top\..\most\file", @"C:\foo\bar", @"C:\most\file", TestOS.Windows)] + [Arguments(@"C:\top\..\most\file", @"D:\foo\bar", @"C:\most\file", TestOS.Windows)] + [Arguments("/top/../most/file", "/foo/bar", "/most/file", TestOS.Linux | TestOS.Mac)] public async Task GetFullPath_Relative_WithRootedPath_ShouldIgnoreBasePath( string path, string basePath, string expected, TestOS operatingSystem) { @@ -118,7 +118,7 @@ public async Task GetFullPath_Relative_WithRootedPath_ShouldIgnoreBasePath( } #endif - [Fact] + [Test] public async Task GetFullPath_RelativePathWithDrive_ShouldReturnExpectedValue() { Skip.IfNot(Test.RunsOnWindows); @@ -133,7 +133,7 @@ public async Task GetFullPath_RelativePathWithDrive_ShouldReturnExpectedValue() await That(result).IsEqualTo(expectedFullPath); } - [Fact] + [Test] public async Task GetFullPath_RelativePathWithDrive_WhenCurrentDirectoryIsDifferent_ShouldReturnExpectedValue() { @@ -153,9 +153,9 @@ public async Task await That(result).IsEqualTo(expectedFullPath); } - [Theory] - [InlineData(@"X:\foo/bar", @"X:\foo\bar")] - [InlineData(@"Y:\foo/bar/", @"Y:\foo\bar\")] + [Test] + [Arguments(@"X:\foo/bar", @"X:\foo\bar")] + [Arguments(@"Y:\foo/bar/", @"Y:\foo\bar\")] public async Task GetFullPath_ShouldFlipAltDirectorySeparators(string path, string expected) { @@ -166,15 +166,15 @@ public async Task GetFullPath_ShouldFlipAltDirectorySeparators(string path, await That(result).IsEqualTo(expected); } - [Theory] - [InlineData("top/../most/file", "most/file")] - [InlineData("top/../most/../dir/file", "dir/file")] - [InlineData("top/../../most/file", "most/file")] - [InlineData("top/..//../most/file", "most/file")] - [InlineData("top//most//file", "top/most/file")] - [InlineData("top//.//file", "top/file")] - [InlineData("top/most/file/..", "top/most")] - [InlineData("top/..most/file", "top/..most/file")] + [Test] + [Arguments("top/../most/file", "most/file")] + [Arguments("top/../most/../dir/file", "dir/file")] + [Arguments("top/../../most/file", "most/file")] + [Arguments("top/..//../most/file", "most/file")] + [Arguments("top//most//file", "top/most/file")] + [Arguments("top//.//file", "top/file")] + [Arguments("top/most/file/..", "top/most")] + [Arguments("top/..most/file", "top/..most/file")] public async Task GetFullPath_ShouldRemoveRelativeSegments(string input, string expected) { string expectedRootedPath = FileTestHelper.RootDrive(Test, diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/Path/GetPathRootTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/Path/GetPathRootTests.cs index 01095eac0..33c0b1eb6 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/Path/GetPathRootTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/Path/GetPathRootTests.cs @@ -1,30 +1,30 @@ namespace Testably.Abstractions.Tests.FileSystem.Path; [FileSystemTests] -public partial class GetPathRootTests +public class GetPathRootTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [InlineData(@"\\?\foo", @"\\?\foo", TestOS.Windows)] - [InlineData(@"\\.\BAR", @"\\.\BAR", TestOS.Windows)] - [InlineData(@"\\.\.", @"\\.\.", TestOS.Windows)] - [InlineData(@"\\.\\", @"\\.\", TestOS.Windows)] - [InlineData(@"\\.\a\", @"\\.\a\", TestOS.Windows)] - [InlineData(@"\\?\\", @"\\?\", TestOS.Windows)] - [InlineData(@"\\?\a\", @"\\?\a\", TestOS.Windows)] - [InlineData(@"\\?\UNC\", @"\\?\UNC\", TestOS.Windows)] - [InlineData(@"\\?\UNC\Bar", @"\\?\UNC\Bar", TestOS.Windows)] - [InlineData(@"\\?\UNC\a\b\c\d", @"\\?\UNC\a\b", TestOS.Windows)] - [InlineData(@"//?/UNC/a\b\c\d", @"\\?\UNC\a\b", TestOS.Windows)] - [InlineData(@"\\.\UNC\a\b\c\d", @"\\.\UNC\a\b", TestOS.Windows)] - [InlineData(@"//./UNC/a\b\c\d", @"\\.\UNC\a\b", TestOS.Windows)] - [InlineData(@"\\?\ABC\a\b\c\d", @"\\?\ABC\", TestOS.Windows)] - [InlineData(@"//?/ABC\a\b\c\d", @"\\?\ABC\", TestOS.Windows)] - [InlineData(@"\\.\ABC\a\b\c\d", @"\\.\ABC\", TestOS.Windows)] - [InlineData(@"//./ABC\a\b\c\d", @"\\.\ABC\", TestOS.Windows)] - [InlineData(@"\\X\ABC\a\b\c\d", @"\\X\ABC", TestOS.Windows)] - [InlineData(@"//X\ABC\a\b\c\d", @"\\X\ABC", TestOS.Windows)] - [InlineData(@"\??\ABC\a\b\c\d", @"\??\ABC\", TestOS.Windows)] - [InlineData(@"/??/ABC\a\b\c\d", @"\", TestOS.Windows)] + [Test] + [Arguments(@"\\?\foo", @"\\?\foo", TestOS.Windows)] + [Arguments(@"\\.\BAR", @"\\.\BAR", TestOS.Windows)] + [Arguments(@"\\.\.", @"\\.\.", TestOS.Windows)] + [Arguments(@"\\.\\", @"\\.\", TestOS.Windows)] + [Arguments(@"\\.\a\", @"\\.\a\", TestOS.Windows)] + [Arguments(@"\\?\\", @"\\?\", TestOS.Windows)] + [Arguments(@"\\?\a\", @"\\?\a\", TestOS.Windows)] + [Arguments(@"\\?\UNC\", @"\\?\UNC\", TestOS.Windows)] + [Arguments(@"\\?\UNC\Bar", @"\\?\UNC\Bar", TestOS.Windows)] + [Arguments(@"\\?\UNC\a\b\c\d", @"\\?\UNC\a\b", TestOS.Windows)] + [Arguments(@"//?/UNC/a\b\c\d", @"\\?\UNC\a\b", TestOS.Windows)] + [Arguments(@"\\.\UNC\a\b\c\d", @"\\.\UNC\a\b", TestOS.Windows)] + [Arguments(@"//./UNC/a\b\c\d", @"\\.\UNC\a\b", TestOS.Windows)] + [Arguments(@"\\?\ABC\a\b\c\d", @"\\?\ABC\", TestOS.Windows)] + [Arguments(@"//?/ABC\a\b\c\d", @"\\?\ABC\", TestOS.Windows)] + [Arguments(@"\\.\ABC\a\b\c\d", @"\\.\ABC\", TestOS.Windows)] + [Arguments(@"//./ABC\a\b\c\d", @"\\.\ABC\", TestOS.Windows)] + [Arguments(@"\\X\ABC\a\b\c\d", @"\\X\ABC", TestOS.Windows)] + [Arguments(@"//X\ABC\a\b\c\d", @"\\X\ABC", TestOS.Windows)] + [Arguments(@"\??\ABC\a\b\c\d", @"\??\ABC\", TestOS.Windows)] + [Arguments(@"/??/ABC\a\b\c\d", @"\", TestOS.Windows)] public async Task GetPathRoot_EdgeCases_ShouldReturnExpectedValue( string path, string expected, TestOS operatingSystem) { @@ -35,7 +35,7 @@ public async Task GetPathRoot_EdgeCases_ShouldReturnExpectedValue( await That(result).IsEqualTo(expected); } - [Fact] + [Test] public async Task GetPathRoot_Null_ShouldReturnNull() { string? result = FileSystem.Path.GetPathRoot(null); @@ -43,9 +43,9 @@ public async Task GetPathRoot_Null_ShouldReturnNull() await That(result).IsNull(); } - [Theory] - [InlineData("D:")] - [InlineData("D:\\")] + [Test] + [Arguments("D:")] + [Arguments("D:\\")] public async Task GetPathRoot_RootedDrive_ShouldReturnDriveOnWindows(string path) { Skip.IfNot(Test.RunsOnWindows); @@ -55,9 +55,9 @@ public async Task GetPathRoot_RootedDrive_ShouldReturnDriveOnWindows(string path await That(result).IsEqualTo(path); } - [Theory] - [InlineData("D:some-path", "D:")] - [InlineData("D:\\some-path", "D:\\")] + [Test] + [Arguments("D:some-path", "D:")] + [Arguments("D:\\some-path", "D:\\")] public async Task GetPathRoot_RootedDriveWithPath_ShouldReturnDriveOnWindows( string path, string expected) { @@ -68,8 +68,8 @@ public async Task GetPathRoot_RootedDriveWithPath_ShouldReturnDriveOnWindows( await That(result).IsEqualTo(expected); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetPathRoot_ShouldReturnDefaultValue(string path) { string? result = FileSystem.Path.GetPathRoot(path); @@ -78,8 +78,8 @@ public async Task GetPathRoot_ShouldReturnDefaultValue(string path) } #if FEATURE_SPAN - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetPathRoot_Span_ShouldReturnDefaultValue(string path) { ReadOnlySpan result = FileSystem.Path.GetPathRoot(path.AsSpan()); diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/Path/GetRandomFileNameTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/Path/GetRandomFileNameTests.cs index 3f0e2643c..9e150941d 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/Path/GetRandomFileNameTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/Path/GetRandomFileNameTests.cs @@ -3,9 +3,9 @@ namespace Testably.Abstractions.Tests.FileSystem.Path; [FileSystemTests] -public partial class GetRandomFileNameTests +public class GetRandomFileNameTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Fact] + [Test] public async Task GetRandomFileName_ShouldMatch8Dot3Pattern() { string result = FileSystem.Path.GetRandomFileName(); @@ -13,7 +13,7 @@ public async Task GetRandomFileName_ShouldMatch8Dot3Pattern() await That(result).IsEqualTo("????????.???").AsWildcard(); } - [Fact] + [Test] public async Task GetRandomFileName_ShouldReturnRandomFileNameWithExtension() { string result = FileSystem.Path.GetRandomFileName(); @@ -25,7 +25,7 @@ public async Task GetRandomFileName_ShouldReturnRandomFileNameWithExtension() await That(FileSystem.Path.GetFileNameWithoutExtension(result)).IsNotEmpty(); } - [Fact] + [Test] public async Task GetRandomFileName_ShouldReturnRandomStrings() { ConcurrentBag results = []; diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/Path/GetRelativePathTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/Path/GetRelativePathTests.cs index 9e0b39a6d..b928ea617 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/Path/GetRelativePathTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/Path/GetRelativePathTests.cs @@ -5,10 +5,10 @@ namespace Testably.Abstractions.Tests.FileSystem.Path; [FileSystemTests] -public partial class GetRelativePathTests +public class GetRelativePathTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetRelativePath_CommonParentDirectory_ShouldReturnRelativePath( string baseDirectory, string directory1, string directory2) { @@ -20,8 +20,8 @@ public async Task GetRelativePath_CommonParentDirectory_ShouldReturnRelativePath await That(result).IsEqualTo(expectedRelativePath); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetRelativePath_DifferentDrives_ShouldReturnAbsolutePath( string path1, string path2) { @@ -34,27 +34,27 @@ public async Task GetRelativePath_DifferentDrives_ShouldReturnAbsolutePath( await That(result).IsEqualTo(path2); } - [Theory] - [InlineData(@"C:\FOO", @"C:\foo", ".", TestOS.Windows)] - [InlineData("/FOO", "/foo", "../foo", TestOS.Linux)] - [InlineData("/FOO", "/foo", ".", TestOS.Mac)] - [InlineData("foo", "foo/", ".", TestOS.All)] - [InlineData("foo", "foo-bar", "../foo-bar", TestOS.All)] - [InlineData("foo/", "foo/", ".", TestOS.All)] - [InlineData(@"C:\Foo", @"C:\Bar", @"..\Bar", TestOS.Windows)] - [InlineData(@"C:\Foo", @"C:\Bar\", @"..\Bar\", TestOS.Windows)] - [InlineData(@"C:\Foo", @"C:\Foo\Bar", "Bar", TestOS.Windows)] - [InlineData(@"C:\Foo\Bar", @"C:\Foo\", "..", TestOS.Windows)] - [InlineData(@"C:\Foo", @"C:\Foo\Bar\", @"Bar\", TestOS.Windows)] - [InlineData(@"C:\Foo\Bar", @"C:\Bar\Bar", @"..\..\Bar\Bar", TestOS.Windows)] - [InlineData(@"C:\Foo\Foo", @"C:\Foo\Bar", @"..\Bar", TestOS.Windows)] - [InlineData("/Foo", "/Bar", "../Bar", TestOS.Linux | TestOS.Mac)] - [InlineData("/", "/Bar", "Bar", TestOS.Linux | TestOS.Mac)] - [InlineData("/Foo", "/Bar/", "../Bar/", TestOS.Linux | TestOS.Mac)] - [InlineData("/Foo", "/Foo/Bar", "Bar", TestOS.Linux | TestOS.Mac)] - [InlineData("/Foo", "/Foo/Bar/", "Bar/", TestOS.Linux | TestOS.Mac)] - [InlineData("/Foo/Bar", "/Bar/Bar", "../../Bar/Bar", TestOS.Linux | TestOS.Mac)] - [InlineData("/Foo/Foo", "/Foo/Bar", "../Bar", TestOS.Linux | TestOS.Mac)] + [Test] + [Arguments(@"C:\FOO", @"C:\foo", ".", TestOS.Windows)] + [Arguments("/FOO", "/foo", "../foo", TestOS.Linux)] + [Arguments("/FOO", "/foo", ".", TestOS.Mac)] + [Arguments("foo", "foo/", ".", TestOS.All)] + [Arguments("foo", "foo-bar", "../foo-bar", TestOS.All)] + [Arguments("foo/", "foo/", ".", TestOS.All)] + [Arguments(@"C:\Foo", @"C:\Bar", @"..\Bar", TestOS.Windows)] + [Arguments(@"C:\Foo", @"C:\Bar\", @"..\Bar\", TestOS.Windows)] + [Arguments(@"C:\Foo", @"C:\Foo\Bar", "Bar", TestOS.Windows)] + [Arguments(@"C:\Foo\Bar", @"C:\Foo\", "..", TestOS.Windows)] + [Arguments(@"C:\Foo", @"C:\Foo\Bar\", @"Bar\", TestOS.Windows)] + [Arguments(@"C:\Foo\Bar", @"C:\Bar\Bar", @"..\..\Bar\Bar", TestOS.Windows)] + [Arguments(@"C:\Foo\Foo", @"C:\Foo\Bar", @"..\Bar", TestOS.Windows)] + [Arguments("/Foo", "/Bar", "../Bar", TestOS.Linux | TestOS.Mac)] + [Arguments("/", "/Bar", "Bar", TestOS.Linux | TestOS.Mac)] + [Arguments("/Foo", "/Bar/", "../Bar/", TestOS.Linux | TestOS.Mac)] + [Arguments("/Foo", "/Foo/Bar", "Bar", TestOS.Linux | TestOS.Mac)] + [Arguments("/Foo", "/Foo/Bar/", "Bar/", TestOS.Linux | TestOS.Mac)] + [Arguments("/Foo/Bar", "/Bar/Bar", "../../Bar/Bar", TestOS.Linux | TestOS.Mac)] + [Arguments("/Foo/Foo", "/Foo/Bar", "../Bar", TestOS.Linux | TestOS.Mac)] public async Task GetRelativePath_EdgeCases_ShouldReturnExpectedValue(string relativeTo, string path, string expected, TestOS operatingSystem) { @@ -69,7 +69,7 @@ public async Task GetRelativePath_EdgeCases_ShouldReturnExpectedValue(string rel await That(result).IsEqualTo(expected); } - [Fact] + [Test] public async Task GetRelativePath_FromAbsolutePathInCurrentDirectory_ShouldReturnRelativePath() { string rootedPath = FileSystem.Path.Combine(BasePath, "input"); @@ -81,8 +81,8 @@ public async Task GetRelativePath_FromAbsolutePathInCurrentDirectory_ShouldRetur await That(result).IsEqualTo("a.txt"); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetRelativePath_RootedPath_ShouldReturnAbsolutePath( string baseDirectory, string directory1, string directory2) { @@ -95,7 +95,7 @@ public async Task GetRelativePath_RootedPath_ShouldReturnAbsolutePath( await That(result).IsEqualTo(expectedRelativePath); } - [Fact] + [Test] public async Task GetRelativePath_RootedPath_ShouldWorkOnAnyDrive() { Skip.IfNot(Test.RunsOnWindows); @@ -109,8 +109,8 @@ public async Task GetRelativePath_RootedPath_ShouldWorkOnAnyDrive() await That(result).IsEqualTo("subDirectory"); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task GetRelativePath_ToItself_ShouldReturnDot(string path) { string expectedResult = "."; diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/Path/GetTempFileNameTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/Path/GetTempFileNameTests.cs index 6ca37453e..97fe06300 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/Path/GetTempFileNameTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/Path/GetTempFileNameTests.cs @@ -1,9 +1,9 @@ namespace Testably.Abstractions.Tests.FileSystem.Path; [FileSystemTests] -public partial class GetTempFileNameTests +public class GetTempFileNameTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Fact] + [Test] public async Task GetTempFileName_ShouldBeInTempPath() { string tempPath = FileSystem.Path.GetTempPath(); @@ -15,7 +15,7 @@ public async Task GetTempFileName_ShouldBeInTempPath() await That(result).StartsWith(tempPath); } - [Fact] + [Test] public async Task GetTempFileName_ShouldExist() { #pragma warning disable CS0618 // Type or member is obsolete diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/Path/GetTempPathTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/Path/GetTempPathTests.cs index f46ea42e6..7ef8d44e3 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/Path/GetTempPathTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/Path/GetTempPathTests.cs @@ -1,9 +1,9 @@ namespace Testably.Abstractions.Tests.FileSystem.Path; [FileSystemTests] -public partial class GetTempPathTests +public class GetTempPathTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Fact] + [Test] public async Task GetTempPath_Linux_ShouldBeTmp() { Skip.IfNot(Test.RunsOnLinux); @@ -13,7 +13,7 @@ public async Task GetTempPath_Linux_ShouldBeTmp() await That(result).IsEqualTo("/tmp/"); } - [Fact] + [Test] public async Task GetTempPath_MacOs_ShouldBeTmp() { Skip.IfNot(Test.RunsOnMac); @@ -23,7 +23,7 @@ public async Task GetTempPath_MacOs_ShouldBeTmp() await That(result).IsEqualTo("/var/folders/??/*/T/").AsWildcard(); } - [Fact] + [Test] public async Task GetTempPath_ShouldEndWithDirectorySeparator() { string directorySeparator = FileSystem.Path.DirectorySeparatorChar.ToString(); @@ -33,7 +33,7 @@ public async Task GetTempPath_ShouldEndWithDirectorySeparator() await That(result).EndsWith(directorySeparator); } - [Fact] + [Test] public async Task GetTempPath_ShouldRemainTheSame() { string result1 = FileSystem.Path.GetTempPath(); @@ -42,7 +42,7 @@ public async Task GetTempPath_ShouldRemainTheSame() await That(result1).IsEqualTo(result2); } - [Fact] + [Test] public async Task GetTempPath_Windows_ShouldBeOnDriveC() { Skip.IfNot(Test.RunsOnWindows); diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/Path/HasExtensionTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/Path/HasExtensionTests.cs index 9978de0e8..cab50626e 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/Path/HasExtensionTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/Path/HasExtensionTests.cs @@ -1,9 +1,9 @@ namespace Testably.Abstractions.Tests.FileSystem.Path; [FileSystemTests] -public partial class HasExtensionTests +public class HasExtensionTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Fact] + [Test] public async Task HasExtension_Null_ShouldReturnFalse() { bool result = FileSystem.Path.HasExtension(null); @@ -11,12 +11,12 @@ public async Task HasExtension_Null_ShouldReturnFalse() await That(result).IsFalse(); } - [Theory] - [InlineAutoData("abc.", false)] - [InlineAutoData(".foo", true)] - [InlineAutoData(".abc.xyz", true)] - [InlineAutoData("foo", false)] - [InlineAutoData(".", false)] + [Test] + [AutoArguments("abc.", false)] + [AutoArguments(".foo", true)] + [AutoArguments(".abc.xyz", true)] + [AutoArguments("foo", false)] + [AutoArguments(".", false)] public async Task HasExtension_ShouldReturnExpectedResult( string suffix, bool expectedResult, string filename) { @@ -28,12 +28,12 @@ public async Task HasExtension_ShouldReturnExpectedResult( } #if FEATURE_SPAN - [Theory] - [InlineAutoData("abc.", false)] - [InlineAutoData(".foo", true)] - [InlineAutoData(".abc.xyz", true)] - [InlineAutoData("foo", false)] - [InlineAutoData(".", false)] + [Test] + [AutoArguments("abc.", false)] + [AutoArguments(".foo", true)] + [AutoArguments(".abc.xyz", true)] + [AutoArguments("foo", false)] + [AutoArguments(".", false)] public async Task HasExtension_Span_ShouldReturnExpectedResult( string suffix, bool expectedResult, string filename) { diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/Path/IsPathFullyQualifiedTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/Path/IsPathFullyQualifiedTests.cs index a8431b387..c0ee85269 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/Path/IsPathFullyQualifiedTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/Path/IsPathFullyQualifiedTests.cs @@ -2,16 +2,16 @@ namespace Testably.Abstractions.Tests.FileSystem.Path; [FileSystemTests] -public partial class IsPathFullyQualifiedTests +public class IsPathFullyQualifiedTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [InlineData("C", false, TestOS.Windows)] - [InlineData("//", true, TestOS.All)] - [InlineData("/Foo", true, TestOS.Linux | TestOS.Mac)] - [InlineData("/Foo", false, TestOS.Windows)] - [InlineData(@"\\", true, TestOS.Windows)] - [InlineData("/?", true, TestOS.Windows)] - [InlineData(@"\?", true, TestOS.Windows)] + [Test] + [Arguments("C", false, TestOS.Windows)] + [Arguments("//", true, TestOS.All)] + [Arguments("/Foo", true, TestOS.Linux | TestOS.Mac)] + [Arguments("/Foo", false, TestOS.Windows)] + [Arguments(@"\\", true, TestOS.Windows)] + [Arguments("/?", true, TestOS.Windows)] + [Arguments(@"\?", true, TestOS.Windows)] public async Task IsPathFullyQualified_EdgeCases_ShouldReturnExpectedValue( string path, bool expected, TestOS operatingSystem) { @@ -23,8 +23,8 @@ public async Task IsPathFullyQualified_EdgeCases_ShouldReturnExpectedValue( await That(result).IsEqualTo(expected); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task IsPathFullyQualified_PrefixedRoot_ShouldReturnTrue( string directory) { @@ -35,8 +35,8 @@ public async Task IsPathFullyQualified_PrefixedRoot_ShouldReturnTrue( } #if FEATURE_SPAN - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task IsPathFullyQualified_Span_PrefixedRoot_ShouldReturnTrue( string directory) { @@ -48,8 +48,8 @@ public async Task IsPathFullyQualified_Span_PrefixedRoot_ShouldReturnTrue( #endif #if FEATURE_SPAN - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task IsPathFullyQualified_Span_WithoutPrefixedRoot_ShouldReturnFalse( string path) { @@ -59,8 +59,8 @@ public async Task IsPathFullyQualified_Span_WithoutPrefixedRoot_ShouldReturnFals } #endif - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task IsPathFullyQualified_WithoutPrefixedRoot_ShouldReturnFalse( string path) { diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/Path/IsPathRootedTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/Path/IsPathRootedTests.cs index 7a597e5aa..415cd8b5b 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/Path/IsPathRootedTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/Path/IsPathRootedTests.cs @@ -1,10 +1,12 @@ +using System.Collections.Generic; + namespace Testably.Abstractions.Tests.FileSystem.Path; [FileSystemTests] -public partial class IsPathRootedTests +public class IsPathRootedTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [MemberData(nameof(TestData))] + [Test] + [MethodDataSource(nameof(TestData))] public async Task IsPathRooted_ShouldReturnDefaultValue(string path, TestOS isRootedOn) { bool result = FileSystem.Path.IsPathRooted(path); @@ -13,8 +15,8 @@ public async Task IsPathRooted_ShouldReturnDefaultValue(string path, TestOS isRo } #if FEATURE_SPAN - [Theory] - [MemberData(nameof(TestData))] + [Test] + [MethodDataSource(nameof(TestData))] public async Task IsPathRooted_Span_ShouldReturnDefaultValue(string path, TestOS isRootedOn) { bool result = FileSystem.Path.IsPathRooted(path.AsSpan()); @@ -25,53 +27,22 @@ public async Task IsPathRooted_Span_ShouldReturnDefaultValue(string path, TestOS #region Helpers - public static TheoryData TestData() + public static IEnumerable<(string, TestOS)> TestData() { - return new TheoryData - { - { - "", TestOS.None - }, - { - "/", TestOS.All - }, - { - @"\", TestOS.Windows | TestOS.Framework - }, - { - "/foo", TestOS.All - }, - { - @"\foo", TestOS.Windows | TestOS.Framework - }, - { - "foo/bar", TestOS.None - }, - { - "a:", TestOS.Windows | TestOS.Framework - }, - { - "z:", TestOS.Windows | TestOS.Framework - }, - { - "A:", TestOS.Windows | TestOS.Framework - }, - { - "Z:", TestOS.Windows | TestOS.Framework - }, - { - "@:", TestOS.Framework - }, - { - "[:", TestOS.Framework - }, - { - "`:", TestOS.Framework - }, - { - "{:", TestOS.Framework - }, - }; + yield return ("", TestOS.None); + yield return ("/", TestOS.All); + yield return (@"\", TestOS.Windows | TestOS.Framework); + yield return ("/foo", TestOS.All); + yield return (@"\foo", TestOS.Windows | TestOS.Framework); + yield return ("foo/bar", TestOS.None); + yield return ("a:", TestOS.Windows | TestOS.Framework); + yield return ("z:", TestOS.Windows | TestOS.Framework); + yield return ("A:", TestOS.Windows | TestOS.Framework); + yield return ("Z:", TestOS.Windows | TestOS.Framework); + yield return ("@:", TestOS.Framework); + yield return ("[:", TestOS.Framework); + yield return ("`:", TestOS.Framework); + yield return ("{:", TestOS.Framework); } #endregion diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/Path/JoinTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/Path/JoinTests.cs index 287118b86..6b2ebf87e 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/Path/JoinTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/Path/JoinTests.cs @@ -2,11 +2,11 @@ namespace Testably.Abstractions.Tests.FileSystem.Path; [FileSystemTests] -public partial class JoinTests +public class JoinTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [InlineAutoData((string?)null)] - [InlineAutoData("")] + [Test] + [AutoArguments((string?)null)] + [AutoArguments("")] public async Task Join_2Paths_OneNullOrEmpty_ShouldReturnCombinationOfOtherParts( string? missingPath, string? path) { @@ -17,13 +17,13 @@ public async Task Join_2Paths_OneNullOrEmpty_ShouldReturnCombinationOfOtherParts await That(result2).IsEqualTo(path); } - [Theory] - [InlineAutoData("/foo/", "/bar/", "/foo//bar/")] - [InlineAutoData("foo/", "/bar", "foo//bar")] - [InlineAutoData("foo/", "bar", "foo/bar")] - [InlineAutoData("foo", "/bar", "foo/bar")] - [InlineAutoData("foo", "bar", "foo/bar")] - [InlineAutoData("/foo", "bar/", "/foo/bar/")] + [Test] + [AutoArguments("/foo/", "/bar/", "/foo//bar/")] + [AutoArguments("foo/", "/bar", "foo//bar")] + [AutoArguments("foo/", "bar", "foo/bar")] + [AutoArguments("foo", "/bar", "foo/bar")] + [AutoArguments("foo", "bar", "foo/bar")] + [AutoArguments("/foo", "bar/", "/foo/bar/")] public async Task Join_2Paths_ShouldReturnExpectedResult( string path1, string path2, string expectedResult) { @@ -36,8 +36,8 @@ public async Task Join_2Paths_ShouldReturnExpectedResult( await That(result).IsEqualTo(expectedResult); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Join_2Paths_ShouldReturnPathsCombinedByDirectorySeparatorChar( string path1, string path2) { @@ -49,8 +49,8 @@ public async Task Join_2Paths_ShouldReturnPathsCombinedByDirectorySeparatorChar( await That(result).IsEqualTo(expectedResult); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Join_2Paths_Span_ShouldReturnPathsCombinedByDirectorySeparatorChar( string path1, string path2) { @@ -64,9 +64,9 @@ public async Task Join_2Paths_Span_ShouldReturnPathsCombinedByDirectorySeparator await That(result).IsEqualTo(expectedResult); } - [Theory] - [InlineAutoData((string?)null)] - [InlineAutoData("")] + [Test] + [AutoArguments((string?)null)] + [AutoArguments("")] public async Task Join_3Paths_OneNullOrEmpty_ShouldReturnCombinationOfOtherParts( string? missingPath, string path1, string path2) { @@ -81,14 +81,14 @@ public async Task Join_3Paths_OneNullOrEmpty_ShouldReturnCombinationOfOtherParts await That(result3).IsEqualTo(expectedPath); } - [Theory] - [InlineAutoData("/foo/", "/bar/", "/baz/", "/foo//bar//baz/")] - [InlineAutoData("foo/", "/bar/", "/baz", "foo//bar//baz")] - [InlineAutoData("foo/", "bar", "/baz", "foo/bar/baz")] - [InlineAutoData("foo", "/bar", "/baz", "foo/bar/baz")] - [InlineAutoData("foo", "/bar/", "baz", "foo/bar/baz")] - [InlineAutoData("foo", "bar", "baz", "foo/bar/baz")] - [InlineAutoData("/foo", "bar", "baz/", "/foo/bar/baz/")] + [Test] + [AutoArguments("/foo/", "/bar/", "/baz/", "/foo//bar//baz/")] + [AutoArguments("foo/", "/bar/", "/baz", "foo//bar//baz")] + [AutoArguments("foo/", "bar", "/baz", "foo/bar/baz")] + [AutoArguments("foo", "/bar", "/baz", "foo/bar/baz")] + [AutoArguments("foo", "/bar/", "baz", "foo/bar/baz")] + [AutoArguments("foo", "bar", "baz", "foo/bar/baz")] + [AutoArguments("/foo", "bar", "baz/", "/foo/bar/baz/")] public async Task Join_3Paths_ShouldReturnExpectedResult( string path1, string path2, string path3, string expectedResult) { @@ -102,8 +102,8 @@ public async Task Join_3Paths_ShouldReturnExpectedResult( await That(result).IsEqualTo(expectedResult); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Join_3Paths_ShouldReturnPathsCombinedByDirectorySeparatorChar( string path1, string path2, string path3) { @@ -116,8 +116,8 @@ public async Task Join_3Paths_ShouldReturnPathsCombinedByDirectorySeparatorChar( await That(result).IsEqualTo(expectedResult); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Join_3Paths_Span_ShouldReturnPathsCombinedByDirectorySeparatorChar( string path1, string path2, string path3) { @@ -133,9 +133,9 @@ public async Task Join_3Paths_Span_ShouldReturnPathsCombinedByDirectorySeparator await That(result).IsEqualTo(expectedResult); } - [Theory] - [InlineAutoData((string?)null)] - [InlineAutoData("")] + [Test] + [AutoArguments((string?)null)] + [AutoArguments("")] public async Task Join_4Paths_OneNullOrEmpty_ShouldReturnCombinationOfOtherParts( string? missingPath, string path1, string path2, string path3) { @@ -153,14 +153,14 @@ public async Task Join_4Paths_OneNullOrEmpty_ShouldReturnCombinationOfOtherParts await That(result4).IsEqualTo(expectedPath); } - [Theory] - [InlineAutoData("/foo/", "/bar/", "/baz/", "/muh/", "/foo//bar//baz//muh/")] - [InlineAutoData("foo/", "/bar/", "/baz/", "/muh", "foo//bar//baz//muh")] - [InlineAutoData("foo/", "bar", "/baz", "/muh", "foo/bar/baz/muh")] - [InlineAutoData("foo", "/bar", "/baz", "/muh", "foo/bar/baz/muh")] - [InlineAutoData("foo", "/bar/", "baz/", "muh", "foo/bar/baz/muh")] - [InlineAutoData("foo", "bar", "baz", "muh", "foo/bar/baz/muh")] - [InlineAutoData("/foo", "bar", "baz", "muh/", "/foo/bar/baz/muh/")] + [Test] + [AutoArguments("/foo/", "/bar/", "/baz/", "/muh/", "/foo//bar//baz//muh/")] + [AutoArguments("foo/", "/bar/", "/baz/", "/muh", "foo//bar//baz//muh")] + [AutoArguments("foo/", "bar", "/baz", "/muh", "foo/bar/baz/muh")] + [AutoArguments("foo", "/bar", "/baz", "/muh", "foo/bar/baz/muh")] + [AutoArguments("foo", "/bar/", "baz/", "muh", "foo/bar/baz/muh")] + [AutoArguments("foo", "bar", "baz", "muh", "foo/bar/baz/muh")] + [AutoArguments("/foo", "bar", "baz", "muh/", "/foo/bar/baz/muh/")] public async Task Join_4Paths_ShouldReturnExpectedResult( string path1, string path2, string path3, string path4, string expectedResult) { @@ -175,8 +175,8 @@ public async Task Join_4Paths_ShouldReturnExpectedResult( await That(result).IsEqualTo(expectedResult); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Join_4Paths_ShouldReturnPathsCombinedByDirectorySeparatorChar( string path1, string path2, string path3, string path4) { @@ -190,8 +190,8 @@ public async Task Join_4Paths_ShouldReturnPathsCombinedByDirectorySeparatorChar( await That(result).IsEqualTo(expectedResult); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Join_4Paths_Span_ShouldReturnPathsCombinedByDirectorySeparatorChar( string path1, string path2, string path3, string path4) { @@ -209,7 +209,7 @@ public async Task Join_4Paths_Span_ShouldReturnPathsCombinedByDirectorySeparator await That(result).IsEqualTo(expectedResult); } - [Fact] + [Test] public async Task Join_ParamPaths_Empty_ShouldReturnEmptyString() { string?[] paths = []; @@ -219,7 +219,7 @@ public async Task Join_ParamPaths_Empty_ShouldReturnEmptyString() await That(result).IsEqualTo(string.Empty); } - [Fact] + [Test] public async Task Join_ParamPaths_Null_ShouldThrow() { void Act() @@ -230,9 +230,9 @@ void Act() await That(Act).Throws().WithParamName("paths"); } - [Theory] - [InlineAutoData((string?)null)] - [InlineAutoData("")] + [Test] + [AutoArguments((string?)null)] + [AutoArguments("")] public async Task Join_ParamPaths_OneNullOrEmpty_ShouldReturnCombinationOfOtherParts( string? missingPath, string path1, string path2, string path3, string path4) { @@ -292,14 +292,14 @@ public async Task Join_ParamPaths_OneNullOrEmpty_ShouldReturnCombinationOfOtherP await That(result5).IsEqualTo(expectedPath); } - [Theory] - [InlineAutoData("/foo/", "/bar/", "/baz/", "/muh/", "/maeh/", "/foo//bar//baz//muh//maeh/")] - [InlineAutoData("foo/", "/bar/", "/baz/", "/muh", "/maeh", "foo//bar//baz//muh/maeh")] - [InlineAutoData("foo/", "bar", "/baz", "/muh", "/maeh", "foo/bar/baz/muh/maeh")] - [InlineAutoData("foo", "/bar", "/baz", "/muh", "/maeh", "foo/bar/baz/muh/maeh")] - [InlineAutoData("foo", "/bar/", "baz/", "muh/", "maeh", "foo/bar/baz/muh/maeh")] - [InlineAutoData("foo", "bar", "baz", "muh", "maeh", "foo/bar/baz/muh/maeh")] - [InlineAutoData("/foo", "bar", "baz", "muh", "maeh/", "/foo/bar/baz/muh/maeh/")] + [Test] + [AutoArguments("/foo/", "/bar/", "/baz/", "/muh/", "/maeh/", "/foo//bar//baz//muh//maeh/")] + [AutoArguments("foo/", "/bar/", "/baz/", "/muh", "/maeh", "foo//bar//baz//muh/maeh")] + [AutoArguments("foo/", "bar", "/baz", "/muh", "/maeh", "foo/bar/baz/muh/maeh")] + [AutoArguments("foo", "/bar", "/baz", "/muh", "/maeh", "foo/bar/baz/muh/maeh")] + [AutoArguments("foo", "/bar/", "baz/", "muh/", "maeh", "foo/bar/baz/muh/maeh")] + [AutoArguments("foo", "bar", "baz", "muh", "maeh", "foo/bar/baz/muh/maeh")] + [AutoArguments("/foo", "bar", "baz", "muh", "maeh/", "/foo/bar/baz/muh/maeh/")] public async Task Join_ParamPaths_ShouldReturnExpectedResult( string path1, string path2, string path3, string path4, string path5, string expectedResult) { @@ -322,8 +322,8 @@ public async Task Join_ParamPaths_ShouldReturnExpectedResult( await That(result).IsEqualTo(expectedResult); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Join_ParamPaths_ShouldReturnPathsCombinedByDirectorySeparatorChar( string path1, string path2, string path3, string path4, string path5) { @@ -340,7 +340,7 @@ public async Task Join_ParamPaths_ShouldReturnPathsCombinedByDirectorySeparatorC #if FEATURE_PATH_SPAN - [Fact] + [Test] public async Task Join_ReadOnlySpanPaths_Empty_ShouldReturnEmptyString() { ReadOnlySpan paths = Array.Empty(); @@ -350,9 +350,9 @@ public async Task Join_ReadOnlySpanPaths_Empty_ShouldReturnEmptyString() await That(result).IsEqualTo(string.Empty); } - [Theory] - [InlineAutoData((string?)null)] - [InlineAutoData("")] + [Test] + [AutoArguments((string?)null)] + [AutoArguments("")] public async Task Join_ReadOnlySpanPaths_OneNullOrEmpty_ShouldReturnCombinationOfOtherParts( string? missingPath, string path1, string path2, string path3, string path4) { @@ -377,14 +377,14 @@ public async Task Join_ReadOnlySpanPaths_OneNullOrEmpty_ShouldReturnCombinationO await That(result5).IsEqualTo(expectedPath); } - [Theory] - [InlineAutoData("/foo/", "/bar/", "/baz/", "/muh/", "/maeh/", "/foo//bar//baz//muh//maeh/")] - [InlineAutoData("foo/", "/bar/", "/baz/", "/muh", "/maeh", "foo//bar//baz//muh/maeh")] - [InlineAutoData("foo/", "bar", "/baz", "/muh", "/maeh", "foo/bar/baz/muh/maeh")] - [InlineAutoData("foo", "/bar", "/baz", "/muh", "/maeh", "foo/bar/baz/muh/maeh")] - [InlineAutoData("foo", "/bar/", "baz/", "muh/", "maeh", "foo/bar/baz/muh/maeh")] - [InlineAutoData("foo", "bar", "baz", "muh", "maeh", "foo/bar/baz/muh/maeh")] - [InlineAutoData("/foo", "bar", "baz", "muh", "maeh/", "/foo/bar/baz/muh/maeh/")] + [Test] + [AutoArguments("/foo/", "/bar/", "/baz/", "/muh/", "/maeh/", "/foo//bar//baz//muh//maeh/")] + [AutoArguments("foo/", "/bar/", "/baz/", "/muh", "/maeh", "foo//bar//baz//muh/maeh")] + [AutoArguments("foo/", "bar", "/baz", "/muh", "/maeh", "foo/bar/baz/muh/maeh")] + [AutoArguments("foo", "/bar", "/baz", "/muh", "/maeh", "foo/bar/baz/muh/maeh")] + [AutoArguments("foo", "/bar/", "baz/", "muh/", "maeh", "foo/bar/baz/muh/maeh")] + [AutoArguments("foo", "bar", "baz", "muh", "maeh", "foo/bar/baz/muh/maeh")] + [AutoArguments("/foo", "bar", "baz", "muh", "maeh/", "/foo/bar/baz/muh/maeh/")] public async Task Join_ReadOnlySpanPaths_ShouldReturnExpectedResult( string path1, string path2, string path3, string path4, string path5, string expectedResult) { @@ -400,8 +400,8 @@ public async Task Join_ReadOnlySpanPaths_ShouldReturnExpectedResult( await That(result).IsEqualTo(expectedResult); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task Join_ReadOnlySpanPaths_ShouldReturnPathsCombinedByDirectorySeparatorChar( string path1, string path2, string path3, string path4, string path5) { diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/Path/Tests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/Path/Tests.cs index dcf914006..30a725278 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/Path/Tests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/Path/Tests.cs @@ -3,9 +3,9 @@ namespace Testably.Abstractions.Tests.FileSystem.Path; [FileSystemTests] -public partial class Tests +public class Tests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Fact] + [Test] public async Task AltDirectorySeparatorChar_ShouldReturnSlash() { char result = FileSystem.Path.AltDirectorySeparatorChar; @@ -13,7 +13,7 @@ public async Task AltDirectorySeparatorChar_ShouldReturnSlash() await That(result).IsEqualTo('/'); } - [Fact] + [Test] public async Task DirectorySeparatorChar_WhenNotOnWindows_ShouldReturnSlash() { Skip.If(Test.RunsOnWindows); @@ -23,7 +23,7 @@ public async Task DirectorySeparatorChar_WhenNotOnWindows_ShouldReturnSlash() await That(result).IsEqualTo('/'); } - [Fact] + [Test] public async Task DirectorySeparatorChar_WhenOnWindows_ShouldReturnBackslash() { Skip.IfNot(Test.RunsOnWindows); @@ -33,7 +33,7 @@ public async Task DirectorySeparatorChar_WhenOnWindows_ShouldReturnBackslash() await That(result).IsEqualTo('\\'); } - [Fact] + [Test] public async Task GetInvalidFileNameChars_WhenNotOnWindows_ShouldReturnCorrectValues() { Skip.If(Test.RunsOnWindows); @@ -45,7 +45,7 @@ public async Task GetInvalidFileNameChars_WhenNotOnWindows_ShouldReturnCorrectVa await That(result).IsEqualTo(expected).InAnyOrder(); } - [Fact] + [Test] public async Task GetInvalidFileNameChars_WhenOnWindows_ShouldReturnCorrectValues() { Skip.IfNot(Test.RunsOnWindows); @@ -64,7 +64,7 @@ public async Task GetInvalidFileNameChars_WhenOnWindows_ShouldReturnCorrectValue await That(result).IsEqualTo(expected).InAnyOrder(); } - [Fact] + [Test] public async Task GetInvalidPathChars_WhenNotOnWindows_ShouldReturnCorrectValues() { Skip.If(Test.RunsOnWindows); @@ -76,7 +76,7 @@ public async Task GetInvalidPathChars_WhenNotOnWindows_ShouldReturnCorrectValues await That(result).IsEqualTo(expected).InAnyOrder(); } - [Fact] + [Test] public async Task GetInvalidPathChars_WhenOnWindows_ShouldReturnCorrectValues() { Skip.IfNot(Test.RunsOnWindows); @@ -98,7 +98,7 @@ public async Task GetInvalidPathChars_WhenOnWindows_ShouldReturnCorrectValues() await That(result).IsEqualTo(expected).InAnyOrder(); } - [Fact] + [Test] public async Task PathSeparator_WhenNotOnWindows_ShouldReturnColon() { Skip.If(Test.RunsOnWindows); @@ -108,7 +108,7 @@ public async Task PathSeparator_WhenNotOnWindows_ShouldReturnColon() await That(result).IsEqualTo(':'); } - [Fact] + [Test] public async Task PathSeparator_WhenOnWindows_ShouldReturnSemicolon() { Skip.IfNot(Test.RunsOnWindows); @@ -118,7 +118,7 @@ public async Task PathSeparator_WhenOnWindows_ShouldReturnSemicolon() await That(result).IsEqualTo(';'); } - [Fact] + [Test] public async Task VolumeSeparatorChar_WhenNotOnWindows_ShouldReturnSlash() { Skip.If(Test.RunsOnWindows); @@ -128,7 +128,7 @@ public async Task VolumeSeparatorChar_WhenNotOnWindows_ShouldReturnSlash() await That(result).IsEqualTo('/'); } - [Fact] + [Test] public async Task VolumeSeparatorChar_WhenOnWindows_ShouldReturnColon() { Skip.IfNot(Test.RunsOnWindows); diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/Path/TrimEndingDirectorySeparatorTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/Path/TrimEndingDirectorySeparatorTests.cs index 1d8a182d8..63429aff5 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/Path/TrimEndingDirectorySeparatorTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/Path/TrimEndingDirectorySeparatorTests.cs @@ -2,10 +2,10 @@ namespace Testably.Abstractions.Tests.FileSystem.Path; [FileSystemTests] -public partial class TrimEndingDirectorySeparatorTests +public class TrimEndingDirectorySeparatorTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task TrimEndingDirectorySeparator_DirectoryChar_ShouldTrim( string directory) { @@ -16,7 +16,7 @@ public async Task TrimEndingDirectorySeparator_DirectoryChar_ShouldTrim( await That(result).IsEqualTo(directory); } - [Fact] + [Test] public async Task TrimEndingDirectorySeparator_EmptyString_ShouldReturnEmptyString() { string result = FileSystem.Path.TrimEndingDirectorySeparator(string.Empty); @@ -24,7 +24,7 @@ public async Task TrimEndingDirectorySeparator_EmptyString_ShouldReturnEmptyStri await That(result).IsEqualTo(string.Empty); } - [Fact] + [Test] public async Task TrimEndingDirectorySeparator_Root_ShouldReturnUnchanged() { string path = FileTestHelper.RootDrive(Test); @@ -34,8 +34,8 @@ public async Task TrimEndingDirectorySeparator_Root_ShouldReturnUnchanged() await That(result).IsEqualTo(path); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task TrimEndingDirectorySeparator_Span_DirectoryChar_ShouldTrim( string directory) { @@ -47,7 +47,7 @@ public async Task TrimEndingDirectorySeparator_Span_DirectoryChar_ShouldTrim( await That(result.ToString()).IsEqualTo(directory); } - [Fact] + [Test] public async Task TrimEndingDirectorySeparator_Span_Root_ShouldReturnUnchanged() { string path = FileTestHelper.RootDrive(Test); @@ -58,8 +58,8 @@ public async Task TrimEndingDirectorySeparator_Span_Root_ShouldReturnUnchanged() await That(result.ToString()).IsEqualTo(path); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task TrimEndingDirectorySeparator_Span_WithoutDirectoryChar_ShouldReturnUnchanged( string path) @@ -70,8 +70,8 @@ public async Task await That(result.ToString()).IsEqualTo(path); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task TrimEndingDirectorySeparator_WithoutDirectoryChar_ShouldReturnUnchanged( string path) { diff --git a/Tests/Testably.Abstractions.Tests/FileSystem/Path/TryJoinTests.cs b/Tests/Testably.Abstractions.Tests/FileSystem/Path/TryJoinTests.cs index 41dbc660f..61e16ce89 100644 --- a/Tests/Testably.Abstractions.Tests/FileSystem/Path/TryJoinTests.cs +++ b/Tests/Testably.Abstractions.Tests/FileSystem/Path/TryJoinTests.cs @@ -2,10 +2,10 @@ namespace Testably.Abstractions.Tests.FileSystem.Path; [FileSystemTests] -public partial class TryJoinTests +public class TryJoinTests(FileSystemTestData testData) : FileSystemTestBase(testData) { - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task TryJoin_2Paths_BufferTooLittle_ShouldReturnFalse( string path1, string path2) { @@ -25,13 +25,13 @@ public async Task TryJoin_2Paths_BufferTooLittle_ShouldReturnFalse( await That(charsWritten).IsEqualTo(0); } - [Theory] - [InlineAutoData("/foo/", "/bar/", "/foo//bar/")] - [InlineAutoData("foo/", "/bar", "foo//bar")] - [InlineAutoData("foo/", "bar", "foo/bar")] - [InlineAutoData("foo", "/bar", "foo/bar")] - [InlineAutoData("foo", "bar", "foo/bar")] - [InlineAutoData("/foo", "bar/", "/foo/bar/")] + [Test] + [AutoArguments("/foo/", "/bar/", "/foo//bar/")] + [AutoArguments("foo/", "/bar", "foo//bar")] + [AutoArguments("foo/", "bar", "foo/bar")] + [AutoArguments("foo", "/bar", "foo/bar")] + [AutoArguments("foo", "bar", "foo/bar")] + [AutoArguments("/foo", "bar/", "/foo/bar/")] public async Task TryJoin_2Paths_ShouldReturnExpectedResult( string path1, string path2, string expectedResult) { @@ -53,8 +53,8 @@ public async Task TryJoin_2Paths_ShouldReturnExpectedResult( await That(writtenString).IsEqualTo(expectedResult); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task TryJoin_2Paths_ShouldReturnPathsCombinedByDirectorySeparatorChar( string path1, string path2) { @@ -76,8 +76,8 @@ public async Task TryJoin_2Paths_ShouldReturnPathsCombinedByDirectorySeparatorCh await That(writtenString).IsEqualTo(expectedResult); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task TryJoin_3Paths_BufferTooLittle_ShouldReturnFalse( string path1, string path2, string path3) { @@ -99,14 +99,14 @@ public async Task TryJoin_3Paths_BufferTooLittle_ShouldReturnFalse( await That(charsWritten).IsEqualTo(0); } - [Theory] - [InlineAutoData("/foo/", "/bar/", "/baz/", "/foo//bar//baz/")] - [InlineAutoData("foo/", "/bar/", "/baz", "foo//bar//baz")] - [InlineAutoData("foo/", "bar", "/baz", "foo/bar/baz")] - [InlineAutoData("foo", "/bar", "/baz", "foo/bar/baz")] - [InlineAutoData("foo", "/bar/", "baz", "foo/bar/baz")] - [InlineAutoData("foo", "bar", "baz", "foo/bar/baz")] - [InlineAutoData("/foo", "bar", "baz/", "/foo/bar/baz/")] + [Test] + [AutoArguments("/foo/", "/bar/", "/baz/", "/foo//bar//baz/")] + [AutoArguments("foo/", "/bar/", "/baz", "foo//bar//baz")] + [AutoArguments("foo/", "bar", "/baz", "foo/bar/baz")] + [AutoArguments("foo", "/bar", "/baz", "foo/bar/baz")] + [AutoArguments("foo", "/bar/", "baz", "foo/bar/baz")] + [AutoArguments("foo", "bar", "baz", "foo/bar/baz")] + [AutoArguments("/foo", "bar", "baz/", "/foo/bar/baz/")] public async Task TryJoin_3Paths_ShouldReturnExpectedResult( string path1, string path2, string path3, string expectedResult) { @@ -130,8 +130,8 @@ public async Task TryJoin_3Paths_ShouldReturnExpectedResult( await That(writtenString).IsEqualTo(expectedResult); } - [Theory] - [AutoData] + [Test] + [AutoArguments] public async Task TryJoin_3Paths_ShouldReturnPathsCombinedByDirectorySeparatorChar( string path1, string path2, string path3) { diff --git a/Tests/Testably.Abstractions.Tests/Internal/DirectoryInfoWrapperTests.cs b/Tests/Testably.Abstractions.Tests/Internal/DirectoryInfoWrapperTests.cs index 063e8aeaf..9ba08afb1 100644 --- a/Tests/Testably.Abstractions.Tests/Internal/DirectoryInfoWrapperTests.cs +++ b/Tests/Testably.Abstractions.Tests/Internal/DirectoryInfoWrapperTests.cs @@ -4,7 +4,7 @@ namespace Testably.Abstractions.Tests.Internal; public class DirectoryInfoWrapperTests { - [Fact] + [Test] public async Task FromDirectoryInfo_Null_ShouldReturnNull() { RealFileSystem fileSystem = new(); @@ -15,8 +15,8 @@ public async Task FromDirectoryInfo_Null_ShouldReturnNull() await That(result).IsNull(); } - [Theory] - [AutoData] + [Test] + [Arguments("my-path")] public async Task FromDirectoryInfo_ShouldBePartOfFileSystem(string path) { RealFileSystem fileSystem = new(); diff --git a/Tests/Testably.Abstractions.Tests/Internal/DriveInfoWrapperTests.cs b/Tests/Testably.Abstractions.Tests/Internal/DriveInfoWrapperTests.cs index 5c45709dd..890e8ec2d 100644 --- a/Tests/Testably.Abstractions.Tests/Internal/DriveInfoWrapperTests.cs +++ b/Tests/Testably.Abstractions.Tests/Internal/DriveInfoWrapperTests.cs @@ -2,7 +2,7 @@ public class DriveInfoWrapperTests { - [Fact] + [Test] public async Task FromDriveInfo_Null_ShouldReturnNull() { RealFileSystem fileSystem = new(); diff --git a/Tests/Testably.Abstractions.Tests/Internal/FileInfoWrapperTests.cs b/Tests/Testably.Abstractions.Tests/Internal/FileInfoWrapperTests.cs index 5e05afd3e..e1541b56d 100644 --- a/Tests/Testably.Abstractions.Tests/Internal/FileInfoWrapperTests.cs +++ b/Tests/Testably.Abstractions.Tests/Internal/FileInfoWrapperTests.cs @@ -4,7 +4,7 @@ namespace Testably.Abstractions.Tests.Internal; public class FileInfoWrapperTests { - [Fact] + [Test] public async Task FromFileInfo_Null_ShouldReturnNull() { RealFileSystem fileSystem = new(); @@ -15,8 +15,8 @@ public async Task FromFileInfo_Null_ShouldReturnNull() await That(result).IsNull(); } - [Theory] - [AutoData] + [Test] + [Arguments("my-path")] public async Task FromFileInfo_ShouldBePartOfFileSystem(string path) { RealFileSystem fileSystem = new(); diff --git a/Tests/Testably.Abstractions.Tests/Internal/FileStreamWrapperTests.cs b/Tests/Testably.Abstractions.Tests/Internal/FileStreamWrapperTests.cs index d8c2a63c9..86918c760 100644 --- a/Tests/Testably.Abstractions.Tests/Internal/FileStreamWrapperTests.cs +++ b/Tests/Testably.Abstractions.Tests/Internal/FileStreamWrapperTests.cs @@ -4,7 +4,7 @@ namespace Testably.Abstractions.Tests.Internal; -[Collection("RealFileSystemTests")] +[NotInParallel(nameof(RealFileSystem))] public sealed class FileStreamWrapperTests : IDisposable { #region Test Setup @@ -13,13 +13,13 @@ public sealed class FileStreamWrapperTests : IDisposable private readonly IDirectoryCleaner _directoryCleaner; - public FileStreamWrapperTests(ITestOutputHelper testOutputHelper) + public FileStreamWrapperTests() { FileSystem = new RealFileSystem(); _directoryCleaner = FileSystem .SetCurrentDirectoryToEmptyTemporaryDirectory( $"Testably.Abstractions.Tests.Internal{FileSystem.Path.DirectorySeparatorChar}FileStreamWrapperTests-", - testOutputHelper.WriteLine); + Console.WriteLine); } /// @@ -28,8 +28,8 @@ public void Dispose() #endregion - [Theory] - [AutoData] + [Test] + [Arguments("my-path", "my-key", "my-value")] public async Task RetrieveMetadata_ShouldReturnStoredValue(string path, string key, object value) { @@ -44,8 +44,8 @@ public async Task RetrieveMetadata_ShouldReturnStoredValue(string path, string k await That(result).IsEqualTo(value); } - [Theory] - [AutoData] + [Test] + [Arguments("my-path")] public async Task TryGetWrappedInstance_ShouldReturnWrappedInstance(string path) { using FileSystemStream sut = FileSystem.FileStream.New(path, FileMode.OpenOrCreate); diff --git a/Tests/Testably.Abstractions.Tests/Internal/FileSystemExtensibilityTests.cs b/Tests/Testably.Abstractions.Tests/Internal/FileSystemExtensibilityTests.cs index 28ba922cc..38c4ef78f 100644 --- a/Tests/Testably.Abstractions.Tests/Internal/FileSystemExtensibilityTests.cs +++ b/Tests/Testably.Abstractions.Tests/Internal/FileSystemExtensibilityTests.cs @@ -5,8 +5,8 @@ namespace Testably.Abstractions.Tests.Internal; public class FileSystemExtensibilityTests { - [Theory] - [AutoData] + [Test] + [Arguments("my-path", "my-key")] public async Task RetrieveMetadata_IncorrectType_ShouldReturnNull(string path, string key) { FileInfo value = new(path); @@ -20,8 +20,8 @@ public async Task RetrieveMetadata_IncorrectType_ShouldReturnNull(string path, s await That(result).IsNull(); } - [Theory] - [AutoData] + [Test] + [Arguments("my-path", "my-key")] public async Task RetrieveMetadata_WithoutStoringBefore_ShouldReturnDefault(string path, string key) { @@ -34,8 +34,8 @@ public async Task RetrieveMetadata_WithoutStoringBefore_ShouldReturnDefault(stri await That(result).IsNull(); } - [Theory] - [AutoData] + [Test] + [Arguments("my-path", "my-key", "my-value")] public async Task StoreMetadata_ShouldMakeValueRetrievable(string path, string key, object value) { @@ -49,8 +49,8 @@ public async Task StoreMetadata_ShouldMakeValueRetrievable(string path, string k await That(result).IsEqualTo(value); } - [Theory] - [AutoData] + [Test] + [Arguments("my-path")] public async Task TryGetWrappedInstance_IncorrectType_ShouldReturnNull(string path) { RealFileSystem fileSystem = new(); @@ -63,8 +63,8 @@ public async Task TryGetWrappedInstance_IncorrectType_ShouldReturnNull(string pa await That(fileInfo).IsNull(); } - [Theory] - [AutoData] + [Test] + [Arguments("my-path")] public async Task TryGetWrappedInstance_ShouldReturnWrappedInstance(string path) { RealFileSystem fileSystem = new(); diff --git a/Tests/Testably.Abstractions.Tests/Internal/FileSystemInfoWrapperTests.cs b/Tests/Testably.Abstractions.Tests/Internal/FileSystemInfoWrapperTests.cs index b89a24ea4..649f344b8 100644 --- a/Tests/Testably.Abstractions.Tests/Internal/FileSystemInfoWrapperTests.cs +++ b/Tests/Testably.Abstractions.Tests/Internal/FileSystemInfoWrapperTests.cs @@ -4,7 +4,7 @@ namespace Testably.Abstractions.Tests.Internal; public class FileSystemInfoWrapperTests { - [Fact] + [Test] public async Task FromFileSystemInfo_Null_ShouldReturnNull() { RealFileSystem fileSystem = new(); @@ -15,8 +15,8 @@ public async Task FromFileSystemInfo_Null_ShouldReturnNull() await That(result).IsNull(); } - [Theory] - [AutoData] + [Test] + [Arguments("my-path")] public async Task FromFileSystemInfo_WithDirectoryInfo_ShouldReturnDirectoryInfoWrapper( string path) { @@ -28,8 +28,8 @@ public async Task FromFileSystemInfo_WithDirectoryInfo_ShouldReturnDirectoryInfo await That(result).IsExactly(); } - [Theory] - [AutoData] + [Test] + [Arguments("my-path")] public async Task FromFileSystemInfo_WithFileInfo_ShouldReturnFileInfoWrapper(string path) { RealFileSystem fileSystem = new(); diff --git a/Tests/Testably.Abstractions.Tests/Internal/FileSystemWatcherWrapperTests.cs b/Tests/Testably.Abstractions.Tests/Internal/FileSystemWatcherWrapperTests.cs index de9282867..c4ecfdc67 100644 --- a/Tests/Testably.Abstractions.Tests/Internal/FileSystemWatcherWrapperTests.cs +++ b/Tests/Testably.Abstractions.Tests/Internal/FileSystemWatcherWrapperTests.cs @@ -2,7 +2,7 @@ public class FileSystemWatcherWrapperTests { - [Fact] + [Test] public async Task FromFileSystemWatcher_Null_ShouldReturnNull() { RealFileSystem fileSystem = new(); diff --git a/Tests/Testably.Abstractions.Tests/RandomSystem/GuidTests.cs b/Tests/Testably.Abstractions.Tests/RandomSystem/GuidTests.cs index 3596baff0..652161fd5 100644 --- a/Tests/Testably.Abstractions.Tests/RandomSystem/GuidTests.cs +++ b/Tests/Testably.Abstractions.Tests/RandomSystem/GuidTests.cs @@ -10,10 +10,10 @@ namespace Testably.Abstractions.Tests.RandomSystem; [RandomSystemTests] -public partial class GuidTests +public class GuidTests(RandomSystemTestData testData) : RandomSystemTestBase(testData) { #if FEATURE_GUID_V7 - [Fact] + [Test] public async Task CreateVersion7_ShouldBeThreadSafeAndReturnUniqueItems() { ConcurrentBag results = []; @@ -28,7 +28,7 @@ public async Task CreateVersion7_ShouldBeThreadSafeAndReturnUniqueItems() #endif #if FEATURE_GUID_V7 - [Fact] + [Test] public async Task CreateVersion7_WithOffset_ShouldBeThreadSafeAndReturnUniqueItems() { ConcurrentBag results = []; @@ -41,13 +41,13 @@ public async Task CreateVersion7_WithOffset_ShouldBeThreadSafeAndReturnUniqueIte await That(results).AreAllUnique(); } #endif - [Fact] + [Test] public async Task Empty_ShouldReturnEmptyGuid() { await That(RandomSystem.Guid.Empty).IsEqualTo(Guid.Empty); } - [Fact] + [Test] public async Task NewGuid_ShouldBeThreadSafeAndReturnUniqueItems() { ConcurrentBag results = []; @@ -61,10 +61,11 @@ public async Task NewGuid_ShouldBeThreadSafeAndReturnUniqueItems() } #if FEATURE_GUID_PARSE - [Theory] - [AutoData] - public async Task Parse_SpanArray_ShouldReturnCorrectGuid(Guid guid) + [Test] + public async Task Parse_SpanArray_ShouldReturnCorrectGuid() { + Guid guid = Guid.NewGuid(); + ReadOnlySpan serializedGuid = guid.ToString().AsSpan(); #pragma warning disable MA0011 @@ -76,10 +77,11 @@ public async Task Parse_SpanArray_ShouldReturnCorrectGuid(Guid guid) #endif #if FEATURE_GUID_PARSE - [Theory] - [AutoData] - public async Task Parse_String_ShouldReturnCorrectGuid(Guid guid) + [Test] + public async Task Parse_String_ShouldReturnCorrectGuid() { + Guid guid = Guid.NewGuid(); + string serializedGuid = guid.ToString(); #pragma warning disable MA0011 @@ -91,10 +93,11 @@ public async Task Parse_String_ShouldReturnCorrectGuid(Guid guid) #endif #if FEATURE_GUID_PARSE_UTF8 - [Theory] - [AutoData] - public async Task Parse_UTF8_ShouldReturnCorrectGuid(Guid guid) + [Test] + public async Task Parse_UTF8_ShouldReturnCorrectGuid() { + Guid guid = Guid.NewGuid(); + byte[] bytes = Encoding.UTF8.GetBytes(guid.ToString()); #pragma warning disable MA0011 @@ -106,10 +109,11 @@ public async Task Parse_UTF8_ShouldReturnCorrectGuid(Guid guid) #endif #if FEATURE_GUID_PARSE_UTF8 - [Theory] - [AutoData] - public async Task Parse_UTF8_WithFormatProvider_ShouldReturnCorrectGuid(Guid guid) + [Test] + public async Task Parse_UTF8_WithFormatProvider_ShouldReturnCorrectGuid() { + Guid guid = Guid.NewGuid(); + byte[] bytes = Encoding.UTF8.GetBytes(guid.ToString()); #pragma warning disable MA0011 @@ -121,10 +125,11 @@ public async Task Parse_UTF8_WithFormatProvider_ShouldReturnCorrectGuid(Guid gui #endif #if FEATURE_GUID_FORMATPROVIDER - [Theory] - [AutoData] - public async Task Parse_WithFormatProvider_SpanArray_ShouldReturnCorrectGuid(Guid guid) + [Test] + public async Task Parse_WithFormatProvider_SpanArray_ShouldReturnCorrectGuid() { + Guid guid = Guid.NewGuid(); + ReadOnlySpan serializedGuid = guid.ToString().AsSpan(); Guid result = RandomSystem.Guid.Parse(serializedGuid, CultureInfo.InvariantCulture); @@ -134,10 +139,11 @@ public async Task Parse_WithFormatProvider_SpanArray_ShouldReturnCorrectGuid(Gui #endif #if FEATURE_GUID_FORMATPROVIDER - [Theory] - [AutoData] - public async Task Parse_WithFormatProvider_String_ShouldReturnCorrectGuid(Guid guid) + [Test] + public async Task Parse_WithFormatProvider_String_ShouldReturnCorrectGuid() { + Guid guid = Guid.NewGuid(); + string serializedGuid = guid.ToString(); Guid result = RandomSystem.Guid.Parse(serializedGuid, CultureInfo.InvariantCulture); @@ -147,8 +153,8 @@ public async Task Parse_WithFormatProvider_String_ShouldReturnCorrectGuid(Guid g #endif #if FEATURE_GUID_PARSE - [Theory] - [MemberAutoData(nameof(GuidFormats))] + [Test] + [MethodDataSource(nameof(GuidFormats))] public async Task ParseExact_SpanArray_ShouldReturnCorrectGuid( string format, Guid guid) { @@ -161,8 +167,8 @@ public async Task ParseExact_SpanArray_ShouldReturnCorrectGuid( #endif #if FEATURE_GUID_PARSE - [Theory] - [MemberAutoData(nameof(GuidFormats))] + [Test] + [MethodDataSource(nameof(GuidFormats))] public async Task ParseExact_String_ShouldReturnCorrectGuid(string format, Guid guid) { string serializedGuid = guid.ToString(format); @@ -174,10 +180,11 @@ public async Task ParseExact_String_ShouldReturnCorrectGuid(string format, Guid #endif #if FEATURE_GUID_PARSE - [Theory] - [AutoData] - public async Task TryParse_SpanArray_ShouldReturnTrue(Guid guid) + [Test] + public async Task TryParse_SpanArray_ShouldReturnTrue() { + Guid guid = Guid.NewGuid(); + ReadOnlySpan serializedGuid = guid.ToString().AsSpan(); #pragma warning disable MA0011 @@ -190,10 +197,11 @@ public async Task TryParse_SpanArray_ShouldReturnTrue(Guid guid) #endif #if FEATURE_GUID_FORMATPROVIDER - [Theory] - [AutoData] - public async Task TryParse_SpanArray_WithFormatProvider_ShouldReturnTrue(Guid guid) + [Test] + public async Task TryParse_SpanArray_WithFormatProvider_ShouldReturnTrue() { + Guid guid = Guid.NewGuid(); + ReadOnlySpan serializedGuid = guid.ToString().AsSpan(); bool result = RandomSystem.Guid.TryParse(serializedGuid, CultureInfo.InvariantCulture, @@ -205,10 +213,11 @@ public async Task TryParse_SpanArray_WithFormatProvider_ShouldReturnTrue(Guid gu #endif #if FEATURE_GUID_PARSE - [Theory] - [AutoData] - public async Task TryParse_String_ShouldReturnTrue(Guid guid) + [Test] + public async Task TryParse_String_ShouldReturnTrue() { + Guid guid = Guid.NewGuid(); + string serializedGuid = guid.ToString(); #pragma warning disable MA0011 @@ -221,10 +230,11 @@ public async Task TryParse_String_ShouldReturnTrue(Guid guid) #endif #if FEATURE_GUID_FORMATPROVIDER - [Theory] - [AutoData] - public async Task TryParse_String_WithFormatProvider_ShouldReturnTrue(Guid guid) + [Test] + public async Task TryParse_String_WithFormatProvider_ShouldReturnTrue() { + Guid guid = Guid.NewGuid(); + string serializedGuid = guid.ToString(); bool result = RandomSystem.Guid.TryParse(serializedGuid, CultureInfo.InvariantCulture, @@ -236,10 +246,11 @@ public async Task TryParse_String_WithFormatProvider_ShouldReturnTrue(Guid guid) #endif #if FEATURE_GUID_PARSE_UTF8 - [Theory] - [AutoData] - public async Task TryParse_UTF8_ShouldReturnTrue(Guid guid) + [Test] + public async Task TryParse_UTF8_ShouldReturnTrue() { + Guid guid = Guid.NewGuid(); + byte[] bytes = Encoding.UTF8.GetBytes(guid.ToString()); #pragma warning disable MA0011 @@ -252,10 +263,11 @@ public async Task TryParse_UTF8_ShouldReturnTrue(Guid guid) #endif #if FEATURE_GUID_PARSE_UTF8 - [Theory] - [AutoData] - public async Task TryParse_UTF8_WithFormatProvider_ShouldReturnTrue(Guid guid) + [Test] + public async Task TryParse_UTF8_WithFormatProvider_ShouldReturnTrue() { + Guid guid = Guid.NewGuid(); + byte[] bytes = Encoding.UTF8.GetBytes(guid.ToString()); bool result = RandomSystem.Guid.TryParse(bytes, CultureInfo.InvariantCulture, @@ -267,8 +279,8 @@ public async Task TryParse_UTF8_WithFormatProvider_ShouldReturnTrue(Guid guid) #endif #if FEATURE_GUID_PARSE - [Theory] - [MemberAutoData(nameof(GuidFormats))] + [Test] + [MethodDataSource(nameof(GuidFormats))] public async Task TryParseExact_SpanArray_ShouldReturnTrue(string format, Guid guid) { ReadOnlySpan serializedGuid = guid.ToString(format).AsSpan(); @@ -283,8 +295,8 @@ public async Task TryParseExact_SpanArray_ShouldReturnTrue(string format, Guid g #endif #if FEATURE_GUID_PARSE - [Theory] - [MemberAutoData(nameof(GuidFormats))] + [Test] + [MethodDataSource(nameof(GuidFormats))] public async Task TryParseExact_String_ShouldReturnTrue(string format, Guid guid) { string serializedGuid = guid.ToString(format); @@ -302,13 +314,13 @@ public async Task TryParseExact_String_ShouldReturnTrue(string format, Guid guid #if FEATURE_GUID_PARSE #pragma warning disable MA0018 - public static IEnumerable GuidFormats() + public static IEnumerable<(string, Guid)> GuidFormats() { - yield return ["N"]; - yield return ["D"]; - yield return ["B"]; - yield return ["P"]; - yield return ["X"]; + yield return ("N", Guid.NewGuid()); + yield return ("D", Guid.NewGuid()); + yield return ("B", Guid.NewGuid()); + yield return ("P", Guid.NewGuid()); + yield return ("X", Guid.NewGuid()); } #pragma warning restore MA0018 #endif diff --git a/Tests/Testably.Abstractions.Tests/RandomSystem/RandomFactoryTests.cs b/Tests/Testably.Abstractions.Tests/RandomSystem/RandomFactoryTests.cs index 55a2f1770..8d113d727 100644 --- a/Tests/Testably.Abstractions.Tests/RandomSystem/RandomFactoryTests.cs +++ b/Tests/Testably.Abstractions.Tests/RandomSystem/RandomFactoryTests.cs @@ -4,9 +4,9 @@ namespace Testably.Abstractions.Tests.RandomSystem; [RandomSystemTests] -public partial class RandomFactoryTests +public class RandomFactoryTests(RandomSystemTestData testData) : RandomSystemTestBase(testData) { - [Fact] + [Test] public async Task New_Next_ShouldReturnDifferentValues() { List results = []; @@ -19,8 +19,8 @@ public async Task New_Next_ShouldReturnDifferentValues() await That(results).AreAllUnique(); } - [Theory] - [AutoData] + [Test] + [Arguments(5)] public async Task New_Next_WithSeed_ShouldReturnSameValue(int seed) { List results = []; @@ -33,7 +33,7 @@ public async Task New_Next_WithSeed_ShouldReturnSameValue(int seed) await That(results).All().AreEqualTo(results[0]); } - [Fact] + [Test] public async Task New_Shared_ShouldReturnDifferentValues() { List results = []; @@ -46,7 +46,7 @@ public async Task New_Shared_ShouldReturnDifferentValues() await That(results).AreAllUnique(); } - [Fact] + [Test] public async Task Shared_ShouldReturnSameReference() { IRandom shared1 = RandomSystem.Random.Shared; diff --git a/Tests/Testably.Abstractions.Tests/RandomSystem/RandomTests.cs b/Tests/Testably.Abstractions.Tests/RandomSystem/RandomTests.cs index 4dfebfc46..b347964a3 100644 --- a/Tests/Testably.Abstractions.Tests/RandomSystem/RandomTests.cs +++ b/Tests/Testably.Abstractions.Tests/RandomSystem/RandomTests.cs @@ -6,13 +6,13 @@ namespace Testably.Abstractions.Tests.RandomSystem; [RandomSystemTests] -public partial class RandomTests +public class RandomTests(RandomSystemTestData testData) : RandomSystemTestBase(testData) { #if FEATURE_RANDOM_STRINGS - [Theory] - [InlineData(2)] - [InlineData(100)] - [InlineData(1000)] + [Test] + [Arguments(2)] + [Arguments(100)] + [Arguments(1000)] public async Task GetHexString_ShouldHaveExpectedLength(int length) { string result = RandomSystem.Random.Shared.GetHexString(length); @@ -22,7 +22,7 @@ public async Task GetHexString_ShouldHaveExpectedLength(int length) #endif #if FEATURE_RANDOM_STRINGS - [Fact] + [Test] public async Task GetHexString_ShouldOnlyContainHexadecimalCharacters() { char[] hexadecimalCharacters = "0123456789ABCDEF".ToCharArray(); @@ -34,7 +34,7 @@ public async Task GetHexString_ShouldOnlyContainHexadecimalCharacters() #endif #if FEATURE_RANDOM_STRINGS - [Fact] + [Test] public async Task GetHexString_WithDestinationSpan_ShouldOnlyContainHexadecimalCharacters() { char[] buffer = new char[10000]; @@ -49,7 +49,7 @@ public async Task GetHexString_WithDestinationSpan_ShouldOnlyContainHexadecimalC #endif #if FEATURE_RANDOM_STRINGS - [Fact] + [Test] public async Task GetHexString_WithDestinationSpan_WithLowercase_ShouldOnlyContainLowercaseHexadecimalCharacters() { @@ -65,7 +65,7 @@ public async Task #endif #if FEATURE_RANDOM_STRINGS - [Fact] + [Test] public async Task GetHexString_WithLowercase_ShouldOnlyContainLowercaseHexadecimalCharacters() { char[] hexadecimalCharacters = "0123456789abcdef".ToCharArray(); @@ -77,7 +77,7 @@ public async Task GetHexString_WithLowercase_ShouldOnlyContainLowercaseHexadecim #endif #if FEATURE_RANDOM_ITEMS - [Fact] + [Test] public async Task GetItems_Array_EmptyChoices_ShouldThrowArgumentNullException() { int[] choices = Array.Empty(); @@ -95,7 +95,7 @@ await That(Act).Throws() #endif #if FEATURE_RANDOM_ITEMS - [Fact] + [Test] public async Task GetItems_Array_LengthLargerThanChoices_ShouldIncludeDuplicateValues() { int[] choices = Enumerable.Range(1, 10).ToArray(); @@ -108,9 +108,9 @@ public async Task GetItems_Array_LengthLargerThanChoices_ShouldIncludeDuplicateV #endif #if FEATURE_RANDOM_ITEMS - [Theory] - [InlineData(-1)] - [InlineData(-200)] + [Test] + [Arguments(-1)] + [Arguments(-200)] public async Task GetItems_Array_NegativeLength_ShouldThrowArgumentOutOfRangeException( int length) { @@ -128,7 +128,7 @@ await That(Act).Throws() #endif #if FEATURE_RANDOM_ITEMS - [Fact] + [Test] public async Task GetItems_Array_NullChoices_ShouldThrowArgumentNullException() { int[] choices = null!; @@ -143,7 +143,7 @@ void Act() #endif #if FEATURE_RANDOM_ITEMS - [Fact] + [Test] public async Task GetItems_Array_ShouldSelectRandomElements() { int[] choices = Enumerable.Range(1, 100).ToArray(); @@ -156,7 +156,7 @@ public async Task GetItems_Array_ShouldSelectRandomElements() #endif #if FEATURE_RANDOM_ITEMS - [Fact] + [Test] public async Task GetItems_ReadOnlySpan_LengthLargerThanChoices_ShouldIncludeDuplicateValues() { ReadOnlySpan choices = Enumerable.Range(1, 10).ToArray().AsSpan(); @@ -169,7 +169,7 @@ public async Task GetItems_ReadOnlySpan_LengthLargerThanChoices_ShouldIncludeDup #endif #if FEATURE_RANDOM_ITEMS - [Fact] + [Test] public async Task GetItems_ReadOnlySpan_ShouldSelectRandomElements() { ReadOnlySpan choices = Enumerable.Range(1, 100).ToArray().AsSpan(); @@ -182,7 +182,7 @@ public async Task GetItems_ReadOnlySpan_ShouldSelectRandomElements() #endif #if FEATURE_RANDOM_ITEMS - [Fact] + [Test] public async Task GetItems_SpanDestination_LengthLargerThanChoices_ShouldIncludeDuplicateValues() { @@ -199,7 +199,7 @@ public async Task #endif #if FEATURE_RANDOM_ITEMS - [Fact] + [Test] public async Task GetItems_SpanDestination_ShouldSelectRandomElements() { int[] buffer = new int[10]; @@ -215,10 +215,10 @@ public async Task GetItems_SpanDestination_ShouldSelectRandomElements() #endif #if FEATURE_RANDOM_STRINGS - [Theory] - [InlineData(2)] - [InlineData(100)] - [InlineData(1000)] + [Test] + [Arguments(2)] + [Arguments(100)] + [Arguments(1000)] public async Task GetString_ShouldHaveExpectedLength(int length) { ReadOnlySpan choices = "abcde".ToCharArray(); @@ -230,10 +230,11 @@ public async Task GetString_ShouldHaveExpectedLength(int length) #endif #if FEATURE_RANDOM_STRINGS - [Theory] - [AutoData] - public async Task GetString_ShouldOnlyContainProvidedCharacters(char[] chars) + [Test] + [Arguments("foo")] + public async Task GetString_ShouldOnlyContainProvidedCharacters(string value) { + char[] chars = value.ToCharArray(); ReadOnlySpan choices = chars; string result = RandomSystem.Random.Shared.GetString(choices, 100); @@ -242,7 +243,7 @@ public async Task GetString_ShouldOnlyContainProvidedCharacters(char[] chars) } #endif - [Fact] + [Test] public async Task Next_MaxValue_ShouldOnlyReturnValidValues() { int maxValue = 10; @@ -256,7 +257,7 @@ public async Task Next_MaxValue_ShouldOnlyReturnValidValues() await That(results).All().Satisfy(r => r < maxValue); } - [Fact] + [Test] public async Task Next_MinAndMaxValue_ShouldOnlyReturnValidValues() { int minValue = 10; @@ -271,7 +272,7 @@ public async Task Next_MinAndMaxValue_ShouldOnlyReturnValidValues() await That(results).All().Satisfy(r => r >= minValue && r < maxValue); } - [Fact] + [Test] public async Task Next_ShouldBeThreadSafe() { ConcurrentBag results = []; @@ -284,7 +285,7 @@ public async Task Next_ShouldBeThreadSafe() await That(results).AreAllUnique(); } - [Fact] + [Test] public async Task NextBytes_ShouldBeThreadSafe() { ConcurrentBag results = []; @@ -300,7 +301,7 @@ public async Task NextBytes_ShouldBeThreadSafe() } #if FEATURE_SPAN - [Fact] + [Test] public async Task NextBytes_Span_ShouldBeThreadSafe() { ConcurrentBag results = []; @@ -316,7 +317,7 @@ public async Task NextBytes_Span_ShouldBeThreadSafe() } #endif - [Fact] + [Test] public async Task NextDouble_ShouldBeThreadSafe() { ConcurrentBag results = []; @@ -330,7 +331,7 @@ public async Task NextDouble_ShouldBeThreadSafe() } #if FEATURE_RANDOM_ADVANCED - [Fact] + [Test] public async Task NextInt64_MaxValue_ShouldOnlyReturnValidValues() { long maxValue = 10; @@ -346,7 +347,7 @@ public async Task NextInt64_MaxValue_ShouldOnlyReturnValidValues() #endif #if FEATURE_RANDOM_ADVANCED - [Fact] + [Test] public async Task NextInt64_MinAndMaxValue_ShouldOnlyReturnValidValues() { long minValue = 10; @@ -363,7 +364,7 @@ public async Task NextInt64_MinAndMaxValue_ShouldOnlyReturnValidValues() #endif #if FEATURE_RANDOM_ADVANCED - [Fact] + [Test] public async Task NextInt64_ShouldBeThreadSafe() { ConcurrentBag results = []; @@ -378,7 +379,7 @@ public async Task NextInt64_ShouldBeThreadSafe() #endif #if FEATURE_RANDOM_ADVANCED - [Fact] + [Test] public async Task NextSingle_ShouldBeThreadSafe() { ConcurrentBag results = []; @@ -393,7 +394,7 @@ public async Task NextSingle_ShouldBeThreadSafe() #endif #if FEATURE_RANDOM_ITEMS - [Fact] + [Test] public async Task Shuffle_Array_Null_ShouldThrowArgumentNullException() { int[] values = null!; @@ -408,7 +409,7 @@ void Act() #endif #if FEATURE_RANDOM_ITEMS - [Fact] + [Test] public async Task Shuffle_Array_ShouldShuffleItemsInPlace() { int[] originalValues = Enumerable.Range(1, 100).ToArray(); @@ -423,7 +424,7 @@ public async Task Shuffle_Array_ShouldShuffleItemsInPlace() #endif #if FEATURE_RANDOM_ITEMS - [Fact] + [Test] public async Task Shuffle_Span_ShouldShuffleItemsInPlace() { int[] originalValues = Enumerable.Range(1, 100).ToArray(); diff --git a/Tests/Testably.Abstractions.Tests/SourceGeneratorTests.cs b/Tests/Testably.Abstractions.Tests/SourceGeneratorTests.cs deleted file mode 100644 index f069a5a55..000000000 --- a/Tests/Testably.Abstractions.Tests/SourceGeneratorTests.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System.Linq; - -namespace Testably.Abstractions.Tests; - -public sealed class SourceGeneratorTests -{ - [Fact] - public async Task SourceGeneratorTestsAreCreated() - { - int mockFileSystemTestsCount = typeof(SourceGeneratorTests).Assembly.GetTypes() - .Count(x => string.Equals(x.Name, "MockFileSystemTests", StringComparison.Ordinal)); - - await That(mockFileSystemTestsCount).IsGreaterThan(100); - } -} diff --git a/Tests/Testably.Abstractions.Tests/TestHelpers/Polyfills/CancellationTokenSourceExtensions.cs b/Tests/Testably.Abstractions.Tests/TestHelpers/Polyfills/CancellationTokenSourceExtensions.cs deleted file mode 100644 index b0b374eac..000000000 --- a/Tests/Testably.Abstractions.Tests/TestHelpers/Polyfills/CancellationTokenSourceExtensions.cs +++ /dev/null @@ -1,18 +0,0 @@ -#if !NET8_0_OR_GREATER -using System.Threading; - -// ReSharper disable once CheckNamespace -namespace System; - -public static class CancellationTokenSourceExtensions -{ - /// - /// Communicates a request for cancellation asynchronously. - /// - public static Task CancelAsync(this CancellationTokenSource @this) - { - @this.Cancel(); - return Task.CompletedTask; - } -} -#endif diff --git a/Tests/Testably.Abstractions.Tests/TestHelpers/Polyfills/StringExtensions.cs b/Tests/Testably.Abstractions.Tests/TestHelpers/Polyfills/StringExtensions.cs index b4c45f277..718d3f9ac 100644 --- a/Tests/Testably.Abstractions.Tests/TestHelpers/Polyfills/StringExtensions.cs +++ b/Tests/Testably.Abstractions.Tests/TestHelpers/Polyfills/StringExtensions.cs @@ -4,14 +4,6 @@ namespace System; public static class StringExtensions { - public static bool Contains(this string @this, string value, - StringComparison comparisonType) - { - #pragma warning disable CA2249 // Consider using 'string.Contains' instead of 'string.IndexOf'... this is the implementation of Contains! - return @this.IndexOf(value, comparisonType) >= 0; - #pragma warning restore CA2249 - } - /// /// Returns a new string in which all occurrences of a specified string in the current instance are replaced with /// another specified string, using the provided comparison type. diff --git a/Tests/Testably.Abstractions.Tests/TestHelpers/TestData.cs b/Tests/Testably.Abstractions.Tests/TestHelpers/TestData.cs new file mode 100644 index 000000000..7c8adf149 --- /dev/null +++ b/Tests/Testably.Abstractions.Tests/TestHelpers/TestData.cs @@ -0,0 +1,23 @@ +using System.Collections.Generic; +using System.Text; + +namespace Testably.Abstractions.Tests.TestHelpers; + +public static class TestData +{ + private const string SpecialCharactersContent = "_€_Ä_Ö_Ü"; + + public static IEnumerable> GetEncodingDifference() + { + yield return () => (SpecialCharactersContent, Encoding.ASCII, Encoding.UTF8); + } + + public static IEnumerable> GetEncodingsForReadAllText() + { + yield return () => new UTF32Encoding(false, true, true); + // big endian + yield return () => new UTF32Encoding(true, true, true); + yield return () => new UTF8Encoding(true, true); + yield return () => new ASCIIEncoding(); + } +} diff --git a/Tests/Testably.Abstractions.Tests/TestHelpers/Usings.cs b/Tests/Testably.Abstractions.Tests/TestHelpers/Usings.cs index 4f53c3e1a..bb22ea218 100644 --- a/Tests/Testably.Abstractions.Tests/TestHelpers/Usings.cs +++ b/Tests/Testably.Abstractions.Tests/TestHelpers/Usings.cs @@ -1,12 +1,11 @@ -global using AutoFixture.Xunit3; -global using System; +global using System; global using System.IO.Abstractions; global using System.Threading.Tasks; global using Testably.Abstractions.FileSystem; global using Testably.Abstractions.Testing; global using Testably.Abstractions.TestHelpers; global using Testably.Abstractions.Tests.TestHelpers; -global using Xunit; +global using TUnit; global using aweXpect; global using static aweXpect.Expect; global using Skip = Testably.Abstractions.TestHelpers.Skip; diff --git a/Tests/Testably.Abstractions.Tests/Testably.Abstractions.Tests.csproj b/Tests/Testably.Abstractions.Tests/Testably.Abstractions.Tests.csproj index 62b18b4d6..a31e9bc1d 100644 --- a/Tests/Testably.Abstractions.Tests/Testably.Abstractions.Tests.csproj +++ b/Tests/Testably.Abstractions.Tests/Testably.Abstractions.Tests.csproj @@ -4,19 +4,9 @@ - - - true - Generated - $(GeneratedFolder)\$(TargetFramework) - - - - - diff --git a/Tests/Testably.Abstractions.Tests/Testably.Abstractions.Tests.v3.ncrunchproject b/Tests/Testably.Abstractions.Tests/Testably.Abstractions.Tests.v3.ncrunchproject deleted file mode 100644 index 5e6d62816..000000000 --- a/Tests/Testably.Abstractions.Tests/Testably.Abstractions.Tests.v3.ncrunchproject +++ /dev/null @@ -1,5 +0,0 @@ - - - True - - \ No newline at end of file diff --git a/Tests/Testably.Abstractions.Tests/TimeSystem/DateTimeTests.cs b/Tests/Testably.Abstractions.Tests/TimeSystem/DateTimeTests.cs index 620ef7561..ba1bc29ef 100644 --- a/Tests/Testably.Abstractions.Tests/TimeSystem/DateTimeTests.cs +++ b/Tests/Testably.Abstractions.Tests/TimeSystem/DateTimeTests.cs @@ -1,9 +1,9 @@ namespace Testably.Abstractions.Tests.TimeSystem; [TimeSystemTests] -public partial class DateTimeTests +public class DateTimeTests(TimeSystemTestData testData) : TimeSystemTestBase(testData) { - [Fact] + [Test] public async Task MaxValue_ShouldReturnDefaultValue() { DateTime expectedResult = DateTime.MaxValue; @@ -13,7 +13,7 @@ public async Task MaxValue_ShouldReturnDefaultValue() await That(result).IsEqualTo(expectedResult); } - [Fact] + [Test] public async Task MinValue_ShouldReturnDefaultValue() { DateTime expectedResult = DateTime.MinValue; @@ -23,21 +23,20 @@ public async Task MinValue_ShouldReturnDefaultValue() await That(result).IsEqualTo(expectedResult); } - [Fact] + [Test] public async Task Now_ShouldBeSetToNow() { // Tests are brittle on the build system TimeSpan tolerance = TimeSpan.FromMilliseconds(250); - DateTime before = DateTime.Now; DateTime result = TimeSystem.DateTime.Now; DateTime after = DateTime.Now; await That(result.Kind).IsEqualTo(DateTimeKind.Local); - await That(result).IsBetween(before).And(after).Within(tolerance); + await That(result).IsBetween(BeforeTime.ToLocalTime()).And(after).Within(tolerance); } - [Fact] + [Test] public async Task Today_ShouldBeSetToToday() { DateTime before = DateTime.Today; @@ -50,7 +49,7 @@ public async Task Today_ShouldBeSetToToday() await That(result).IsBetween(before).And(after).Within(TimeComparison.Tolerance); } - [Fact] + [Test] public async Task UnixEpoch_ShouldReturnDefaultValue() { #pragma warning disable MA0113 // Use DateTime.UnixEpoch @@ -62,17 +61,16 @@ public async Task UnixEpoch_ShouldReturnDefaultValue() await That(result).IsEqualTo(expectedResult); } - [Fact] + [Test] public async Task UtcNow_ShouldBeSetToUtcNow() { // Tests are brittle on the build system TimeSpan tolerance = TimeSpan.FromMilliseconds(250); - DateTime before = DateTime.UtcNow; DateTime result = TimeSystem.DateTime.UtcNow; DateTime after = DateTime.UtcNow; await That(result.Kind).IsEqualTo(DateTimeKind.Utc); - await That(result).IsBetween(before).And(after).Within(tolerance); + await That(result).IsBetween(BeforeTime).And(after).Within(tolerance); } } diff --git a/Tests/Testably.Abstractions.Tests/TimeSystem/StopwatchFactoryTests.cs b/Tests/Testably.Abstractions.Tests/TimeSystem/StopwatchFactoryTests.cs index 0c5c66e9c..7d4f3a65f 100644 --- a/Tests/Testably.Abstractions.Tests/TimeSystem/StopwatchFactoryTests.cs +++ b/Tests/Testably.Abstractions.Tests/TimeSystem/StopwatchFactoryTests.cs @@ -1,12 +1,13 @@ using System.Diagnostics; +using System.Threading; using Testably.Abstractions.TimeSystem; namespace Testably.Abstractions.Tests.TimeSystem; [TimeSystemTests] -public partial class StopwatchFactoryTests +public class StopwatchFactoryTests(TimeSystemTestData testData) : TimeSystemTestBase(testData) { - [Fact] + [Test] public async Task Frequency_ShouldReturnValueOfAtLeastTicksPerSecond() { var expectedMinimum = TimeSystem is RealTimeSystem @@ -18,10 +19,10 @@ public async Task Frequency_ShouldReturnValueOfAtLeastTicksPerSecond() } #if FEATURE_STOPWATCH_GETELAPSEDTIME - [Theory] - [InlineData(5000L, 8000L, 3000L)] - [InlineData(8000L, 5000L, -3000L)] - [InlineData(4000L, 4000L, 0L)] + [Test] + [Arguments(5000L, 8000L, 3000L)] + [Arguments(8000L, 5000L, -3000L)] + [Arguments(4000L, 4000L, 0L)] public async Task GetElapsedTime_WithStartingAndEndingTimestamp_ShouldReturnValue( long startingTimestamp, long endingTimestamp, long expectedTicks) { @@ -34,9 +35,9 @@ public async Task GetElapsedTime_WithStartingAndEndingTimestamp_ShouldReturnValu #endif #if FEATURE_STOPWATCH_GETELAPSEDTIME - [Theory] - [InlineData(1000L)] - [InlineData(100000L)] + [Test] + [Arguments(1000L)] + [Arguments(100000L)] public async Task GetElapsedTime_WithStartingTimestamp_ShouldReturnValue(long expectedTicks) { long endingTimestamp = TimeSystem.Stopwatch.GetTimestamp(); @@ -49,18 +50,18 @@ public async Task GetElapsedTime_WithStartingTimestamp_ShouldReturnValue(long ex } #endif - [Fact] + [Test] public async Task GetTimestamp_AfterDelay_ShouldBeDifferent() { long timestamp1 = TimeSystem.Stopwatch.GetTimestamp(); - await TimeSystem.Task.Delay(10, TestContext.Current.CancellationToken); + await TimeSystem.Task.Delay(10, CancellationToken); long timestamp2 = TimeSystem.Stopwatch.GetTimestamp(); await That(timestamp2).IsGreaterThan(timestamp1); } - [Fact] + [Test] public async Task GetTimestamp_ShouldReturnValue() { long timestamp = TimeSystem.Stopwatch.GetTimestamp(); @@ -68,7 +69,7 @@ public async Task GetTimestamp_ShouldReturnValue() await That(timestamp).IsGreaterThan(0); } - [Fact] + [Test] public async Task IsHighResolution_ShouldReturnTrue() { bool expected = TimeSystem is MockTimeSystem || Stopwatch.IsHighResolution; @@ -77,7 +78,7 @@ public async Task IsHighResolution_ShouldReturnTrue() await That(isHighResolution).IsEqualTo(expected); } - [Fact] + [Test] public async Task New_ShouldCreateNotRunningStopwatch() { IStopwatch stopwatch = TimeSystem.Stopwatch.New(); @@ -85,7 +86,7 @@ public async Task New_ShouldCreateNotRunningStopwatch() await That(stopwatch.IsRunning).IsFalse(); } - [Fact] + [Test] public async Task StartNew_ShouldCreateRunningStopwatch() { IStopwatch stopwatch = TimeSystem.Stopwatch.StartNew(); diff --git a/Tests/Testably.Abstractions.Tests/TimeSystem/StopwatchTests.cs b/Tests/Testably.Abstractions.Tests/TimeSystem/StopwatchTests.cs index 6caedc025..f68098536 100644 --- a/Tests/Testably.Abstractions.Tests/TimeSystem/StopwatchTests.cs +++ b/Tests/Testably.Abstractions.Tests/TimeSystem/StopwatchTests.cs @@ -1,11 +1,12 @@ -using Testably.Abstractions.TimeSystem; +using System.Threading; +using Testably.Abstractions.TimeSystem; namespace Testably.Abstractions.Tests.TimeSystem; [TimeSystemTests] -public partial class StopwatchTests +public class StopwatchTests(TimeSystemTestData testData) : TimeSystemTestBase(testData) { - [Fact] + [Test] public async Task Elapsed_ShouldInitializeToZero() { IStopwatch stopwatch = TimeSystem.Stopwatch.New(); @@ -14,7 +15,7 @@ public async Task Elapsed_ShouldInitializeToZero() await That(elapsed).IsEqualTo(TimeSpan.Zero); } - [Fact] + [Test] public async Task Elapsed_WhenRunning_ShouldIncreaseValue() { TimeSpan delay = TimeSpan.FromMilliseconds(100); @@ -22,34 +23,34 @@ public async Task Elapsed_WhenRunning_ShouldIncreaseValue() stopwatch.Start(); TimeSpan elapsedBefore = stopwatch.Elapsed; - await TimeSystem.Task.Delay(delay, TestContext.Current.CancellationToken); + await TimeSystem.Task.Delay(delay, CancellationToken); TimeSpan elapsedAfter = stopwatch.Elapsed; await That(elapsedAfter).IsGreaterThanOrEqualTo(elapsedBefore + delay) .Within(TimeSpan.FromMilliseconds(1)); } - [Fact] + [Test] public async Task Elapsed_WhenStopped_ShouldRemainUnchanged() { TimeSpan delay = TimeSpan.FromMilliseconds(100); IStopwatch stopwatch = TimeSystem.Stopwatch.StartNew(); - await TimeSystem.Task.Delay(delay, TestContext.Current.CancellationToken); + await TimeSystem.Task.Delay(delay, CancellationToken); stopwatch.Stop(); TimeSpan elapsedBefore = stopwatch.Elapsed; - await TimeSystem.Task.Delay(delay, TestContext.Current.CancellationToken); + await TimeSystem.Task.Delay(delay, CancellationToken); TimeSpan elapsedAfter = stopwatch.Elapsed; await That(elapsedAfter).IsEqualTo(elapsedBefore); } - [Fact] + [Test] public async Task ElapsedMilliseconds_ShouldBeEqualToElapsed() { TimeSpan delay = TimeSpan.FromMilliseconds(100); IStopwatch stopwatch = TimeSystem.Stopwatch.StartNew(); - await TimeSystem.Task.Delay(delay, TestContext.Current.CancellationToken); + await TimeSystem.Task.Delay(delay, CancellationToken); stopwatch.Stop(); TimeSpan elapsed = stopwatch.Elapsed; @@ -58,12 +59,12 @@ public async Task ElapsedMilliseconds_ShouldBeEqualToElapsed() await That(elapsedMilliseconds).IsEqualTo((long)elapsed.TotalMilliseconds).Within(1L); } - [Fact] + [Test] public async Task ElapsedTicks_ShouldBeEqualToElapsed() { TimeSpan delay = TimeSpan.FromMilliseconds(100); IStopwatch stopwatch = TimeSystem.Stopwatch.StartNew(); - await TimeSystem.Task.Delay(delay, TestContext.Current.CancellationToken); + await TimeSystem.Task.Delay(delay, CancellationToken); stopwatch.Stop(); TimeSpan elapsed = stopwatch.Elapsed; @@ -74,12 +75,12 @@ public async Task ElapsedTicks_ShouldBeEqualToElapsed() await That(elapsedTicksAsTimeSpanTicks).IsEqualTo(elapsed.Ticks); } - [Fact] + [Test] public async Task Reset_ShouldResetElapsedAndStop() { TimeSpan delay = TimeSpan.FromMilliseconds(100); IStopwatch stopwatch = TimeSystem.Stopwatch.StartNew(); - await TimeSystem.Task.Delay(delay, TestContext.Current.CancellationToken); + await TimeSystem.Task.Delay(delay, CancellationToken); stopwatch.Reset(); TimeSpan elapsed = stopwatch.Elapsed; @@ -88,12 +89,12 @@ public async Task Reset_ShouldResetElapsedAndStop() await That(stopwatch.IsRunning).IsFalse(); } - [Fact] + [Test] public async Task Restart_ShouldResetElapsedAndSetIsRunningToTrue() { TimeSpan delay = TimeSpan.FromMilliseconds(100); IStopwatch stopwatch = TimeSystem.Stopwatch.StartNew(); - await TimeSystem.Task.Delay(delay, TestContext.Current.CancellationToken); + await TimeSystem.Task.Delay(delay, CancellationToken); stopwatch.Stop(); stopwatch.Restart(); @@ -103,7 +104,7 @@ public async Task Restart_ShouldResetElapsedAndSetIsRunningToTrue() await That(stopwatch.IsRunning).IsTrue(); } - [Fact] + [Test] public async Task Start_ShouldSetIsRunningToTrue() { IStopwatch stopwatch = TimeSystem.Stopwatch.New(); @@ -115,7 +116,7 @@ public async Task Start_ShouldSetIsRunningToTrue() await That(stopwatch.IsRunning).IsTrue(); } - [Fact] + [Test] public async Task Start_WhenStarted_ShouldDoNothing() { IStopwatch stopwatch = TimeSystem.Stopwatch.New(); @@ -126,12 +127,12 @@ public async Task Start_WhenStarted_ShouldDoNothing() await That(stopwatch.IsRunning).IsTrue(); } - [Fact] + [Test] public async Task Stop_ShouldSetIsRunningToFalse() { TimeSpan delay = TimeSpan.FromMilliseconds(100); IStopwatch stopwatch = TimeSystem.Stopwatch.StartNew(); - await TimeSystem.Task.Delay(delay, TestContext.Current.CancellationToken); + await TimeSystem.Task.Delay(delay, CancellationToken); stopwatch.Stop(); TimeSpan elapsed = stopwatch.Elapsed; @@ -141,12 +142,12 @@ public async Task Stop_ShouldSetIsRunningToFalse() await That(stopwatch.IsRunning).IsFalse(); } - [Fact] + [Test] public async Task Stop_WhenStopped_ShouldDoNothing() { TimeSpan delay = TimeSpan.FromMilliseconds(100); IStopwatch stopwatch = TimeSystem.Stopwatch.StartNew(); - await TimeSystem.Task.Delay(delay, TestContext.Current.CancellationToken); + await TimeSystem.Task.Delay(delay, CancellationToken); stopwatch.Stop(); TimeSpan elapsed1 = stopwatch.Elapsed; diff --git a/Tests/Testably.Abstractions.Tests/TimeSystem/TaskTests.cs b/Tests/Testably.Abstractions.Tests/TimeSystem/TaskTests.cs index 7377c225d..344ad2dd5 100644 --- a/Tests/Testably.Abstractions.Tests/TimeSystem/TaskTests.cs +++ b/Tests/Testably.Abstractions.Tests/TimeSystem/TaskTests.cs @@ -3,16 +3,16 @@ namespace Testably.Abstractions.Tests.TimeSystem; [TimeSystemTests] -public partial class TaskTests +public class TaskTests(TimeSystemTestData testData) : TimeSystemTestBase(testData) { - [Fact] + [Test] public async Task Delay_Milliseconds_Cancelled_ShouldThrowTaskCanceledException() { int millisecondsTimeout = 100; using CancellationTokenSource cts = new(); - await cts.CancelAsync(); + cts.Cancel(); async Task Act() => await TimeSystem.Task.Delay(millisecondsTimeout, cts.Token); @@ -20,37 +20,37 @@ async Task Act() await That(Act).Throws().WithHResult(-2146233029); } - [Fact] + [Test] public async Task Delay_Milliseconds_LessThanNegativeOne_ShouldThrowArgumentOutOfRangeException() { async Task Act() - => await TimeSystem.Task.Delay(-2, TestContext.Current.CancellationToken); + => await TimeSystem.Task.Delay(-2, CancellationToken); await That(Act).Throws().WithHResult(-2146233086); } - [Fact] + [Test] public async Task Delay_Milliseconds_ShouldDelayForSpecifiedMilliseconds() { int millisecondsTimeout = 100; DateTime before = TimeSystem.DateTime.UtcNow; - await TimeSystem.Task.Delay(millisecondsTimeout, TestContext.Current.CancellationToken); + await TimeSystem.Task.Delay(millisecondsTimeout, CancellationToken); DateTime after = TimeSystem.DateTime.UtcNow; await That(after) .IsOnOrAfter(before.AddMilliseconds(millisecondsTimeout).ApplySystemClockTolerance()); } - [Fact] + [Test] public async Task Delay_Timespan_Cancelled_ShouldThrowTaskCanceledException() { TimeSpan timeout = TimeSpan.FromMilliseconds(100); using CancellationTokenSource cts = new(); - await cts.CancelAsync(); + cts.Cancel(); async Task Act() => await TimeSystem.Task.Delay(timeout, cts.Token); @@ -58,25 +58,25 @@ async Task Act() await That(Act).Throws().WithHResult(-2146233029); } - [Fact] + [Test] public async Task Delay_Timespan_LessThanNegativeOne_ShouldThrowArgumentOutOfRangeException() { async Task Act() => await TimeSystem.Task.Delay(TimeSpan.FromMilliseconds(-2), - TestContext.Current.CancellationToken); + CancellationToken); await That(Act).Throws().WithHResult(-2146233086); } - [Fact] + [Test] public async Task Delay_Timespan_ShouldDelayForSpecifiedMilliseconds() { TimeSpan timeout = TimeSpan.FromMilliseconds(100); DateTime before = TimeSystem.DateTime.UtcNow; - await TimeSystem.Task.Delay(timeout, TestContext.Current.CancellationToken); + await TimeSystem.Task.Delay(timeout, CancellationToken); DateTime after = TimeSystem.DateTime.UtcNow; await That(after).IsOnOrAfter(before.Add(timeout).ApplySystemClockTolerance()); diff --git a/Tests/Testably.Abstractions.Tests/TimeSystem/ThreadTests.cs b/Tests/Testably.Abstractions.Tests/TimeSystem/ThreadTests.cs index 57d3b8fd3..ba9abd3fa 100644 --- a/Tests/Testably.Abstractions.Tests/TimeSystem/ThreadTests.cs +++ b/Tests/Testably.Abstractions.Tests/TimeSystem/ThreadTests.cs @@ -1,9 +1,9 @@ namespace Testably.Abstractions.Tests.TimeSystem; [TimeSystemTests] -public partial class ThreadTests +public class ThreadTests(TimeSystemTestData testData) : TimeSystemTestBase(testData) { - [Fact] + [Test] public async Task Sleep_LessThanNegativeOne_ShouldThrowArgumentOutOfRangeException() { void Act() => TimeSystem.Thread.Sleep(-2); @@ -11,7 +11,7 @@ public async Task Sleep_LessThanNegativeOne_ShouldThrowArgumentOutOfRangeExcepti await That(Act).Throws().WithHResult(-2146233086); } - [Fact] + [Test] public async Task Sleep_Milliseconds_ShouldSleepForSpecifiedMilliseconds() { int millisecondsTimeout = 100; @@ -24,7 +24,7 @@ await That(after) .IsOnOrAfter(before.AddMilliseconds(millisecondsTimeout).ApplySystemClockTolerance()); } - [Fact] + [Test] public async Task Sleep_Timespan_LessThanNegativeOne_ShouldThrowArgumentOutOfRangeException() { void Act() => @@ -33,7 +33,7 @@ void Act() => await That(Act).Throws().WithHResult(-2146233086); } - [Fact] + [Test] public async Task Sleep_Timespan_ShouldSleepForSpecifiedMilliseconds() { TimeSpan timeout = TimeSpan.FromMilliseconds(100); diff --git a/Tests/Testably.Abstractions.Tests/TimeSystem/TimerFactoryTests.cs b/Tests/Testably.Abstractions.Tests/TimeSystem/TimerFactoryTests.cs index f170388d2..6f9cfe07f 100644 --- a/Tests/Testably.Abstractions.Tests/TimeSystem/TimerFactoryTests.cs +++ b/Tests/Testably.Abstractions.Tests/TimeSystem/TimerFactoryTests.cs @@ -4,10 +4,10 @@ namespace Testably.Abstractions.Tests.TimeSystem; [TimeSystemTests] -public partial class TimeFactoryTests +public class TimeFactoryTests(TimeSystemTestData testData) : TimeSystemTestBase(testData) { #if FEATURE_TIMER_COUNT - [Fact] + [Test] public async Task ActiveCount_ShouldBeIncrementedWhenCreatingANewTimer() { using ITimer timer = TimeSystem.Timer.New(_ => { }); @@ -16,7 +16,7 @@ public async Task ActiveCount_ShouldBeIncrementedWhenCreatingANewTimer() #endif #if FEATURE_TIMER_COUNT - [Fact] + [Test] public async Task ActiveCount_ShouldBeResetWhenDisposingATimer() { const int timersPerThread = 64; @@ -78,9 +78,9 @@ void CreateTimerThreadStart() } #endif - [Theory] - [InlineData(-2)] - [InlineData(-500)] + [Test] + [Arguments(-2)] + [Arguments(-500)] public async Task New_InvalidDueTime_ShouldThrowArgumentOutOfRangeException(int dueTime) { void Act() @@ -94,9 +94,9 @@ await That(Act).Throws().WithHResult(-2146233086).A .WithParamName(nameof(dueTime)); } - [Theory] - [InlineData(-2)] - [InlineData(-500)] + [Test] + [Arguments(-2)] + [Arguments(-500)] public async Task New_InvalidPeriod_ShouldThrowArgumentOutOfRangeException(int period) { void Act() @@ -110,7 +110,7 @@ await That(Act).Throws().WithHResult(-2146233086).A .WithParamName(nameof(period)); } - [Fact] + [Test] public async Task New_WithPeriod_ShouldStartTimer() { int count = 0; @@ -132,11 +132,11 @@ public async Task New_WithPeriod_ShouldStartTimer() } }, null, 0, 50); - await That(ms.Wait(ExpectSuccess, TestContext.Current.CancellationToken)).IsTrue(); + await That(ms.Wait(ExpectSuccess, CancellationToken)).IsTrue(); await That(count).IsGreaterThanOrEqualTo(2); } - [Fact] + [Test] public async Task New_WithDueTime_ShouldStartTimerOnce() { int count = 0; @@ -155,12 +155,12 @@ public async Task New_WithDueTime_ShouldStartTimerOnce() } }, null, 5, 0); - await That(ms.Wait(ExpectSuccess, TestContext.Current.CancellationToken)).IsTrue(); - await Task.Delay(100, TestContext.Current.CancellationToken); + await That(ms.Wait(ExpectSuccess, CancellationToken)).IsTrue(); + await Task.Delay(100, CancellationToken); await That(count).IsEqualTo(1); } - [Fact] + [Test] public async Task New_WithoutPeriod_ShouldNotStartTimer() { using ManualResetEventSlim ms = new(); @@ -177,6 +177,6 @@ public async Task New_WithoutPeriod_ShouldNotStartTimer() } }); - await That(ms.Wait(EnsureTimeout, TestContext.Current.CancellationToken)).IsFalse(); + await That(ms.Wait(EnsureTimeout, CancellationToken)).IsFalse(); } } diff --git a/Tests/Testably.Abstractions.Tests/TimeSystem/TimerTests.cs b/Tests/Testably.Abstractions.Tests/TimeSystem/TimerTests.cs index e59e472b7..dce3e0476 100644 --- a/Tests/Testably.Abstractions.Tests/TimeSystem/TimerTests.cs +++ b/Tests/Testably.Abstractions.Tests/TimeSystem/TimerTests.cs @@ -4,8 +4,9 @@ namespace Testably.Abstractions.Tests.TimeSystem; +#pragma warning disable TUnit0031 [TimeSystemTests] -public partial class TimerTests +public class TimerTests(TimeSystemTestData testData) : TimeSystemTestBase(testData) { #region Test Setup @@ -14,7 +15,7 @@ public partial class TimerTests #endregion #if NET8_0_OR_GREATER - [Fact] + [Test] public async Task Change_DisposedTimer_ShouldReturnFalse() { using ITimer timer = TimeSystem.Timer.New(_ => @@ -35,7 +36,7 @@ void Act() #endif #if !NET8_0_OR_GREATER - [Fact] + [Test] public async Task Change_DisposedTimer_ShouldThrowObjectDisposedException() { using ITimer timer = TimeSystem.Timer.New(_ => @@ -54,7 +55,7 @@ void Act() } #endif - [Fact] + [Test] public async Task Change_Infinite_ShouldBeValidDueTime() { using ITimer timer = TimeSystem.Timer.New(_ => @@ -70,7 +71,7 @@ void Act() await That(Act).DoesNotThrow(); } - [Fact] + [Test] public async Task Change_Infinite_ShouldBeValidPeriod() { using ITimer timer = TimeSystem.Timer.New(_ => @@ -86,9 +87,9 @@ void Act() await That(Act).DoesNotThrow(); } - [Theory] - [InlineData(-2)] - [InlineData(-500)] + [Test] + [Arguments(-2)] + [Arguments(-500)] public async Task Change_InvalidDueTime_ShouldThrowArgumentOutOfRangeException(int dueTime) { using ITimer timer = TimeSystem.Timer.New(_ => @@ -105,9 +106,9 @@ await That(Act).Throws().WithHResult(-2146233086).A .WithParamName(nameof(dueTime)); } - [Theory] - [InlineData(-2)] - [InlineData(-500)] + [Test] + [Arguments(-2)] + [Arguments(-500)] public async Task Change_InvalidPeriod_ShouldThrowArgumentOutOfRangeException(int period) { using ITimer timer = TimeSystem.Timer.New(_ => @@ -124,7 +125,7 @@ await That(Act).Throws().WithHResult(-2146233086).A .WithParamName(nameof(period)); } - [Fact] + [Test] public async Task Change_SameValues_WithInt_ShouldReturnTrue() { using ITimer timer = TimeSystem.Timer.New(_ => @@ -136,7 +137,7 @@ public async Task Change_SameValues_WithInt_ShouldReturnTrue() await That(result).IsTrue(); } - [Fact] + [Test] public async Task Change_SameValues_WithLong_ShouldReturnTrue() { using ITimer timer = TimeSystem.Timer.New(_ => @@ -148,7 +149,7 @@ public async Task Change_SameValues_WithLong_ShouldReturnTrue() await That(result).IsTrue(); } - [Fact] + [Test] public async Task Change_SameValues_WithTimeSpan_ShouldReturnTrue() { using ITimer timer = TimeSystem.Timer.New(_ => @@ -160,7 +161,8 @@ public async Task Change_SameValues_WithTimeSpan_ShouldReturnTrue() await That(result).IsTrue(); } - [Fact(Skip = "Temporarily skip brittle tests")] + [Test] + [Skip("Temporarily skip brittle tests")] public async Task Change_WithInt_ShouldResetTimer() { SkipIfBrittleTestsShouldBeSkipped(); @@ -183,25 +185,25 @@ public async Task Change_WithInt_ShouldResetTimer() ms1.Set(); triggerTimes.Add((int)diff); // ReSharper disable once AccessToDisposedClosure - await That(ms2.Wait(ExpectSuccess, TestContext.Current.CancellationToken)) + await That(ms2.Wait(ExpectSuccess, CancellationToken)) .IsTrue(); if (triggerTimes.Count > 3) { - // ReSharper disable once AccessToDisposedClosure + // ReSharper disable once CancellationToken ms3.Set(); } - await Task.Delay(10, TestContext.Current.CancellationToken); + await Task.Delay(10, CancellationToken); } catch (ObjectDisposedException) { // Ignore any ObjectDisposedException } }, - null, 0 * TimerMultiplier, 200 * TimerMultiplier)) + null, (long)(0 * TimerMultiplier), 200 * TimerMultiplier)) #pragma warning restore MA0147 // Avoid async void method for delegate { - await That(ms1.Wait(ExpectSuccess, TestContext.Current.CancellationToken)).IsTrue(); + await That(ms1.Wait(ExpectSuccess, CancellationToken)).IsTrue(); using ITimer timer2 = TimeSystem.Timer.New(_ => { // ReSharper disable once AccessToDisposedClosure @@ -218,7 +220,7 @@ await That(ms2.Wait(ExpectSuccess, TestContext.Current.CancellationToken)) }, null, 100 * TimerMultiplier, 0 * TimerMultiplier); await That(ms3.Wait(ExpectSuccess * TimerMultiplier, - TestContext.Current.CancellationToken)).IsTrue(); + CancellationToken)).IsTrue(); } if (triggerTimes[0] < 30 * TimerMultiplier) @@ -234,7 +236,8 @@ await That(triggerTimes[i]).IsGreaterThan(170 * TimerMultiplier).And } } - [Fact(Skip = "Temporarily skip brittle tests")] + [Test] + [Skip("Temporarily skip brittle tests")] public async Task Change_WithLong_ShouldResetTimer() { SkipIfBrittleTestsShouldBeSkipped(); @@ -257,7 +260,7 @@ public async Task Change_WithLong_ShouldResetTimer() ms1.Set(); triggerTimes.Add((int)diff); // ReSharper disable once AccessToDisposedClosure - await That(ms2.Wait(ExpectSuccess, TestContext.Current.CancellationToken)) + await That(ms2.Wait(ExpectSuccess, CancellationToken)) .IsTrue(); if (triggerTimes.Count > 3) { @@ -265,7 +268,7 @@ await That(ms2.Wait(ExpectSuccess, TestContext.Current.CancellationToken)) ms3.Set(); } - await Task.Delay(10, TestContext.Current.CancellationToken); + await Task.Delay(10, CancellationToken); } catch (ObjectDisposedException) { @@ -275,7 +278,7 @@ await That(ms2.Wait(ExpectSuccess, TestContext.Current.CancellationToken)) null, 0L * TimerMultiplier, 200L * TimerMultiplier)) #pragma warning restore MA0147 // Avoid async void method for delegate { - await That(ms1.Wait(ExpectSuccess, TestContext.Current.CancellationToken)).IsTrue(); + await That(ms1.Wait(ExpectSuccess, CancellationToken)).IsTrue(); using ITimer timer2 = TimeSystem.Timer.New(_ => { // ReSharper disable once AccessToDisposedClosure @@ -291,7 +294,7 @@ await That(ms2.Wait(ExpectSuccess, TestContext.Current.CancellationToken)) } }, null, 100L * TimerMultiplier, 0L * TimerMultiplier); - await That(ms3.Wait(ExpectSuccess, TestContext.Current.CancellationToken)).IsTrue(); + await That(ms3.Wait(ExpectSuccess, CancellationToken)).IsTrue(); } if (triggerTimes[0] < 30 * TimerMultiplier) @@ -307,7 +310,8 @@ await That(triggerTimes[i]).IsGreaterThan(170 * TimerMultiplier).And } } - [Fact(Skip = "Temporarily skip brittle tests")] + [Test] + [Skip("Temporarily skip brittle tests")] public async Task Change_WithTimeSpan_ShouldResetTimer() { SkipIfBrittleTestsShouldBeSkipped(); @@ -330,7 +334,7 @@ public async Task Change_WithTimeSpan_ShouldResetTimer() ms1.Set(); triggerTimes.Add((int)diff); // ReSharper disable once AccessToDisposedClosure - await That(ms2.Wait(ExpectSuccess, TestContext.Current.CancellationToken)) + await That(ms2.Wait(ExpectSuccess, CancellationToken)) .IsTrue(); if (triggerTimes.Count > 3) { @@ -338,17 +342,18 @@ await That(ms2.Wait(ExpectSuccess, TestContext.Current.CancellationToken)) ms3.Set(); } - await Task.Delay(10, TestContext.Current.CancellationToken); + await Task.Delay(10, CancellationToken); } catch (ObjectDisposedException) { // Ignore any ObjectDisposedException } }, null, TimeSpan.FromMilliseconds(TimerMultiplier), + #pragma warning restore TUnit0031 TimeSpan.FromMilliseconds(200 * TimerMultiplier))) #pragma warning restore MA0147 // Avoid async void method for delegate { - await That(ms1.Wait(ExpectSuccess, TestContext.Current.CancellationToken)).IsTrue(); + await That(ms1.Wait(ExpectSuccess, CancellationToken)).IsTrue(); using ITimer timer2 = TimeSystem.Timer.New(_ => { // ReSharper disable once AccessToDisposedClosure @@ -366,7 +371,7 @@ await That(ms2.Wait(ExpectSuccess, TestContext.Current.CancellationToken)) }, null, TimeSpan.FromMilliseconds(100 * TimerMultiplier), TimeSpan.FromMilliseconds(TimerMultiplier)); - await That(ms3.Wait(ExpectSuccess, TestContext.Current.CancellationToken)).IsTrue(); + await That(ms3.Wait(ExpectSuccess, CancellationToken)).IsTrue(); } if (triggerTimes[0] < 30 * TimerMultiplier) @@ -382,7 +387,7 @@ await That(triggerTimes[i]).IsGreaterThan(170 * TimerMultiplier).And } } - [Fact] + [Test] public async Task Dispose_WithManualResetEventWaitHandle_ShouldBeSet() { using ITimer timer = TimeSystem.Timer.New(_ => @@ -407,7 +412,7 @@ void Act() #endif } - [Fact] + [Test] public async Task Dispose_WithMutexWaitHandle_ShouldBeSet() { using ITimer timer = TimeSystem.Timer.New(_ => @@ -432,7 +437,7 @@ void Act() #endif } - [Fact] + [Test] public async Task Dispose_WithSemaphoreWaitHandle_ShouldBeSet() { using ITimer timer = TimeSystem.Timer.New(_ => @@ -457,7 +462,7 @@ void Act() #endif } - [Fact] + [Test] public async Task Dispose_WithWaitHandleCalledTwice_ShouldReturnFalse() { using ITimer timer = TimeSystem.Timer.New(_ => @@ -472,7 +477,7 @@ public async Task Dispose_WithWaitHandleCalledTwice_ShouldReturnFalse() } #if FEATURE_ASYNC_DISPOSABLE - [Fact] + [Test] public async Task DisposeAsync_ShouldDisposeTimer() { await using ITimer timer = TimeSystem.Timer.New(_ => @@ -495,3 +500,4 @@ void Act() } #endif } +#pragma warning restore TUnit0031 diff --git a/Tests/Testably.Abstractions.Tests/xunit.runner.json b/Tests/Testably.Abstractions.Tests/xunit.runner.json deleted file mode 100644 index 5240d9162..000000000 --- a/Tests/Testably.Abstractions.Tests/xunit.runner.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "$schema": "https://xunit.net/schema/current/xunit.runner.schema.json", - "culture": "en-US", - "parallelizeTestCollections": false -} diff --git a/global.json b/global.json index 740515064..49aa6f9a5 100644 --- a/global.json +++ b/global.json @@ -2,5 +2,8 @@ "sdk": { "version": "10.0.103", "rollForward": "latestMinor" + }, + "test": { + "runner": "Microsoft.Testing.Platform" } }