From 8e50b00ff3a8c8fd28af4832ef95a8b81651acc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valentin=20Breu=C3=9F?= Date: Wed, 20 May 2026 18:09:59 +0200 Subject: [PATCH 1/2] feat: complete `IFileVersionInfo` expectations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add dedicated assertions for every `IFileVersionInfo` property — the remaining 7 strings (`HasComments`, `HasFileName`, `HasInternalName`, `HasLegalCopyright`, `HasLegalTrademarks`, `HasPrivateBuild`, `HasSpecialBuild`), the 8 integer version parts (`HasFileBuildPart`, `HasFileMajorPart`, `HasFileMinorPart`, `HasFilePrivatePart`, `HasProductBuildPart`, `HasProductMajorPart`, `HasProductMinorPart`, `HasProductPrivatePart`) and the boolean pairs `IsPrivateBuild` / `IsNotPrivateBuild` and `IsSpecialBuild` / `IsNotSpecialBuild`. --- README.md | 54 ++++++++----- .../FileVersionInfoExtensions.HasComments.cs | 26 +++++++ ...eVersionInfoExtensions.HasFileBuildPart.cs | 21 ++++++ ...eVersionInfoExtensions.HasFileMajorPart.cs | 21 ++++++ ...eVersionInfoExtensions.HasFileMinorPart.cs | 21 ++++++ .../FileVersionInfoExtensions.HasFileName.cs | 26 +++++++ ...ersionInfoExtensions.HasFilePrivatePart.cs | 21 ++++++ ...leVersionInfoExtensions.HasInternalName.cs | 26 +++++++ ...VersionInfoExtensions.HasLegalCopyright.cs | 26 +++++++ ...ersionInfoExtensions.HasLegalTrademarks.cs | 26 +++++++ ...leVersionInfoExtensions.HasPrivateBuild.cs | 26 +++++++ ...rsionInfoExtensions.HasProductBuildPart.cs | 21 ++++++ ...rsionInfoExtensions.HasProductMajorPart.cs | 21 ++++++ ...rsionInfoExtensions.HasProductMinorPart.cs | 21 ++++++ ...ionInfoExtensions.HasProductPrivatePart.cs | 21 ++++++ ...leVersionInfoExtensions.HasSpecialBuild.cs | 26 +++++++ ...ileVersionInfoExtensions.IsPrivateBuild.cs | 32 ++++++++ ...ileVersionInfoExtensions.IsSpecialBuild.cs | 32 ++++++++ .../Helpers/FileVersionInfoConstraints.cs | 56 ++++++++++++++ .../FileVersionInfo.HasComments.Tests.cs | 75 +++++++++++++++++++ .../FileVersionInfo.HasFileBuildPart.Tests.cs | 71 ++++++++++++++++++ .../FileVersionInfo.HasFileMajorPart.Tests.cs | 71 ++++++++++++++++++ .../FileVersionInfo.HasFileMinorPart.Tests.cs | 71 ++++++++++++++++++ .../FileVersionInfo.HasFileName.Tests.cs | 65 ++++++++++++++++ ...ileVersionInfo.HasFilePrivatePart.Tests.cs | 71 ++++++++++++++++++ .../FileVersionInfo.HasInternalName.Tests.cs | 75 +++++++++++++++++++ ...FileVersionInfo.HasLegalCopyright.Tests.cs | 75 +++++++++++++++++++ ...ileVersionInfo.HasLegalTrademarks.Tests.cs | 75 +++++++++++++++++++ .../FileVersionInfo.HasPrivateBuild.Tests.cs | 75 +++++++++++++++++++ ...leVersionInfo.HasProductBuildPart.Tests.cs | 71 ++++++++++++++++++ ...leVersionInfo.HasProductMajorPart.Tests.cs | 71 ++++++++++++++++++ ...leVersionInfo.HasProductMinorPart.Tests.cs | 71 ++++++++++++++++++ ...VersionInfo.HasProductPrivatePart.Tests.cs | 71 ++++++++++++++++++ .../FileVersionInfo.HasSpecialBuild.Tests.cs | 75 +++++++++++++++++++ ...FileVersionInfo.IsNotPrivateBuild.Tests.cs | 71 ++++++++++++++++++ ...FileVersionInfo.IsNotSpecialBuild.Tests.cs | 71 ++++++++++++++++++ .../FileVersionInfo.IsPrivateBuild.Tests.cs | 71 ++++++++++++++++++ .../FileVersionInfo.IsSpecialBuild.Tests.cs | 71 ++++++++++++++++++ 38 files changed, 1871 insertions(+), 20 deletions(-) create mode 100644 Source/aweXpect.Testably/FileVersionInfoExtensions.HasComments.cs create mode 100644 Source/aweXpect.Testably/FileVersionInfoExtensions.HasFileBuildPart.cs create mode 100644 Source/aweXpect.Testably/FileVersionInfoExtensions.HasFileMajorPart.cs create mode 100644 Source/aweXpect.Testably/FileVersionInfoExtensions.HasFileMinorPart.cs create mode 100644 Source/aweXpect.Testably/FileVersionInfoExtensions.HasFileName.cs create mode 100644 Source/aweXpect.Testably/FileVersionInfoExtensions.HasFilePrivatePart.cs create mode 100644 Source/aweXpect.Testably/FileVersionInfoExtensions.HasInternalName.cs create mode 100644 Source/aweXpect.Testably/FileVersionInfoExtensions.HasLegalCopyright.cs create mode 100644 Source/aweXpect.Testably/FileVersionInfoExtensions.HasLegalTrademarks.cs create mode 100644 Source/aweXpect.Testably/FileVersionInfoExtensions.HasPrivateBuild.cs create mode 100644 Source/aweXpect.Testably/FileVersionInfoExtensions.HasProductBuildPart.cs create mode 100644 Source/aweXpect.Testably/FileVersionInfoExtensions.HasProductMajorPart.cs create mode 100644 Source/aweXpect.Testably/FileVersionInfoExtensions.HasProductMinorPart.cs create mode 100644 Source/aweXpect.Testably/FileVersionInfoExtensions.HasProductPrivatePart.cs create mode 100644 Source/aweXpect.Testably/FileVersionInfoExtensions.HasSpecialBuild.cs create mode 100644 Source/aweXpect.Testably/FileVersionInfoExtensions.IsPrivateBuild.cs create mode 100644 Source/aweXpect.Testably/FileVersionInfoExtensions.IsSpecialBuild.cs create mode 100644 Tests/aweXpect.Testably.Tests/FileVersionInfo.HasComments.Tests.cs create mode 100644 Tests/aweXpect.Testably.Tests/FileVersionInfo.HasFileBuildPart.Tests.cs create mode 100644 Tests/aweXpect.Testably.Tests/FileVersionInfo.HasFileMajorPart.Tests.cs create mode 100644 Tests/aweXpect.Testably.Tests/FileVersionInfo.HasFileMinorPart.Tests.cs create mode 100644 Tests/aweXpect.Testably.Tests/FileVersionInfo.HasFileName.Tests.cs create mode 100644 Tests/aweXpect.Testably.Tests/FileVersionInfo.HasFilePrivatePart.Tests.cs create mode 100644 Tests/aweXpect.Testably.Tests/FileVersionInfo.HasInternalName.Tests.cs create mode 100644 Tests/aweXpect.Testably.Tests/FileVersionInfo.HasLegalCopyright.Tests.cs create mode 100644 Tests/aweXpect.Testably.Tests/FileVersionInfo.HasLegalTrademarks.Tests.cs create mode 100644 Tests/aweXpect.Testably.Tests/FileVersionInfo.HasPrivateBuild.Tests.cs create mode 100644 Tests/aweXpect.Testably.Tests/FileVersionInfo.HasProductBuildPart.Tests.cs create mode 100644 Tests/aweXpect.Testably.Tests/FileVersionInfo.HasProductMajorPart.Tests.cs create mode 100644 Tests/aweXpect.Testably.Tests/FileVersionInfo.HasProductMinorPart.Tests.cs create mode 100644 Tests/aweXpect.Testably.Tests/FileVersionInfo.HasProductPrivatePart.Tests.cs create mode 100644 Tests/aweXpect.Testably.Tests/FileVersionInfo.HasSpecialBuild.Tests.cs create mode 100644 Tests/aweXpect.Testably.Tests/FileVersionInfo.IsNotPrivateBuild.Tests.cs create mode 100644 Tests/aweXpect.Testably.Tests/FileVersionInfo.IsNotSpecialBuild.Tests.cs create mode 100644 Tests/aweXpect.Testably.Tests/FileVersionInfo.IsPrivateBuild.Tests.cs create mode 100644 Tests/aweXpect.Testably.Tests/FileVersionInfo.IsSpecialBuild.Tests.cs diff --git a/README.md b/README.md index e367af4..6c52e41 100644 --- a/README.md +++ b/README.md @@ -202,29 +202,43 @@ fileSystem.File.WriteAllText("Acme.dll", ""); IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); await That(info).HasCompanyName("Acme").And.HasProductName("Anvil"); -await That(info).HasFileVersion("1.2.3.4"); +await That(info).HasFileVersion("1.2.3.4").And.HasFileMajorPart(1); await That(info).IsDebug().And.IsNotPreRelease(); ``` -Dedicated assertions exist for the common fields (`HasCompanyName`, -`HasProductName`, `HasFileDescription`, `HasFileVersion`, `HasProductVersion`, -`HasOriginalFilename`, `HasLanguage`), plus the boolean pairs -`IsDebug` / `IsNotDebug`, `IsPreRelease` / `IsNotPreRelease` and -`IsPatched` / `IsNotPatched`. - -| Property | Assertion | -|-----------------------|--------------------------------------------| -| `CompanyName` | `HasCompanyName(string)` | -| `ProductName` | `HasProductName(string)` | -| `FileDescription` | `HasFileDescription(string)` | -| `FileVersion` | `HasFileVersion(string)` | -| `ProductVersion` | `HasProductVersion(string)` | -| `OriginalFilename` | `HasOriginalFilename(string)` | -| `Language` | `HasLanguage(string)` | -| `IsDebug` | `IsDebug()` / `IsNotDebug()` | -| `IsPreRelease` | `IsPreRelease()` / `IsNotPreRelease()` | -| `IsPatched` | `IsPatched()` / `IsNotPatched()` | -| _other_ (e.g. `Comments`, `LegalCopyright`, `FileMajorPart`) | `await That(info.X).Is…` | +Dedicated assertions cover every `IFileVersionInfo` property — strings via +`Has…(string)`, the integer version parts via `Has…(int)` and the booleans +as `Is…()` / `IsNot…()` pairs. + +| Property | Assertion | +|----------------------|--------------------------------------------| +| `Comments` | `HasComments(string)` | +| `CompanyName` | `HasCompanyName(string)` | +| `FileDescription` | `HasFileDescription(string)` | +| `FileName` | `HasFileName(string)` | +| `FileVersion` | `HasFileVersion(string)` | +| `InternalName` | `HasInternalName(string)` | +| `Language` | `HasLanguage(string)` | +| `LegalCopyright` | `HasLegalCopyright(string)` | +| `LegalTrademarks` | `HasLegalTrademarks(string)` | +| `OriginalFilename` | `HasOriginalFilename(string)` | +| `PrivateBuild` | `HasPrivateBuild(string)` | +| `ProductName` | `HasProductName(string)` | +| `ProductVersion` | `HasProductVersion(string)` | +| `SpecialBuild` | `HasSpecialBuild(string)` | +| `FileBuildPart` | `HasFileBuildPart(int)` | +| `FileMajorPart` | `HasFileMajorPart(int)` | +| `FileMinorPart` | `HasFileMinorPart(int)` | +| `FilePrivatePart` | `HasFilePrivatePart(int)` | +| `ProductBuildPart` | `HasProductBuildPart(int)` | +| `ProductMajorPart` | `HasProductMajorPart(int)` | +| `ProductMinorPart` | `HasProductMinorPart(int)` | +| `ProductPrivatePart` | `HasProductPrivatePart(int)` | +| `IsDebug` | `IsDebug()` / `IsNotDebug()` | +| `IsPatched` | `IsPatched()` / `IsNotPatched()` | +| `IsPreRelease` | `IsPreRelease()` / `IsNotPreRelease()` | +| `IsPrivateBuild` | `IsPrivateBuild()` / `IsNotPrivateBuild()` | +| `IsSpecialBuild` | `IsSpecialBuild()` / `IsNotSpecialBuild()` | ## File-system notifications diff --git a/Source/aweXpect.Testably/FileVersionInfoExtensions.HasComments.cs b/Source/aweXpect.Testably/FileVersionInfoExtensions.HasComments.cs new file mode 100644 index 0000000..f600bc1 --- /dev/null +++ b/Source/aweXpect.Testably/FileVersionInfoExtensions.HasComments.cs @@ -0,0 +1,26 @@ +using System.IO.Abstractions; +using aweXpect.Core; +using aweXpect.Options; +using aweXpect.Results; +using aweXpect.Testably.Helpers; + +namespace aweXpect.Testably; + +public static partial class FileVersionInfoExtensions +{ + /// + /// Verifies that the has the comments. + /// + public static StringEqualityTypeResult> HasComments( + this IThat source, + string? expected) + { + StringEqualityOptions options = new(); + return new StringEqualityTypeResult>( + source.Get().ExpectationBuilder.AddConstraint((it, grammars) + => new FileVersionInfoConstraints.HasStringPropertyConstraint( + it, grammars, v => v.Comments, options, expected, "comments")), + source, + options); + } +} diff --git a/Source/aweXpect.Testably/FileVersionInfoExtensions.HasFileBuildPart.cs b/Source/aweXpect.Testably/FileVersionInfoExtensions.HasFileBuildPart.cs new file mode 100644 index 0000000..f456bad --- /dev/null +++ b/Source/aweXpect.Testably/FileVersionInfoExtensions.HasFileBuildPart.cs @@ -0,0 +1,21 @@ +using System.IO.Abstractions; +using aweXpect.Core; +using aweXpect.Results; +using aweXpect.Testably.Helpers; + +namespace aweXpect.Testably; + +public static partial class FileVersionInfoExtensions +{ + /// + /// Verifies that the has the file build part. + /// + public static AndOrResult> HasFileBuildPart( + this IThat source, + int expected) + => new( + source.Get().ExpectationBuilder.AddConstraint((it, grammars) + => new FileVersionInfoConstraints.HasInt32PropertyConstraint( + it, grammars, v => v.FileBuildPart, expected, "file build part")), + source); +} diff --git a/Source/aweXpect.Testably/FileVersionInfoExtensions.HasFileMajorPart.cs b/Source/aweXpect.Testably/FileVersionInfoExtensions.HasFileMajorPart.cs new file mode 100644 index 0000000..8eb3176 --- /dev/null +++ b/Source/aweXpect.Testably/FileVersionInfoExtensions.HasFileMajorPart.cs @@ -0,0 +1,21 @@ +using System.IO.Abstractions; +using aweXpect.Core; +using aweXpect.Results; +using aweXpect.Testably.Helpers; + +namespace aweXpect.Testably; + +public static partial class FileVersionInfoExtensions +{ + /// + /// Verifies that the has the file major part. + /// + public static AndOrResult> HasFileMajorPart( + this IThat source, + int expected) + => new( + source.Get().ExpectationBuilder.AddConstraint((it, grammars) + => new FileVersionInfoConstraints.HasInt32PropertyConstraint( + it, grammars, v => v.FileMajorPart, expected, "file major part")), + source); +} diff --git a/Source/aweXpect.Testably/FileVersionInfoExtensions.HasFileMinorPart.cs b/Source/aweXpect.Testably/FileVersionInfoExtensions.HasFileMinorPart.cs new file mode 100644 index 0000000..d9e5eb2 --- /dev/null +++ b/Source/aweXpect.Testably/FileVersionInfoExtensions.HasFileMinorPart.cs @@ -0,0 +1,21 @@ +using System.IO.Abstractions; +using aweXpect.Core; +using aweXpect.Results; +using aweXpect.Testably.Helpers; + +namespace aweXpect.Testably; + +public static partial class FileVersionInfoExtensions +{ + /// + /// Verifies that the has the file minor part. + /// + public static AndOrResult> HasFileMinorPart( + this IThat source, + int expected) + => new( + source.Get().ExpectationBuilder.AddConstraint((it, grammars) + => new FileVersionInfoConstraints.HasInt32PropertyConstraint( + it, grammars, v => v.FileMinorPart, expected, "file minor part")), + source); +} diff --git a/Source/aweXpect.Testably/FileVersionInfoExtensions.HasFileName.cs b/Source/aweXpect.Testably/FileVersionInfoExtensions.HasFileName.cs new file mode 100644 index 0000000..163c06d --- /dev/null +++ b/Source/aweXpect.Testably/FileVersionInfoExtensions.HasFileName.cs @@ -0,0 +1,26 @@ +using System.IO.Abstractions; +using aweXpect.Core; +using aweXpect.Options; +using aweXpect.Results; +using aweXpect.Testably.Helpers; + +namespace aweXpect.Testably; + +public static partial class FileVersionInfoExtensions +{ + /// + /// Verifies that the has the file name. + /// + public static StringEqualityTypeResult> HasFileName( + this IThat source, + string? expected) + { + StringEqualityOptions options = new(); + return new StringEqualityTypeResult>( + source.Get().ExpectationBuilder.AddConstraint((it, grammars) + => new FileVersionInfoConstraints.HasStringPropertyConstraint( + it, grammars, v => v.FileName, options, expected, "file name")), + source, + options); + } +} diff --git a/Source/aweXpect.Testably/FileVersionInfoExtensions.HasFilePrivatePart.cs b/Source/aweXpect.Testably/FileVersionInfoExtensions.HasFilePrivatePart.cs new file mode 100644 index 0000000..8762088 --- /dev/null +++ b/Source/aweXpect.Testably/FileVersionInfoExtensions.HasFilePrivatePart.cs @@ -0,0 +1,21 @@ +using System.IO.Abstractions; +using aweXpect.Core; +using aweXpect.Results; +using aweXpect.Testably.Helpers; + +namespace aweXpect.Testably; + +public static partial class FileVersionInfoExtensions +{ + /// + /// Verifies that the has the file private part. + /// + public static AndOrResult> HasFilePrivatePart( + this IThat source, + int expected) + => new( + source.Get().ExpectationBuilder.AddConstraint((it, grammars) + => new FileVersionInfoConstraints.HasInt32PropertyConstraint( + it, grammars, v => v.FilePrivatePart, expected, "file private part")), + source); +} diff --git a/Source/aweXpect.Testably/FileVersionInfoExtensions.HasInternalName.cs b/Source/aweXpect.Testably/FileVersionInfoExtensions.HasInternalName.cs new file mode 100644 index 0000000..e916ede --- /dev/null +++ b/Source/aweXpect.Testably/FileVersionInfoExtensions.HasInternalName.cs @@ -0,0 +1,26 @@ +using System.IO.Abstractions; +using aweXpect.Core; +using aweXpect.Options; +using aweXpect.Results; +using aweXpect.Testably.Helpers; + +namespace aweXpect.Testably; + +public static partial class FileVersionInfoExtensions +{ + /// + /// Verifies that the has the internal name. + /// + public static StringEqualityTypeResult> HasInternalName( + this IThat source, + string? expected) + { + StringEqualityOptions options = new(); + return new StringEqualityTypeResult>( + source.Get().ExpectationBuilder.AddConstraint((it, grammars) + => new FileVersionInfoConstraints.HasStringPropertyConstraint( + it, grammars, v => v.InternalName, options, expected, "internal name")), + source, + options); + } +} diff --git a/Source/aweXpect.Testably/FileVersionInfoExtensions.HasLegalCopyright.cs b/Source/aweXpect.Testably/FileVersionInfoExtensions.HasLegalCopyright.cs new file mode 100644 index 0000000..c03f6f5 --- /dev/null +++ b/Source/aweXpect.Testably/FileVersionInfoExtensions.HasLegalCopyright.cs @@ -0,0 +1,26 @@ +using System.IO.Abstractions; +using aweXpect.Core; +using aweXpect.Options; +using aweXpect.Results; +using aweXpect.Testably.Helpers; + +namespace aweXpect.Testably; + +public static partial class FileVersionInfoExtensions +{ + /// + /// Verifies that the has the legal copyright. + /// + public static StringEqualityTypeResult> HasLegalCopyright( + this IThat source, + string? expected) + { + StringEqualityOptions options = new(); + return new StringEqualityTypeResult>( + source.Get().ExpectationBuilder.AddConstraint((it, grammars) + => new FileVersionInfoConstraints.HasStringPropertyConstraint( + it, grammars, v => v.LegalCopyright, options, expected, "legal copyright")), + source, + options); + } +} diff --git a/Source/aweXpect.Testably/FileVersionInfoExtensions.HasLegalTrademarks.cs b/Source/aweXpect.Testably/FileVersionInfoExtensions.HasLegalTrademarks.cs new file mode 100644 index 0000000..e779a8c --- /dev/null +++ b/Source/aweXpect.Testably/FileVersionInfoExtensions.HasLegalTrademarks.cs @@ -0,0 +1,26 @@ +using System.IO.Abstractions; +using aweXpect.Core; +using aweXpect.Options; +using aweXpect.Results; +using aweXpect.Testably.Helpers; + +namespace aweXpect.Testably; + +public static partial class FileVersionInfoExtensions +{ + /// + /// Verifies that the has the legal trademarks. + /// + public static StringEqualityTypeResult> HasLegalTrademarks( + this IThat source, + string? expected) + { + StringEqualityOptions options = new(); + return new StringEqualityTypeResult>( + source.Get().ExpectationBuilder.AddConstraint((it, grammars) + => new FileVersionInfoConstraints.HasStringPropertyConstraint( + it, grammars, v => v.LegalTrademarks, options, expected, "legal trademarks")), + source, + options); + } +} diff --git a/Source/aweXpect.Testably/FileVersionInfoExtensions.HasPrivateBuild.cs b/Source/aweXpect.Testably/FileVersionInfoExtensions.HasPrivateBuild.cs new file mode 100644 index 0000000..35ed3a4 --- /dev/null +++ b/Source/aweXpect.Testably/FileVersionInfoExtensions.HasPrivateBuild.cs @@ -0,0 +1,26 @@ +using System.IO.Abstractions; +using aweXpect.Core; +using aweXpect.Options; +using aweXpect.Results; +using aweXpect.Testably.Helpers; + +namespace aweXpect.Testably; + +public static partial class FileVersionInfoExtensions +{ + /// + /// Verifies that the has the private build. + /// + public static StringEqualityTypeResult> HasPrivateBuild( + this IThat source, + string? expected) + { + StringEqualityOptions options = new(); + return new StringEqualityTypeResult>( + source.Get().ExpectationBuilder.AddConstraint((it, grammars) + => new FileVersionInfoConstraints.HasStringPropertyConstraint( + it, grammars, v => v.PrivateBuild, options, expected, "private build")), + source, + options); + } +} diff --git a/Source/aweXpect.Testably/FileVersionInfoExtensions.HasProductBuildPart.cs b/Source/aweXpect.Testably/FileVersionInfoExtensions.HasProductBuildPart.cs new file mode 100644 index 0000000..bcf7a6c --- /dev/null +++ b/Source/aweXpect.Testably/FileVersionInfoExtensions.HasProductBuildPart.cs @@ -0,0 +1,21 @@ +using System.IO.Abstractions; +using aweXpect.Core; +using aweXpect.Results; +using aweXpect.Testably.Helpers; + +namespace aweXpect.Testably; + +public static partial class FileVersionInfoExtensions +{ + /// + /// Verifies that the has the product build part. + /// + public static AndOrResult> HasProductBuildPart( + this IThat source, + int expected) + => new( + source.Get().ExpectationBuilder.AddConstraint((it, grammars) + => new FileVersionInfoConstraints.HasInt32PropertyConstraint( + it, grammars, v => v.ProductBuildPart, expected, "product build part")), + source); +} diff --git a/Source/aweXpect.Testably/FileVersionInfoExtensions.HasProductMajorPart.cs b/Source/aweXpect.Testably/FileVersionInfoExtensions.HasProductMajorPart.cs new file mode 100644 index 0000000..e7ebcdb --- /dev/null +++ b/Source/aweXpect.Testably/FileVersionInfoExtensions.HasProductMajorPart.cs @@ -0,0 +1,21 @@ +using System.IO.Abstractions; +using aweXpect.Core; +using aweXpect.Results; +using aweXpect.Testably.Helpers; + +namespace aweXpect.Testably; + +public static partial class FileVersionInfoExtensions +{ + /// + /// Verifies that the has the product major part. + /// + public static AndOrResult> HasProductMajorPart( + this IThat source, + int expected) + => new( + source.Get().ExpectationBuilder.AddConstraint((it, grammars) + => new FileVersionInfoConstraints.HasInt32PropertyConstraint( + it, grammars, v => v.ProductMajorPart, expected, "product major part")), + source); +} diff --git a/Source/aweXpect.Testably/FileVersionInfoExtensions.HasProductMinorPart.cs b/Source/aweXpect.Testably/FileVersionInfoExtensions.HasProductMinorPart.cs new file mode 100644 index 0000000..2096905 --- /dev/null +++ b/Source/aweXpect.Testably/FileVersionInfoExtensions.HasProductMinorPart.cs @@ -0,0 +1,21 @@ +using System.IO.Abstractions; +using aweXpect.Core; +using aweXpect.Results; +using aweXpect.Testably.Helpers; + +namespace aweXpect.Testably; + +public static partial class FileVersionInfoExtensions +{ + /// + /// Verifies that the has the product minor part. + /// + public static AndOrResult> HasProductMinorPart( + this IThat source, + int expected) + => new( + source.Get().ExpectationBuilder.AddConstraint((it, grammars) + => new FileVersionInfoConstraints.HasInt32PropertyConstraint( + it, grammars, v => v.ProductMinorPart, expected, "product minor part")), + source); +} diff --git a/Source/aweXpect.Testably/FileVersionInfoExtensions.HasProductPrivatePart.cs b/Source/aweXpect.Testably/FileVersionInfoExtensions.HasProductPrivatePart.cs new file mode 100644 index 0000000..b79a936 --- /dev/null +++ b/Source/aweXpect.Testably/FileVersionInfoExtensions.HasProductPrivatePart.cs @@ -0,0 +1,21 @@ +using System.IO.Abstractions; +using aweXpect.Core; +using aweXpect.Results; +using aweXpect.Testably.Helpers; + +namespace aweXpect.Testably; + +public static partial class FileVersionInfoExtensions +{ + /// + /// Verifies that the has the product private part. + /// + public static AndOrResult> HasProductPrivatePart( + this IThat source, + int expected) + => new( + source.Get().ExpectationBuilder.AddConstraint((it, grammars) + => new FileVersionInfoConstraints.HasInt32PropertyConstraint( + it, grammars, v => v.ProductPrivatePart, expected, "product private part")), + source); +} diff --git a/Source/aweXpect.Testably/FileVersionInfoExtensions.HasSpecialBuild.cs b/Source/aweXpect.Testably/FileVersionInfoExtensions.HasSpecialBuild.cs new file mode 100644 index 0000000..4a4ecaa --- /dev/null +++ b/Source/aweXpect.Testably/FileVersionInfoExtensions.HasSpecialBuild.cs @@ -0,0 +1,26 @@ +using System.IO.Abstractions; +using aweXpect.Core; +using aweXpect.Options; +using aweXpect.Results; +using aweXpect.Testably.Helpers; + +namespace aweXpect.Testably; + +public static partial class FileVersionInfoExtensions +{ + /// + /// Verifies that the has the special build. + /// + public static StringEqualityTypeResult> HasSpecialBuild( + this IThat source, + string? expected) + { + StringEqualityOptions options = new(); + return new StringEqualityTypeResult>( + source.Get().ExpectationBuilder.AddConstraint((it, grammars) + => new FileVersionInfoConstraints.HasStringPropertyConstraint( + it, grammars, v => v.SpecialBuild, options, expected, "special build")), + source, + options); + } +} diff --git a/Source/aweXpect.Testably/FileVersionInfoExtensions.IsPrivateBuild.cs b/Source/aweXpect.Testably/FileVersionInfoExtensions.IsPrivateBuild.cs new file mode 100644 index 0000000..dd336ba --- /dev/null +++ b/Source/aweXpect.Testably/FileVersionInfoExtensions.IsPrivateBuild.cs @@ -0,0 +1,32 @@ +using System.IO.Abstractions; +using aweXpect.Core; +using aweXpect.Core.Constraints; +using aweXpect.Results; +using aweXpect.Testably.Helpers; + +namespace aweXpect.Testably; + +public static partial class FileVersionInfoExtensions +{ + /// + /// Verifies that the is a private build. + /// + public static AndOrResult> IsPrivateBuild( + this IThat source) + => new( + source.Get().ExpectationBuilder.AddConstraint((it, grammars) + => new FileVersionInfoConstraints.HasBoolPropertyConstraint( + it, grammars, v => v.IsPrivateBuild, "is private build", "is not private build")), + source); + + /// + /// Verifies that the is not a private build. + /// + public static AndOrResult> IsNotPrivateBuild( + this IThat source) + => new( + source.Get().ExpectationBuilder.AddConstraint((it, grammars) + => new FileVersionInfoConstraints.HasBoolPropertyConstraint( + it, grammars, v => v.IsPrivateBuild, "is private build", "is not private build").Invert()), + source); +} diff --git a/Source/aweXpect.Testably/FileVersionInfoExtensions.IsSpecialBuild.cs b/Source/aweXpect.Testably/FileVersionInfoExtensions.IsSpecialBuild.cs new file mode 100644 index 0000000..4f515ee --- /dev/null +++ b/Source/aweXpect.Testably/FileVersionInfoExtensions.IsSpecialBuild.cs @@ -0,0 +1,32 @@ +using System.IO.Abstractions; +using aweXpect.Core; +using aweXpect.Core.Constraints; +using aweXpect.Results; +using aweXpect.Testably.Helpers; + +namespace aweXpect.Testably; + +public static partial class FileVersionInfoExtensions +{ + /// + /// Verifies that the is a special build. + /// + public static AndOrResult> IsSpecialBuild( + this IThat source) + => new( + source.Get().ExpectationBuilder.AddConstraint((it, grammars) + => new FileVersionInfoConstraints.HasBoolPropertyConstraint( + it, grammars, v => v.IsSpecialBuild, "is special build", "is not special build")), + source); + + /// + /// Verifies that the is not a special build. + /// + public static AndOrResult> IsNotSpecialBuild( + this IThat source) + => new( + source.Get().ExpectationBuilder.AddConstraint((it, grammars) + => new FileVersionInfoConstraints.HasBoolPropertyConstraint( + it, grammars, v => v.IsSpecialBuild, "is special build", "is not special build").Invert()), + source); +} diff --git a/Source/aweXpect.Testably/Helpers/FileVersionInfoConstraints.cs b/Source/aweXpect.Testably/Helpers/FileVersionInfoConstraints.cs index 47af7d6..ae817c5 100644 --- a/Source/aweXpect.Testably/Helpers/FileVersionInfoConstraints.cs +++ b/Source/aweXpect.Testably/Helpers/FileVersionInfoConstraints.cs @@ -70,6 +70,62 @@ protected override void AppendNegatedResult(StringBuilder stringBuilder, string? } } + internal sealed class HasInt32PropertyConstraint( + string it, + ExpectationGrammars grammars, + Func selector, + int expected, + string propertyName) + : ConstraintResult.WithValue(grammars), + IValueConstraint + { + private int _actualValue; + + public ConstraintResult IsMetBy(IFileVersionInfo actual) + { + Actual = actual; + if (actual is null) + { + Outcome = Outcome.Failure; + return this; + } + + _actualValue = selector(actual); + Outcome = _actualValue == expected ? Outcome.Success : Outcome.Failure; + return this; + } + + protected override void AppendNormalExpectation(StringBuilder stringBuilder, string? indentation = null) + => stringBuilder.Append("has ").Append(propertyName).Append(' ').Append(expected); + + protected override void AppendNormalResult(StringBuilder stringBuilder, string? indentation = null) + { + if (Actual is null) + { + stringBuilder.Append(it).Append(" was "); + } + else + { + stringBuilder.Append(it).Append(" was ").Append(_actualValue); + } + } + + protected override void AppendNegatedExpectation(StringBuilder stringBuilder, string? indentation = null) + => stringBuilder.Append("does not have ").Append(propertyName).Append(' ').Append(expected); + + protected override void AppendNegatedResult(StringBuilder stringBuilder, string? indentation = null) + { + if (Actual is null) + { + stringBuilder.Append(it).Append(" was "); + } + else + { + stringBuilder.Append(it).Append(" did"); + } + } + } + internal sealed class HasBoolPropertyConstraint( string it, ExpectationGrammars grammars, diff --git a/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasComments.Tests.cs b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasComments.Tests.cs new file mode 100644 index 0000000..d9ac903 --- /dev/null +++ b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasComments.Tests.cs @@ -0,0 +1,75 @@ +using System.IO.Abstractions; +using Testably.Abstractions.Testing; + +namespace aweXpect.Testably.Tests; + +public sealed partial class FileVersionInfo +{ + public sealed class HasComments + { + public sealed class Tests + { + [Fact] + public async Task WhenCommentsDiffers_ShouldFail() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v.SetComments("Acme comment")); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).HasComments("Other comment"); + } + + await That(Act).ThrowsException() + .WithMessage(""" + Expected that info + has comments equal to "Other comment", + but it was "Acme comment" which differs at index 0: + ↓ (actual) + "Acme comment" + "Other comment" + ↑ (expected) + """); + } + + [Fact] + public async Task WhenCommentsMatches_ShouldSucceed() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v.SetComments("Acme comment")); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).HasComments("Acme comment"); + } + + await That(Act).DoesNotThrow(); + } + + [Fact] + public async Task ShouldSupportAndComposition() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v + .SetComments("Acme comment") + .SetCompanyName("Acme")); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).HasComments("Acme comment").And.HasCompanyName("Acme"); + } + + await That(Act).DoesNotThrow(); + } + } + } +} diff --git a/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasFileBuildPart.Tests.cs b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasFileBuildPart.Tests.cs new file mode 100644 index 0000000..4d67fc7 --- /dev/null +++ b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasFileBuildPart.Tests.cs @@ -0,0 +1,71 @@ +using System.IO.Abstractions; +using Testably.Abstractions.Testing; + +namespace aweXpect.Testably.Tests; + +public sealed partial class FileVersionInfo +{ + public sealed class HasFileBuildPart + { + public sealed class Tests + { + [Fact] + public async Task WhenFileBuildPartMatches_ShouldSucceed() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v.SetFileVersion("1.2.3.4")); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).HasFileBuildPart(3); + } + + await That(Act).DoesNotThrow(); + } + + [Fact] + public async Task WhenFileBuildPartDiffers_ShouldFail() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v.SetFileVersion("1.2.3.4")); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).HasFileBuildPart(9); + } + + await That(Act).ThrowsException() + .WithMessage(""" + Expected that info + has file build part 9, + but it was 3 + """); + } + + [Fact] + public async Task ShouldSupportAndComposition() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v + .SetFileVersion("1.2.3.4") + .SetCompanyName("Acme")); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).HasFileBuildPart(3).And.HasCompanyName("Acme"); + } + + await That(Act).DoesNotThrow(); + } + } + } +} diff --git a/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasFileMajorPart.Tests.cs b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasFileMajorPart.Tests.cs new file mode 100644 index 0000000..b6275c1 --- /dev/null +++ b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasFileMajorPart.Tests.cs @@ -0,0 +1,71 @@ +using System.IO.Abstractions; +using Testably.Abstractions.Testing; + +namespace aweXpect.Testably.Tests; + +public sealed partial class FileVersionInfo +{ + public sealed class HasFileMajorPart + { + public sealed class Tests + { + [Fact] + public async Task WhenFileMajorPartMatches_ShouldSucceed() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v.SetFileVersion("1.2.3.4")); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).HasFileMajorPart(1); + } + + await That(Act).DoesNotThrow(); + } + + [Fact] + public async Task WhenFileMajorPartDiffers_ShouldFail() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v.SetFileVersion("1.2.3.4")); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).HasFileMajorPart(9); + } + + await That(Act).ThrowsException() + .WithMessage(""" + Expected that info + has file major part 9, + but it was 1 + """); + } + + [Fact] + public async Task ShouldSupportAndComposition() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v + .SetFileVersion("1.2.3.4") + .SetCompanyName("Acme")); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).HasFileMajorPart(1).And.HasCompanyName("Acme"); + } + + await That(Act).DoesNotThrow(); + } + } + } +} diff --git a/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasFileMinorPart.Tests.cs b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasFileMinorPart.Tests.cs new file mode 100644 index 0000000..0a24ba9 --- /dev/null +++ b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasFileMinorPart.Tests.cs @@ -0,0 +1,71 @@ +using System.IO.Abstractions; +using Testably.Abstractions.Testing; + +namespace aweXpect.Testably.Tests; + +public sealed partial class FileVersionInfo +{ + public sealed class HasFileMinorPart + { + public sealed class Tests + { + [Fact] + public async Task WhenFileMinorPartMatches_ShouldSucceed() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v.SetFileVersion("1.2.3.4")); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).HasFileMinorPart(2); + } + + await That(Act).DoesNotThrow(); + } + + [Fact] + public async Task WhenFileMinorPartDiffers_ShouldFail() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v.SetFileVersion("1.2.3.4")); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).HasFileMinorPart(9); + } + + await That(Act).ThrowsException() + .WithMessage(""" + Expected that info + has file minor part 9, + but it was 2 + """); + } + + [Fact] + public async Task ShouldSupportAndComposition() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v + .SetFileVersion("1.2.3.4") + .SetCompanyName("Acme")); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).HasFileMinorPart(2).And.HasCompanyName("Acme"); + } + + await That(Act).DoesNotThrow(); + } + } + } +} diff --git a/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasFileName.Tests.cs b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasFileName.Tests.cs new file mode 100644 index 0000000..a1d874b --- /dev/null +++ b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasFileName.Tests.cs @@ -0,0 +1,65 @@ +using System.IO.Abstractions; +using Testably.Abstractions.Testing; + +namespace aweXpect.Testably.Tests; + +public sealed partial class FileVersionInfo +{ + public sealed class HasFileName + { + public sealed class Tests + { + [Fact] + public async Task WhenFileNameMatches_ShouldSucceed() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v.SetCompanyName("Acme")); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).HasFileName(info.FileName); + } + + await That(Act).DoesNotThrow(); + } + + [Fact] + public async Task WhenFileNameDiffers_ShouldFail() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v.SetCompanyName("Acme")); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).HasFileName("Other.dll"); + } + + await That(Act).ThrowsException() + .WithMessage("*has file name equal to \"Other.dll\"*").AsWildcard(); + } + + [Fact] + public async Task ShouldSupportAndComposition() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v.SetCompanyName("Acme")); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).HasFileName(info.FileName).And.HasCompanyName("Acme"); + } + + await That(Act).DoesNotThrow(); + } + } + } +} diff --git a/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasFilePrivatePart.Tests.cs b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasFilePrivatePart.Tests.cs new file mode 100644 index 0000000..0dde353 --- /dev/null +++ b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasFilePrivatePart.Tests.cs @@ -0,0 +1,71 @@ +using System.IO.Abstractions; +using Testably.Abstractions.Testing; + +namespace aweXpect.Testably.Tests; + +public sealed partial class FileVersionInfo +{ + public sealed class HasFilePrivatePart + { + public sealed class Tests + { + [Fact] + public async Task WhenFilePrivatePartMatches_ShouldSucceed() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v.SetFileVersion("1.2.3.4")); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).HasFilePrivatePart(4); + } + + await That(Act).DoesNotThrow(); + } + + [Fact] + public async Task WhenFilePrivatePartDiffers_ShouldFail() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v.SetFileVersion("1.2.3.4")); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).HasFilePrivatePart(9); + } + + await That(Act).ThrowsException() + .WithMessage(""" + Expected that info + has file private part 9, + but it was 4 + """); + } + + [Fact] + public async Task ShouldSupportAndComposition() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v + .SetFileVersion("1.2.3.4") + .SetCompanyName("Acme")); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).HasFilePrivatePart(4).And.HasCompanyName("Acme"); + } + + await That(Act).DoesNotThrow(); + } + } + } +} diff --git a/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasInternalName.Tests.cs b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasInternalName.Tests.cs new file mode 100644 index 0000000..bb2e22d --- /dev/null +++ b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasInternalName.Tests.cs @@ -0,0 +1,75 @@ +using System.IO.Abstractions; +using Testably.Abstractions.Testing; + +namespace aweXpect.Testably.Tests; + +public sealed partial class FileVersionInfo +{ + public sealed class HasInternalName + { + public sealed class Tests + { + [Fact] + public async Task WhenInternalNameDiffers_ShouldFail() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v.SetInternalName("AcmeInternal")); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).HasInternalName("OtherInternal"); + } + + await That(Act).ThrowsException() + .WithMessage(""" + Expected that info + has internal name equal to "OtherInternal", + but it was "AcmeInternal" which differs at index 0: + ↓ (actual) + "AcmeInternal" + "OtherInternal" + ↑ (expected) + """); + } + + [Fact] + public async Task WhenInternalNameMatches_ShouldSucceed() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v.SetInternalName("AcmeInternal")); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).HasInternalName("AcmeInternal"); + } + + await That(Act).DoesNotThrow(); + } + + [Fact] + public async Task ShouldSupportAndComposition() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v + .SetInternalName("AcmeInternal") + .SetCompanyName("Acme")); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).HasInternalName("AcmeInternal").And.HasCompanyName("Acme"); + } + + await That(Act).DoesNotThrow(); + } + } + } +} diff --git a/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasLegalCopyright.Tests.cs b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasLegalCopyright.Tests.cs new file mode 100644 index 0000000..04ab6de --- /dev/null +++ b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasLegalCopyright.Tests.cs @@ -0,0 +1,75 @@ +using System.IO.Abstractions; +using Testably.Abstractions.Testing; + +namespace aweXpect.Testably.Tests; + +public sealed partial class FileVersionInfo +{ + public sealed class HasLegalCopyright + { + public sealed class Tests + { + [Fact] + public async Task WhenLegalCopyrightDiffers_ShouldFail() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v.SetLegalCopyright("Acme (c)")); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).HasLegalCopyright("Other (c)"); + } + + await That(Act).ThrowsException() + .WithMessage(""" + Expected that info + has legal copyright equal to "Other (c)", + but it was "Acme (c)" which differs at index 0: + ↓ (actual) + "Acme (c)" + "Other (c)" + ↑ (expected) + """); + } + + [Fact] + public async Task WhenLegalCopyrightMatches_ShouldSucceed() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v.SetLegalCopyright("Acme (c)")); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).HasLegalCopyright("Acme (c)"); + } + + await That(Act).DoesNotThrow(); + } + + [Fact] + public async Task ShouldSupportAndComposition() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v + .SetLegalCopyright("Acme (c)") + .SetCompanyName("Acme")); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).HasLegalCopyright("Acme (c)").And.HasCompanyName("Acme"); + } + + await That(Act).DoesNotThrow(); + } + } + } +} diff --git a/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasLegalTrademarks.Tests.cs b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasLegalTrademarks.Tests.cs new file mode 100644 index 0000000..2ad7a9c --- /dev/null +++ b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasLegalTrademarks.Tests.cs @@ -0,0 +1,75 @@ +using System.IO.Abstractions; +using Testably.Abstractions.Testing; + +namespace aweXpect.Testably.Tests; + +public sealed partial class FileVersionInfo +{ + public sealed class HasLegalTrademarks + { + public sealed class Tests + { + [Fact] + public async Task WhenLegalTrademarksDiffers_ShouldFail() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v.SetLegalTrademarks("Acme (TM)")); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).HasLegalTrademarks("Other (TM)"); + } + + await That(Act).ThrowsException() + .WithMessage(""" + Expected that info + has legal trademarks equal to "Other (TM)", + but it was "Acme (TM)" which differs at index 0: + ↓ (actual) + "Acme (TM)" + "Other (TM)" + ↑ (expected) + """); + } + + [Fact] + public async Task WhenLegalTrademarksMatches_ShouldSucceed() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v.SetLegalTrademarks("Acme (TM)")); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).HasLegalTrademarks("Acme (TM)"); + } + + await That(Act).DoesNotThrow(); + } + + [Fact] + public async Task ShouldSupportAndComposition() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v + .SetLegalTrademarks("Acme (TM)") + .SetCompanyName("Acme")); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).HasLegalTrademarks("Acme (TM)").And.HasCompanyName("Acme"); + } + + await That(Act).DoesNotThrow(); + } + } + } +} diff --git a/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasPrivateBuild.Tests.cs b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasPrivateBuild.Tests.cs new file mode 100644 index 0000000..c6d6940 --- /dev/null +++ b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasPrivateBuild.Tests.cs @@ -0,0 +1,75 @@ +using System.IO.Abstractions; +using Testably.Abstractions.Testing; + +namespace aweXpect.Testably.Tests; + +public sealed partial class FileVersionInfo +{ + public sealed class HasPrivateBuild + { + public sealed class Tests + { + [Fact] + public async Task WhenPrivateBuildDiffers_ShouldFail() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v.SetPrivateBuild("Acme")); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).HasPrivateBuild("Contoso"); + } + + await That(Act).ThrowsException() + .WithMessage(""" + Expected that info + has private build equal to "Contoso", + but it was "Acme" which differs at index 0: + ↓ (actual) + "Acme" + "Contoso" + ↑ (expected) + """); + } + + [Fact] + public async Task WhenPrivateBuildMatches_ShouldSucceed() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v.SetPrivateBuild("Acme")); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).HasPrivateBuild("Acme"); + } + + await That(Act).DoesNotThrow(); + } + + [Fact] + public async Task ShouldSupportAndComposition() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v + .SetPrivateBuild("Acme") + .SetCompanyName("Acme")); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).HasPrivateBuild("Acme").And.HasCompanyName("Acme"); + } + + await That(Act).DoesNotThrow(); + } + } + } +} diff --git a/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasProductBuildPart.Tests.cs b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasProductBuildPart.Tests.cs new file mode 100644 index 0000000..24a9fc4 --- /dev/null +++ b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasProductBuildPart.Tests.cs @@ -0,0 +1,71 @@ +using System.IO.Abstractions; +using Testably.Abstractions.Testing; + +namespace aweXpect.Testably.Tests; + +public sealed partial class FileVersionInfo +{ + public sealed class HasProductBuildPart + { + public sealed class Tests + { + [Fact] + public async Task WhenProductBuildPartMatches_ShouldSucceed() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v.SetProductVersion("5.6.7.8")); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).HasProductBuildPart(7); + } + + await That(Act).DoesNotThrow(); + } + + [Fact] + public async Task WhenProductBuildPartDiffers_ShouldFail() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v.SetProductVersion("5.6.7.8")); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).HasProductBuildPart(9); + } + + await That(Act).ThrowsException() + .WithMessage(""" + Expected that info + has product build part 9, + but it was 7 + """); + } + + [Fact] + public async Task ShouldSupportAndComposition() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v + .SetProductVersion("5.6.7.8") + .SetCompanyName("Acme")); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).HasProductBuildPart(7).And.HasCompanyName("Acme"); + } + + await That(Act).DoesNotThrow(); + } + } + } +} diff --git a/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasProductMajorPart.Tests.cs b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasProductMajorPart.Tests.cs new file mode 100644 index 0000000..12181d7 --- /dev/null +++ b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasProductMajorPart.Tests.cs @@ -0,0 +1,71 @@ +using System.IO.Abstractions; +using Testably.Abstractions.Testing; + +namespace aweXpect.Testably.Tests; + +public sealed partial class FileVersionInfo +{ + public sealed class HasProductMajorPart + { + public sealed class Tests + { + [Fact] + public async Task WhenProductMajorPartMatches_ShouldSucceed() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v.SetProductVersion("5.6.7.8")); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).HasProductMajorPart(5); + } + + await That(Act).DoesNotThrow(); + } + + [Fact] + public async Task WhenProductMajorPartDiffers_ShouldFail() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v.SetProductVersion("5.6.7.8")); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).HasProductMajorPart(9); + } + + await That(Act).ThrowsException() + .WithMessage(""" + Expected that info + has product major part 9, + but it was 5 + """); + } + + [Fact] + public async Task ShouldSupportAndComposition() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v + .SetProductVersion("5.6.7.8") + .SetCompanyName("Acme")); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).HasProductMajorPart(5).And.HasCompanyName("Acme"); + } + + await That(Act).DoesNotThrow(); + } + } + } +} diff --git a/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasProductMinorPart.Tests.cs b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasProductMinorPart.Tests.cs new file mode 100644 index 0000000..a28529a --- /dev/null +++ b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasProductMinorPart.Tests.cs @@ -0,0 +1,71 @@ +using System.IO.Abstractions; +using Testably.Abstractions.Testing; + +namespace aweXpect.Testably.Tests; + +public sealed partial class FileVersionInfo +{ + public sealed class HasProductMinorPart + { + public sealed class Tests + { + [Fact] + public async Task WhenProductMinorPartMatches_ShouldSucceed() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v.SetProductVersion("5.6.7.8")); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).HasProductMinorPart(6); + } + + await That(Act).DoesNotThrow(); + } + + [Fact] + public async Task WhenProductMinorPartDiffers_ShouldFail() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v.SetProductVersion("5.6.7.8")); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).HasProductMinorPart(9); + } + + await That(Act).ThrowsException() + .WithMessage(""" + Expected that info + has product minor part 9, + but it was 6 + """); + } + + [Fact] + public async Task ShouldSupportAndComposition() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v + .SetProductVersion("5.6.7.8") + .SetCompanyName("Acme")); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).HasProductMinorPart(6).And.HasCompanyName("Acme"); + } + + await That(Act).DoesNotThrow(); + } + } + } +} diff --git a/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasProductPrivatePart.Tests.cs b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasProductPrivatePart.Tests.cs new file mode 100644 index 0000000..1f1a555 --- /dev/null +++ b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasProductPrivatePart.Tests.cs @@ -0,0 +1,71 @@ +using System.IO.Abstractions; +using Testably.Abstractions.Testing; + +namespace aweXpect.Testably.Tests; + +public sealed partial class FileVersionInfo +{ + public sealed class HasProductPrivatePart + { + public sealed class Tests + { + [Fact] + public async Task WhenProductPrivatePartMatches_ShouldSucceed() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v.SetProductVersion("5.6.7.8")); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).HasProductPrivatePart(8); + } + + await That(Act).DoesNotThrow(); + } + + [Fact] + public async Task WhenProductPrivatePartDiffers_ShouldFail() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v.SetProductVersion("5.6.7.8")); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).HasProductPrivatePart(9); + } + + await That(Act).ThrowsException() + .WithMessage(""" + Expected that info + has product private part 9, + but it was 8 + """); + } + + [Fact] + public async Task ShouldSupportAndComposition() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v + .SetProductVersion("5.6.7.8") + .SetCompanyName("Acme")); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).HasProductPrivatePart(8).And.HasCompanyName("Acme"); + } + + await That(Act).DoesNotThrow(); + } + } + } +} diff --git a/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasSpecialBuild.Tests.cs b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasSpecialBuild.Tests.cs new file mode 100644 index 0000000..143a78a --- /dev/null +++ b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasSpecialBuild.Tests.cs @@ -0,0 +1,75 @@ +using System.IO.Abstractions; +using Testably.Abstractions.Testing; + +namespace aweXpect.Testably.Tests; + +public sealed partial class FileVersionInfo +{ + public sealed class HasSpecialBuild + { + public sealed class Tests + { + [Fact] + public async Task WhenSpecialBuildDiffers_ShouldFail() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v.SetSpecialBuild("Acme")); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).HasSpecialBuild("Contoso"); + } + + await That(Act).ThrowsException() + .WithMessage(""" + Expected that info + has special build equal to "Contoso", + but it was "Acme" which differs at index 0: + ↓ (actual) + "Acme" + "Contoso" + ↑ (expected) + """); + } + + [Fact] + public async Task WhenSpecialBuildMatches_ShouldSucceed() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v.SetSpecialBuild("Acme")); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).HasSpecialBuild("Acme"); + } + + await That(Act).DoesNotThrow(); + } + + [Fact] + public async Task ShouldSupportAndComposition() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v + .SetSpecialBuild("Acme") + .SetCompanyName("Acme")); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).HasSpecialBuild("Acme").And.HasCompanyName("Acme"); + } + + await That(Act).DoesNotThrow(); + } + } + } +} diff --git a/Tests/aweXpect.Testably.Tests/FileVersionInfo.IsNotPrivateBuild.Tests.cs b/Tests/aweXpect.Testably.Tests/FileVersionInfo.IsNotPrivateBuild.Tests.cs new file mode 100644 index 0000000..06e0d9c --- /dev/null +++ b/Tests/aweXpect.Testably.Tests/FileVersionInfo.IsNotPrivateBuild.Tests.cs @@ -0,0 +1,71 @@ +using System.IO.Abstractions; +using Testably.Abstractions.Testing; + +namespace aweXpect.Testably.Tests; + +public sealed partial class FileVersionInfo +{ + public sealed class IsNotPrivateBuild + { + public sealed class Tests + { + [Fact] + public async Task WhenInfoIsNotPrivateBuild_ShouldSucceed() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v.SetIsPrivateBuild(false)); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).IsNotPrivateBuild(); + } + + await That(Act).DoesNotThrow(); + } + + [Fact] + public async Task WhenInfoIsPrivateBuild_ShouldFail() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v.SetIsPrivateBuild(true)); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).IsNotPrivateBuild(); + } + + await That(Act).ThrowsException() + .WithMessage(""" + Expected that info + is not private build, + but it was + """); + } + + [Fact] + public async Task ShouldSupportAndComposition() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v + .SetIsPrivateBuild(false) + .SetCompanyName("Acme")); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).IsNotPrivateBuild().And.HasCompanyName("Acme"); + } + + await That(Act).DoesNotThrow(); + } + } + } +} diff --git a/Tests/aweXpect.Testably.Tests/FileVersionInfo.IsNotSpecialBuild.Tests.cs b/Tests/aweXpect.Testably.Tests/FileVersionInfo.IsNotSpecialBuild.Tests.cs new file mode 100644 index 0000000..b62d5c9 --- /dev/null +++ b/Tests/aweXpect.Testably.Tests/FileVersionInfo.IsNotSpecialBuild.Tests.cs @@ -0,0 +1,71 @@ +using System.IO.Abstractions; +using Testably.Abstractions.Testing; + +namespace aweXpect.Testably.Tests; + +public sealed partial class FileVersionInfo +{ + public sealed class IsNotSpecialBuild + { + public sealed class Tests + { + [Fact] + public async Task WhenInfoIsNotSpecialBuild_ShouldSucceed() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v.SetIsSpecialBuild(false)); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).IsNotSpecialBuild(); + } + + await That(Act).DoesNotThrow(); + } + + [Fact] + public async Task WhenInfoIsSpecialBuild_ShouldFail() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v.SetIsSpecialBuild(true)); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).IsNotSpecialBuild(); + } + + await That(Act).ThrowsException() + .WithMessage(""" + Expected that info + is not special build, + but it was + """); + } + + [Fact] + public async Task ShouldSupportAndComposition() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v + .SetIsSpecialBuild(false) + .SetCompanyName("Acme")); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).IsNotSpecialBuild().And.HasCompanyName("Acme"); + } + + await That(Act).DoesNotThrow(); + } + } + } +} diff --git a/Tests/aweXpect.Testably.Tests/FileVersionInfo.IsPrivateBuild.Tests.cs b/Tests/aweXpect.Testably.Tests/FileVersionInfo.IsPrivateBuild.Tests.cs new file mode 100644 index 0000000..9fc0c87 --- /dev/null +++ b/Tests/aweXpect.Testably.Tests/FileVersionInfo.IsPrivateBuild.Tests.cs @@ -0,0 +1,71 @@ +using System.IO.Abstractions; +using Testably.Abstractions.Testing; + +namespace aweXpect.Testably.Tests; + +public sealed partial class FileVersionInfo +{ + public sealed class IsPrivateBuild + { + public sealed class Tests + { + [Fact] + public async Task WhenInfoIsPrivateBuild_ShouldSucceed() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v.SetIsPrivateBuild(true)); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).IsPrivateBuild(); + } + + await That(Act).DoesNotThrow(); + } + + [Fact] + public async Task WhenInfoIsNotPrivateBuild_ShouldFail() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v.SetIsPrivateBuild(false)); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).IsPrivateBuild(); + } + + await That(Act).ThrowsException() + .WithMessage(""" + Expected that info + is private build, + but it was not + """); + } + + [Fact] + public async Task ShouldSupportAndComposition() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v + .SetIsPrivateBuild(true) + .SetCompanyName("Acme")); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).IsPrivateBuild().And.HasCompanyName("Acme"); + } + + await That(Act).DoesNotThrow(); + } + } + } +} diff --git a/Tests/aweXpect.Testably.Tests/FileVersionInfo.IsSpecialBuild.Tests.cs b/Tests/aweXpect.Testably.Tests/FileVersionInfo.IsSpecialBuild.Tests.cs new file mode 100644 index 0000000..970f36c --- /dev/null +++ b/Tests/aweXpect.Testably.Tests/FileVersionInfo.IsSpecialBuild.Tests.cs @@ -0,0 +1,71 @@ +using System.IO.Abstractions; +using Testably.Abstractions.Testing; + +namespace aweXpect.Testably.Tests; + +public sealed partial class FileVersionInfo +{ + public sealed class IsSpecialBuild + { + public sealed class Tests + { + [Fact] + public async Task WhenInfoIsSpecialBuild_ShouldSucceed() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v.SetIsSpecialBuild(true)); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).IsSpecialBuild(); + } + + await That(Act).DoesNotThrow(); + } + + [Fact] + public async Task WhenInfoIsNotSpecialBuild_ShouldFail() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v.SetIsSpecialBuild(false)); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).IsSpecialBuild(); + } + + await That(Act).ThrowsException() + .WithMessage(""" + Expected that info + is special build, + but it was not + """); + } + + [Fact] + public async Task ShouldSupportAndComposition() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v + .SetIsSpecialBuild(true) + .SetCompanyName("Acme")); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).IsSpecialBuild().And.HasCompanyName("Acme"); + } + + await That(Act).DoesNotThrow(); + } + } + } +} From 29d1eeb935122fbc18e9c9680b4919fe6a81ca87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valentin=20Breu=C3=9F?= Date: Wed, 20 May 2026 18:16:30 +0200 Subject: [PATCH 2/2] Cleanup code and accept API changes --- .../Recorded/RecordedDirectoryInfoBucket.cs | 9 +- .../Recorded/RecordedDirectoryInfoInstance.cs | 277 +++++++++-------- .../Recorded/RecordedDirectoryMethods.cs | 180 +++++++---- .../Recorded/RecordedDriveInfoBucket.cs | 9 +- .../Recorded/RecordedDriveInfoInstance.cs | 4 +- .../Recorded/RecordedFileInfoBucket.cs | 9 +- .../Recorded/RecordedFileInfoInstance.cs | 260 ++++++++-------- .../Recorded/RecordedFileMethods.cs | 279 ++++++++++++------ .../Recorded/RecordedFileStreamBucket.cs | 18 +- .../Recorded/RecordedFileStreamInstance.cs | 130 ++++---- .../RecordedFileSystemWatcherBucket.cs | 9 +- .../RecordedFileSystemWatcherInstance.cs | 52 ++-- .../Recorded/RecordedFileVersionInfoBucket.cs | 3 +- .../RecordedFileVersionInfoInstance.cs | 4 +- .../Recorded/RecordedPathMethods.cs | 107 ++++--- .../Recorded/RecordedProperty.cs | 4 +- .../aweXpect.Testably/Results/DriveResult.cs | 2 +- .../Expected/aweXpect.Testably_net10.0.txt | 19 ++ .../Expected/aweXpect.Testably_net8.0.txt | 19 ++ .../aweXpect.Testably_netstandard2.0.txt | 19 ++ .../FileSystem.TriggeredNotification.Tests.cs | 1 - .../FileVersionInfo.HasComments.Tests.cs | 38 +-- .../FileVersionInfo.HasCompanyName.Tests.cs | 38 +-- .../FileVersionInfo.HasFileBuildPart.Tests.cs | 16 +- ...ileVersionInfo.HasFileDescription.Tests.cs | 38 +-- .../FileVersionInfo.HasFileMajorPart.Tests.cs | 16 +- .../FileVersionInfo.HasFileMinorPart.Tests.cs | 16 +- .../FileVersionInfo.HasFileName.Tests.cs | 8 +- ...ileVersionInfo.HasFilePrivatePart.Tests.cs | 16 +- .../FileVersionInfo.HasFileVersion.Tests.cs | 38 +-- .../FileVersionInfo.HasInternalName.Tests.cs | 38 +-- .../FileVersionInfo.HasLanguage.Tests.cs | 38 +-- ...FileVersionInfo.HasLegalCopyright.Tests.cs | 38 +-- ...ileVersionInfo.HasLegalTrademarks.Tests.cs | 38 +-- ...leVersionInfo.HasOriginalFilename.Tests.cs | 38 +-- .../FileVersionInfo.HasPrivateBuild.Tests.cs | 38 +-- ...leVersionInfo.HasProductBuildPart.Tests.cs | 16 +- ...leVersionInfo.HasProductMajorPart.Tests.cs | 16 +- ...leVersionInfo.HasProductMinorPart.Tests.cs | 16 +- .../FileVersionInfo.HasProductName.Tests.cs | 38 +-- ...VersionInfo.HasProductPrivatePart.Tests.cs | 16 +- ...FileVersionInfo.HasProductVersion.Tests.cs | 38 +-- .../FileVersionInfo.HasSpecialBuild.Tests.cs | 38 +-- .../FileVersionInfo.IsDebug.Tests.cs | 50 ++-- ...FileVersionInfo.IsNotPrivateBuild.Tests.cs | 34 +-- ...FileVersionInfo.IsNotSpecialBuild.Tests.cs | 34 +-- .../FileVersionInfo.IsPatched.Tests.cs | 50 ++-- .../FileVersionInfo.IsPreRelease.Tests.cs | 50 ++-- .../FileVersionInfo.IsPrivateBuild.Tests.cs | 16 +- .../FileVersionInfo.IsSpecialBuild.Tests.cs | 16 +- 50 files changed, 1295 insertions(+), 999 deletions(-) diff --git a/Source/aweXpect.Testably/Recorded/RecordedDirectoryInfoBucket.cs b/Source/aweXpect.Testably/Recorded/RecordedDirectoryInfoBucket.cs index 9050472..9490a4a 100644 --- a/Source/aweXpect.Testably/Recorded/RecordedDirectoryInfoBucket.cs +++ b/Source/aweXpect.Testably/Recorded/RecordedDirectoryInfoBucket.cs @@ -1,4 +1,5 @@ using System; +using System.IO; using System.IO.Abstractions; using System.Runtime.CompilerServices; using aweXpect.Core; @@ -35,7 +36,8 @@ public RecordedDirectoryInfoInstance this[string path] /// public RecordedMethodCallResult New( Func? path = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null) => Build(nameof(IDirectoryInfoFactory.New), ParameterMatcher.From("path", path, pathExpression)); @@ -43,8 +45,9 @@ public RecordedMethodCallResult New( /// Recorded calls to . /// public RecordedMethodCallResult Wrap( - Func? directoryInfo = null, - [CallerArgumentExpression(nameof(directoryInfo))] string? directoryInfoExpression = null) + Func? directoryInfo = null, + [CallerArgumentExpression(nameof(directoryInfo))] + string? directoryInfoExpression = null) => Build(nameof(IDirectoryInfoFactory.Wrap), ParameterMatcher.From("directoryInfo", directoryInfo, directoryInfoExpression)); diff --git a/Source/aweXpect.Testably/Recorded/RecordedDirectoryInfoInstance.cs b/Source/aweXpect.Testably/Recorded/RecordedDirectoryInfoInstance.cs index 5150e5b..32de3ba 100644 --- a/Source/aweXpect.Testably/Recorded/RecordedDirectoryInfoInstance.cs +++ b/Source/aweXpect.Testably/Recorded/RecordedDirectoryInfoInstance.cs @@ -15,9 +15,9 @@ namespace aweXpect.Testably.Recorded; /// public sealed class RecordedDirectoryInfoInstance { - private readonly IThat _subject; - private readonly string _path; private readonly string _bucketDescription; + private readonly string _path; + private readonly IThat _subject; internal RecordedDirectoryInfoInstance(IThat subject, string path) { @@ -26,6 +26,104 @@ internal RecordedDirectoryInfoInstance(IThat subject, str _bucketDescription = $"DirectoryInfo[\"{path}\"]"; } + /// + /// Recorded accesses to . + /// + public RecordedProperty Attributes + => Property(nameof(IFileSystemInfo.Attributes)); + + /// + /// Recorded accesses to . + /// + public RecordedProperty CreationTime + => Property(nameof(IFileSystemInfo.CreationTime)); + + /// + /// Recorded accesses to . + /// + public RecordedProperty CreationTimeUtc + => Property(nameof(IFileSystemInfo.CreationTimeUtc)); + + /// + /// Recorded accesses to . + /// + public RecordedProperty Exists + => Property(nameof(IFileSystemInfo.Exists)); + + /// + /// Recorded accesses to . + /// + public RecordedProperty Extension + => Property(nameof(IFileSystemInfo.Extension)); + + /// + /// Recorded accesses to . + /// + public RecordedProperty FullName + => Property(nameof(IFileSystemInfo.FullName)); + + /// + /// Recorded accesses to . + /// + public RecordedProperty LastAccessTime + => Property(nameof(IFileSystemInfo.LastAccessTime)); + + /// + /// Recorded accesses to . + /// + public RecordedProperty LastAccessTimeUtc + => Property(nameof(IFileSystemInfo.LastAccessTimeUtc)); + + /// + /// Recorded accesses to . + /// + public RecordedProperty LastWriteTime + => Property(nameof(IFileSystemInfo.LastWriteTime)); + + /// + /// Recorded accesses to . + /// + public RecordedProperty LastWriteTimeUtc + => Property(nameof(IFileSystemInfo.LastWriteTimeUtc)); + + /// + /// Recorded accesses to IFileSystemInfo.LinkTarget. + /// + public RecordedProperty LinkTarget +#if NET6_0_OR_GREATER + => Property(nameof(IFileSystemInfo.LinkTarget)); +#else + => Property("LinkTarget"); +#endif + + /// + /// Recorded accesses to . + /// + public RecordedProperty Name + => Property(nameof(IFileSystemInfo.Name)); + + /// + /// Recorded accesses to . + /// + public RecordedProperty Parent + => Property(nameof(IDirectoryInfo.Parent)); + + /// + /// Recorded accesses to . + /// + public RecordedProperty Root + => Property(nameof(IDirectoryInfo.Root)); + + /// + /// Recorded accesses to IFileSystemInfo.UnixFileMode. + /// + public RecordedProperty UnixFileMode +#if NET7_0_OR_GREATER + => Property(nameof(IFileSystemInfo.UnixFileMode)); +#else + => Property("UnixFileMode"); +#endif + /// /// Recorded calls to . /// @@ -37,7 +135,8 @@ public RecordedMethodCallResult Create() /// public RecordedMethodCallResult CreateAsSymbolicLink( Func? pathToTarget = null, - [CallerArgumentExpression(nameof(pathToTarget))] string? pathToTargetExpression = null) + [CallerArgumentExpression(nameof(pathToTarget))] + string? pathToTargetExpression = null) => Build("CreateAsSymbolicLink", ParameterMatcher.From("pathToTarget", pathToTarget, pathToTargetExpression)); @@ -46,7 +145,8 @@ public RecordedMethodCallResult CreateAsSymbolicLink( /// public RecordedMethodCallResult CreateSubdirectory( Func? path = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null) => Build(nameof(IDirectoryInfo.CreateSubdirectory), ParameterMatcher.From("path", path, pathExpression)); @@ -55,7 +155,8 @@ public RecordedMethodCallResult CreateSubdirectory( /// public RecordedMethodCallResult Delete( Func? recursive = null, - [CallerArgumentExpression(nameof(recursive))] string? recursiveExpression = null) + [CallerArgumentExpression(nameof(recursive))] + string? recursiveExpression = null) => Build(nameof(IFileSystemInfo.Delete), ParameterMatcher.From("recursive", recursive, recursiveExpression)); @@ -72,19 +173,21 @@ public RecordedMethodCallResult EnumerateDirectories( #if NET6_0_OR_GREATER Func? enumerationOptions = null, #endif - [CallerArgumentExpression(nameof(searchPattern))] string? searchPatternExpression = null, - [CallerArgumentExpression(nameof(searchOption))] string? searchOptionExpression = null + [CallerArgumentExpression(nameof(searchPattern))] + string? searchPatternExpression = null, + [CallerArgumentExpression(nameof(searchOption))] + string? searchOptionExpression = null #if NET6_0_OR_GREATER , [CallerArgumentExpression(nameof(enumerationOptions))] string? enumerationOptionsExpression = null #endif - ) + ) => Build(nameof(IDirectoryInfo.EnumerateDirectories), ParameterMatcher.From("searchPattern", searchPattern, searchPatternExpression), SearchOrEnumerationMatcher(searchOption, searchOptionExpression #if NET6_0_OR_GREATER , enumerationOptions, enumerationOptionsExpression #endif - )); + )); /// /// Recorded calls to and overloads. @@ -99,19 +202,21 @@ public RecordedMethodCallResult EnumerateFiles( #if NET6_0_OR_GREATER Func? enumerationOptions = null, #endif - [CallerArgumentExpression(nameof(searchPattern))] string? searchPatternExpression = null, - [CallerArgumentExpression(nameof(searchOption))] string? searchOptionExpression = null + [CallerArgumentExpression(nameof(searchPattern))] + string? searchPatternExpression = null, + [CallerArgumentExpression(nameof(searchOption))] + string? searchOptionExpression = null #if NET6_0_OR_GREATER , [CallerArgumentExpression(nameof(enumerationOptions))] string? enumerationOptionsExpression = null #endif - ) + ) => Build(nameof(IDirectoryInfo.EnumerateFiles), ParameterMatcher.From("searchPattern", searchPattern, searchPatternExpression), SearchOrEnumerationMatcher(searchOption, searchOptionExpression #if NET6_0_OR_GREATER , enumerationOptions, enumerationOptionsExpression #endif - )); + )); /// /// Recorded calls to and overloads. @@ -126,19 +231,21 @@ public RecordedMethodCallResult EnumerateFileSystemInfos( #if NET6_0_OR_GREATER Func? enumerationOptions = null, #endif - [CallerArgumentExpression(nameof(searchPattern))] string? searchPatternExpression = null, - [CallerArgumentExpression(nameof(searchOption))] string? searchOptionExpression = null + [CallerArgumentExpression(nameof(searchPattern))] + string? searchPatternExpression = null, + [CallerArgumentExpression(nameof(searchOption))] + string? searchOptionExpression = null #if NET6_0_OR_GREATER , [CallerArgumentExpression(nameof(enumerationOptions))] string? enumerationOptionsExpression = null #endif - ) + ) => Build(nameof(IDirectoryInfo.EnumerateFileSystemInfos), ParameterMatcher.From("searchPattern", searchPattern, searchPatternExpression), SearchOrEnumerationMatcher(searchOption, searchOptionExpression #if NET6_0_OR_GREATER , enumerationOptions, enumerationOptionsExpression #endif - )); + )); /// /// Recorded calls to and overloads. @@ -153,19 +260,21 @@ public RecordedMethodCallResult GetDirectories( #if NET6_0_OR_GREATER Func? enumerationOptions = null, #endif - [CallerArgumentExpression(nameof(searchPattern))] string? searchPatternExpression = null, - [CallerArgumentExpression(nameof(searchOption))] string? searchOptionExpression = null + [CallerArgumentExpression(nameof(searchPattern))] + string? searchPatternExpression = null, + [CallerArgumentExpression(nameof(searchOption))] + string? searchOptionExpression = null #if NET6_0_OR_GREATER , [CallerArgumentExpression(nameof(enumerationOptions))] string? enumerationOptionsExpression = null #endif - ) + ) => Build(nameof(IDirectoryInfo.GetDirectories), ParameterMatcher.From("searchPattern", searchPattern, searchPatternExpression), SearchOrEnumerationMatcher(searchOption, searchOptionExpression #if NET6_0_OR_GREATER , enumerationOptions, enumerationOptionsExpression #endif - )); + )); /// /// Recorded calls to and overloads. @@ -180,19 +289,21 @@ public RecordedMethodCallResult GetFiles( #if NET6_0_OR_GREATER Func? enumerationOptions = null, #endif - [CallerArgumentExpression(nameof(searchPattern))] string? searchPatternExpression = null, - [CallerArgumentExpression(nameof(searchOption))] string? searchOptionExpression = null + [CallerArgumentExpression(nameof(searchPattern))] + string? searchPatternExpression = null, + [CallerArgumentExpression(nameof(searchOption))] + string? searchOptionExpression = null #if NET6_0_OR_GREATER , [CallerArgumentExpression(nameof(enumerationOptions))] string? enumerationOptionsExpression = null #endif - ) + ) => Build(nameof(IDirectoryInfo.GetFiles), ParameterMatcher.From("searchPattern", searchPattern, searchPatternExpression), SearchOrEnumerationMatcher(searchOption, searchOptionExpression #if NET6_0_OR_GREATER , enumerationOptions, enumerationOptionsExpression #endif - )); + )); /// /// Recorded calls to and overloads. @@ -207,26 +318,29 @@ public RecordedMethodCallResult GetFileSystemInfos( #if NET6_0_OR_GREATER Func? enumerationOptions = null, #endif - [CallerArgumentExpression(nameof(searchPattern))] string? searchPatternExpression = null, - [CallerArgumentExpression(nameof(searchOption))] string? searchOptionExpression = null + [CallerArgumentExpression(nameof(searchPattern))] + string? searchPatternExpression = null, + [CallerArgumentExpression(nameof(searchOption))] + string? searchOptionExpression = null #if NET6_0_OR_GREATER , [CallerArgumentExpression(nameof(enumerationOptions))] string? enumerationOptionsExpression = null #endif - ) + ) => Build(nameof(IDirectoryInfo.GetFileSystemInfos), ParameterMatcher.From("searchPattern", searchPattern, searchPatternExpression), SearchOrEnumerationMatcher(searchOption, searchOptionExpression #if NET6_0_OR_GREATER , enumerationOptions, enumerationOptionsExpression #endif - )); + )); /// /// Recorded calls to . /// public RecordedMethodCallResult MoveTo( Func? destDirName = null, - [CallerArgumentExpression(nameof(destDirName))] string? destDirNameExpression = null) + [CallerArgumentExpression(nameof(destDirName))] + string? destDirNameExpression = null) => Build(nameof(IDirectoryInfo.MoveTo), ParameterMatcher.From("destDirName", destDirName, destDirNameExpression)); @@ -241,108 +355,11 @@ public RecordedMethodCallResult Refresh() /// public RecordedMethodCallResult ResolveLinkTarget( Func? returnFinalTarget = null, - [CallerArgumentExpression(nameof(returnFinalTarget))] string? returnFinalTargetExpression = null) + [CallerArgumentExpression(nameof(returnFinalTarget))] + string? returnFinalTargetExpression = null) => Build("ResolveLinkTarget", ParameterMatcher.From("returnFinalTarget", returnFinalTarget, returnFinalTargetExpression)); - /// - /// Recorded accesses to . - /// - public RecordedProperty Attributes - => Property(nameof(IFileSystemInfo.Attributes)); - - /// - /// Recorded accesses to . - /// - public RecordedProperty CreationTime - => Property(nameof(IFileSystemInfo.CreationTime)); - - /// - /// Recorded accesses to . - /// - public RecordedProperty CreationTimeUtc - => Property(nameof(IFileSystemInfo.CreationTimeUtc)); - - /// - /// Recorded accesses to . - /// - public RecordedProperty Exists - => Property(nameof(IFileSystemInfo.Exists)); - - /// - /// Recorded accesses to . - /// - public RecordedProperty Extension - => Property(nameof(IFileSystemInfo.Extension)); - - /// - /// Recorded accesses to . - /// - public RecordedProperty FullName - => Property(nameof(IFileSystemInfo.FullName)); - - /// - /// Recorded accesses to . - /// - public RecordedProperty LastAccessTime - => Property(nameof(IFileSystemInfo.LastAccessTime)); - - /// - /// Recorded accesses to . - /// - public RecordedProperty LastAccessTimeUtc - => Property(nameof(IFileSystemInfo.LastAccessTimeUtc)); - - /// - /// Recorded accesses to . - /// - public RecordedProperty LastWriteTime - => Property(nameof(IFileSystemInfo.LastWriteTime)); - - /// - /// Recorded accesses to . - /// - public RecordedProperty LastWriteTimeUtc - => Property(nameof(IFileSystemInfo.LastWriteTimeUtc)); - - /// - /// Recorded accesses to IFileSystemInfo.LinkTarget. - /// - public RecordedProperty LinkTarget -#if NET6_0_OR_GREATER - => Property(nameof(IFileSystemInfo.LinkTarget)); -#else - => Property("LinkTarget"); -#endif - - /// - /// Recorded accesses to . - /// - public RecordedProperty Name - => Property(nameof(IFileSystemInfo.Name)); - - /// - /// Recorded accesses to . - /// - public RecordedProperty Parent - => Property(nameof(IDirectoryInfo.Parent)); - - /// - /// Recorded accesses to . - /// - public RecordedProperty Root - => Property(nameof(IDirectoryInfo.Root)); - - /// - /// Recorded accesses to IFileSystemInfo.UnixFileMode. - /// - public RecordedProperty UnixFileMode -#if NET7_0_OR_GREATER - => Property(nameof(IFileSystemInfo.UnixFileMode)); -#else - => Property("UnixFileMode"); -#endif - private RecordedProperty Property(string propertyName) { string path = _path; @@ -356,7 +373,7 @@ private static ParameterMatcher SearchOrEnumerationMatcher( , Func? enumerationOptions, string? enumerationOptionsExpression #endif - ) + ) { #if NET6_0_OR_GREATER if (enumerationOptions is not null) diff --git a/Source/aweXpect.Testably/Recorded/RecordedDirectoryMethods.cs b/Source/aweXpect.Testably/Recorded/RecordedDirectoryMethods.cs index 848118f..232f72b 100644 --- a/Source/aweXpect.Testably/Recorded/RecordedDirectoryMethods.cs +++ b/Source/aweXpect.Testably/Recorded/RecordedDirectoryMethods.cs @@ -30,24 +30,27 @@ public RecordedMethodCallResult CreateDirectory( #if NET7_0_OR_GREATER Func? unixCreateMode = null, #endif - [CallerArgumentExpression(nameof(path))] string? pathExpression = null + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null #if NET7_0_OR_GREATER , [CallerArgumentExpression(nameof(unixCreateMode))] string? unixCreateModeExpression = null #endif - ) + ) => Build(nameof(IDirectory.CreateDirectory), ParameterMatcher.From("path", path, pathExpression) #if NET7_0_OR_GREATER , ParameterMatcher.From("unixCreateMode", unixCreateMode, unixCreateModeExpression) #endif - ); + ); /// Recorded calls to IDirectory.CreateSymbolicLink(string, string). public RecordedMethodCallResult CreateSymbolicLink( Func? path = null, Func? pathToTarget = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null, - [CallerArgumentExpression(nameof(pathToTarget))] string? pathToTargetExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null, + [CallerArgumentExpression(nameof(pathToTarget))] + string? pathToTargetExpression = null) => Build("CreateSymbolicLink", ParameterMatcher.From("path", path, pathExpression), ParameterMatcher.From("pathToTarget", pathToTarget, pathToTargetExpression)); @@ -55,7 +58,8 @@ public RecordedMethodCallResult CreateSymbolicLink( /// Recorded calls to IDirectory.CreateTempSubdirectory(string?). public RecordedMethodCallResult CreateTempSubdirectory( Func? prefix = null, - [CallerArgumentExpression(nameof(prefix))] string? prefixExpression = null) + [CallerArgumentExpression(nameof(prefix))] + string? prefixExpression = null) => Build("CreateTempSubdirectory", ParameterMatcher.From("prefix", prefix, prefixExpression)); @@ -63,8 +67,10 @@ public RecordedMethodCallResult CreateTempSubdirectory( public RecordedMethodCallResult Delete( Func? path = null, Func? recursive = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null, - [CallerArgumentExpression(nameof(recursive))] string? recursiveExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null, + [CallerArgumentExpression(nameof(recursive))] + string? recursiveExpression = null) => Build(nameof(IDirectory.Delete), ParameterMatcher.From("path", path, pathExpression), ParameterMatcher.From("recursive", recursive, recursiveExpression)); @@ -82,13 +88,16 @@ public RecordedMethodCallResult EnumerateDirectories( #if NET6_0_OR_GREATER Func? enumerationOptions = null, #endif - [CallerArgumentExpression(nameof(path))] string? pathExpression = null, - [CallerArgumentExpression(nameof(searchPattern))] string? searchPatternExpression = null, - [CallerArgumentExpression(nameof(searchOption))] string? searchOptionExpression = null + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null, + [CallerArgumentExpression(nameof(searchPattern))] + string? searchPatternExpression = null, + [CallerArgumentExpression(nameof(searchOption))] + string? searchOptionExpression = null #if NET6_0_OR_GREATER , [CallerArgumentExpression(nameof(enumerationOptions))] string? enumerationOptionsExpression = null #endif - ) + ) => Build(nameof(IDirectory.EnumerateDirectories), ParameterMatcher.From("path", path, pathExpression), ParameterMatcher.From("searchPattern", searchPattern, searchPatternExpression), @@ -96,7 +105,7 @@ public RecordedMethodCallResult EnumerateDirectories( #if NET6_0_OR_GREATER , enumerationOptions, enumerationOptionsExpression #endif - )); + )); #pragma warning restore S107 /// Recorded calls to and overloads. @@ -112,13 +121,16 @@ public RecordedMethodCallResult EnumerateFiles( #if NET6_0_OR_GREATER Func? enumerationOptions = null, #endif - [CallerArgumentExpression(nameof(path))] string? pathExpression = null, - [CallerArgumentExpression(nameof(searchPattern))] string? searchPatternExpression = null, - [CallerArgumentExpression(nameof(searchOption))] string? searchOptionExpression = null + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null, + [CallerArgumentExpression(nameof(searchPattern))] + string? searchPatternExpression = null, + [CallerArgumentExpression(nameof(searchOption))] + string? searchOptionExpression = null #if NET6_0_OR_GREATER , [CallerArgumentExpression(nameof(enumerationOptions))] string? enumerationOptionsExpression = null #endif - ) + ) => Build(nameof(IDirectory.EnumerateFiles), ParameterMatcher.From("path", path, pathExpression), ParameterMatcher.From("searchPattern", searchPattern, searchPatternExpression), @@ -126,7 +138,7 @@ public RecordedMethodCallResult EnumerateFiles( #if NET6_0_OR_GREATER , enumerationOptions, enumerationOptionsExpression #endif - )); + )); #pragma warning restore S107 /// Recorded calls to and overloads. @@ -142,13 +154,16 @@ public RecordedMethodCallResult EnumerateFileSystemEntries( #if NET6_0_OR_GREATER Func? enumerationOptions = null, #endif - [CallerArgumentExpression(nameof(path))] string? pathExpression = null, - [CallerArgumentExpression(nameof(searchPattern))] string? searchPatternExpression = null, - [CallerArgumentExpression(nameof(searchOption))] string? searchOptionExpression = null + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null, + [CallerArgumentExpression(nameof(searchPattern))] + string? searchPatternExpression = null, + [CallerArgumentExpression(nameof(searchOption))] + string? searchOptionExpression = null #if NET6_0_OR_GREATER , [CallerArgumentExpression(nameof(enumerationOptions))] string? enumerationOptionsExpression = null #endif - ) + ) => Build(nameof(IDirectory.EnumerateFileSystemEntries), ParameterMatcher.From("path", path, pathExpression), ParameterMatcher.From("searchPattern", searchPattern, searchPatternExpression), @@ -156,27 +171,30 @@ public RecordedMethodCallResult EnumerateFileSystemEntries( #if NET6_0_OR_GREATER , enumerationOptions, enumerationOptionsExpression #endif - )); + )); #pragma warning restore S107 /// Recorded calls to . public RecordedMethodCallResult Exists( Func? path = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null) => Build(nameof(IDirectory.Exists), ParameterMatcher.From("path", path, pathExpression)); /// Recorded calls to . public RecordedMethodCallResult GetCreationTime( Func? path = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null) => Build(nameof(IDirectory.GetCreationTime), ParameterMatcher.From("path", path, pathExpression)); /// Recorded calls to . public RecordedMethodCallResult GetCreationTimeUtc( Func? path = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null) => Build(nameof(IDirectory.GetCreationTimeUtc), ParameterMatcher.From("path", path, pathExpression)); @@ -197,13 +215,16 @@ public RecordedMethodCallResult GetDirectories( #if NET6_0_OR_GREATER Func? enumerationOptions = null, #endif - [CallerArgumentExpression(nameof(path))] string? pathExpression = null, - [CallerArgumentExpression(nameof(searchPattern))] string? searchPatternExpression = null, - [CallerArgumentExpression(nameof(searchOption))] string? searchOptionExpression = null + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null, + [CallerArgumentExpression(nameof(searchPattern))] + string? searchPatternExpression = null, + [CallerArgumentExpression(nameof(searchOption))] + string? searchOptionExpression = null #if NET6_0_OR_GREATER , [CallerArgumentExpression(nameof(enumerationOptions))] string? enumerationOptionsExpression = null #endif - ) + ) => Build(nameof(IDirectory.GetDirectories), ParameterMatcher.From("path", path, pathExpression), ParameterMatcher.From("searchPattern", searchPattern, searchPatternExpression), @@ -211,13 +232,14 @@ public RecordedMethodCallResult GetDirectories( #if NET6_0_OR_GREATER , enumerationOptions, enumerationOptionsExpression #endif - )); + )); #pragma warning restore S107 /// Recorded calls to . public RecordedMethodCallResult GetDirectoryRoot( Func? path = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null) => Build(nameof(IDirectory.GetDirectoryRoot), ParameterMatcher.From("path", path, pathExpression)); @@ -234,13 +256,16 @@ public RecordedMethodCallResult GetFiles( #if NET6_0_OR_GREATER Func? enumerationOptions = null, #endif - [CallerArgumentExpression(nameof(path))] string? pathExpression = null, - [CallerArgumentExpression(nameof(searchPattern))] string? searchPatternExpression = null, - [CallerArgumentExpression(nameof(searchOption))] string? searchOptionExpression = null + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null, + [CallerArgumentExpression(nameof(searchPattern))] + string? searchPatternExpression = null, + [CallerArgumentExpression(nameof(searchOption))] + string? searchOptionExpression = null #if NET6_0_OR_GREATER , [CallerArgumentExpression(nameof(enumerationOptions))] string? enumerationOptionsExpression = null #endif - ) + ) => Build(nameof(IDirectory.GetFiles), ParameterMatcher.From("path", path, pathExpression), ParameterMatcher.From("searchPattern", searchPattern, searchPatternExpression), @@ -248,7 +273,7 @@ public RecordedMethodCallResult GetFiles( #if NET6_0_OR_GREATER , enumerationOptions, enumerationOptionsExpression #endif - )); + )); #pragma warning restore S107 /// Recorded calls to and overloads. @@ -264,13 +289,16 @@ public RecordedMethodCallResult GetFileSystemEntries( #if NET6_0_OR_GREATER Func? enumerationOptions = null, #endif - [CallerArgumentExpression(nameof(path))] string? pathExpression = null, - [CallerArgumentExpression(nameof(searchPattern))] string? searchPatternExpression = null, - [CallerArgumentExpression(nameof(searchOption))] string? searchOptionExpression = null + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null, + [CallerArgumentExpression(nameof(searchPattern))] + string? searchPatternExpression = null, + [CallerArgumentExpression(nameof(searchOption))] + string? searchOptionExpression = null #if NET6_0_OR_GREATER , [CallerArgumentExpression(nameof(enumerationOptions))] string? enumerationOptionsExpression = null #endif - ) + ) => Build(nameof(IDirectory.GetFileSystemEntries), ParameterMatcher.From("path", path, pathExpression), ParameterMatcher.From("searchPattern", searchPattern, searchPatternExpression), @@ -278,34 +306,38 @@ public RecordedMethodCallResult GetFileSystemEntries( #if NET6_0_OR_GREATER , enumerationOptions, enumerationOptionsExpression #endif - )); + )); #pragma warning restore S107 /// Recorded calls to . public RecordedMethodCallResult GetLastAccessTime( Func? path = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null) => Build(nameof(IDirectory.GetLastAccessTime), ParameterMatcher.From("path", path, pathExpression)); /// Recorded calls to . public RecordedMethodCallResult GetLastAccessTimeUtc( Func? path = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null) => Build(nameof(IDirectory.GetLastAccessTimeUtc), ParameterMatcher.From("path", path, pathExpression)); /// Recorded calls to . public RecordedMethodCallResult GetLastWriteTime( Func? path = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null) => Build(nameof(IDirectory.GetLastWriteTime), ParameterMatcher.From("path", path, pathExpression)); /// Recorded calls to . public RecordedMethodCallResult GetLastWriteTimeUtc( Func? path = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null) => Build(nameof(IDirectory.GetLastWriteTimeUtc), ParameterMatcher.From("path", path, pathExpression)); @@ -316,7 +348,8 @@ public RecordedMethodCallResult GetLogicalDrives() /// Recorded calls to . public RecordedMethodCallResult GetParent( Func? path = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null) => Build(nameof(IDirectory.GetParent), ParameterMatcher.From("path", path, pathExpression)); @@ -324,8 +357,10 @@ public RecordedMethodCallResult GetParent( public RecordedMethodCallResult Move( Func? sourceDirName = null, Func? destDirName = null, - [CallerArgumentExpression(nameof(sourceDirName))] string? sourceDirNameExpression = null, - [CallerArgumentExpression(nameof(destDirName))] string? destDirNameExpression = null) + [CallerArgumentExpression(nameof(sourceDirName))] + string? sourceDirNameExpression = null, + [CallerArgumentExpression(nameof(destDirName))] + string? destDirNameExpression = null) => Build(nameof(IDirectory.Move), ParameterMatcher.From("sourceDirName", sourceDirName, sourceDirNameExpression), ParameterMatcher.From("destDirName", destDirName, destDirNameExpression)); @@ -334,8 +369,10 @@ public RecordedMethodCallResult Move( public RecordedMethodCallResult ResolveLinkTarget( Func? linkPath = null, Func? returnFinalTarget = null, - [CallerArgumentExpression(nameof(linkPath))] string? linkPathExpression = null, - [CallerArgumentExpression(nameof(returnFinalTarget))] string? returnFinalTargetExpression = null) + [CallerArgumentExpression(nameof(linkPath))] + string? linkPathExpression = null, + [CallerArgumentExpression(nameof(returnFinalTarget))] + string? returnFinalTargetExpression = null) => Build("ResolveLinkTarget", ParameterMatcher.From("linkPath", linkPath, linkPathExpression), ParameterMatcher.From("returnFinalTarget", returnFinalTarget, returnFinalTargetExpression)); @@ -344,8 +381,10 @@ public RecordedMethodCallResult ResolveLinkTarget( public RecordedMethodCallResult SetCreationTime( Func? path = null, Func? creationTime = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null, - [CallerArgumentExpression(nameof(creationTime))] string? creationTimeExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null, + [CallerArgumentExpression(nameof(creationTime))] + string? creationTimeExpression = null) => Build(nameof(IDirectory.SetCreationTime), ParameterMatcher.From("path", path, pathExpression), ParameterMatcher.From("creationTime", creationTime, creationTimeExpression)); @@ -354,8 +393,10 @@ public RecordedMethodCallResult SetCreationTime( public RecordedMethodCallResult SetCreationTimeUtc( Func? path = null, Func? creationTimeUtc = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null, - [CallerArgumentExpression(nameof(creationTimeUtc))] string? creationTimeUtcExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null, + [CallerArgumentExpression(nameof(creationTimeUtc))] + string? creationTimeUtcExpression = null) => Build(nameof(IDirectory.SetCreationTimeUtc), ParameterMatcher.From("path", path, pathExpression), ParameterMatcher.From("creationTimeUtc", creationTimeUtc, creationTimeUtcExpression)); @@ -363,7 +404,8 @@ public RecordedMethodCallResult SetCreationTimeUtc( /// Recorded calls to . public RecordedMethodCallResult SetCurrentDirectory( Func? path = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null) => Build(nameof(IDirectory.SetCurrentDirectory), ParameterMatcher.From("path", path, pathExpression)); @@ -371,8 +413,10 @@ public RecordedMethodCallResult SetCurrentDirectory( public RecordedMethodCallResult SetLastAccessTime( Func? path = null, Func? lastAccessTime = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null, - [CallerArgumentExpression(nameof(lastAccessTime))] string? lastAccessTimeExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null, + [CallerArgumentExpression(nameof(lastAccessTime))] + string? lastAccessTimeExpression = null) => Build(nameof(IDirectory.SetLastAccessTime), ParameterMatcher.From("path", path, pathExpression), ParameterMatcher.From("lastAccessTime", lastAccessTime, lastAccessTimeExpression)); @@ -381,8 +425,10 @@ public RecordedMethodCallResult SetLastAccessTime( public RecordedMethodCallResult SetLastAccessTimeUtc( Func? path = null, Func? lastAccessTimeUtc = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null, - [CallerArgumentExpression(nameof(lastAccessTimeUtc))] string? lastAccessTimeUtcExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null, + [CallerArgumentExpression(nameof(lastAccessTimeUtc))] + string? lastAccessTimeUtcExpression = null) => Build(nameof(IDirectory.SetLastAccessTimeUtc), ParameterMatcher.From("path", path, pathExpression), ParameterMatcher.From("lastAccessTimeUtc", lastAccessTimeUtc, lastAccessTimeUtcExpression)); @@ -391,8 +437,10 @@ public RecordedMethodCallResult SetLastAccessTimeUtc( public RecordedMethodCallResult SetLastWriteTime( Func? path = null, Func? lastWriteTime = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null, - [CallerArgumentExpression(nameof(lastWriteTime))] string? lastWriteTimeExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null, + [CallerArgumentExpression(nameof(lastWriteTime))] + string? lastWriteTimeExpression = null) => Build(nameof(IDirectory.SetLastWriteTime), ParameterMatcher.From("path", path, pathExpression), ParameterMatcher.From("lastWriteTime", lastWriteTime, lastWriteTimeExpression)); @@ -401,8 +449,10 @@ public RecordedMethodCallResult SetLastWriteTime( public RecordedMethodCallResult SetLastWriteTimeUtc( Func? path = null, Func? lastWriteTimeUtc = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null, - [CallerArgumentExpression(nameof(lastWriteTimeUtc))] string? lastWriteTimeUtcExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null, + [CallerArgumentExpression(nameof(lastWriteTimeUtc))] + string? lastWriteTimeUtcExpression = null) => Build(nameof(IDirectory.SetLastWriteTimeUtc), ParameterMatcher.From("path", path, pathExpression), ParameterMatcher.From("lastWriteTimeUtc", lastWriteTimeUtc, lastWriteTimeUtcExpression)); @@ -414,7 +464,7 @@ private static ParameterMatcher SearchOrEnumerationMatcher( , Func? enumerationOptions, string? enumerationOptionsExpression #endif - ) + ) { #if NET6_0_OR_GREATER if (enumerationOptions is not null) diff --git a/Source/aweXpect.Testably/Recorded/RecordedDriveInfoBucket.cs b/Source/aweXpect.Testably/Recorded/RecordedDriveInfoBucket.cs index 9d6edf6..37249c8 100644 --- a/Source/aweXpect.Testably/Recorded/RecordedDriveInfoBucket.cs +++ b/Source/aweXpect.Testably/Recorded/RecordedDriveInfoBucket.cs @@ -1,4 +1,5 @@ using System; +using System.IO; using System.IO.Abstractions; using System.Runtime.CompilerServices; using aweXpect.Core; @@ -41,7 +42,8 @@ public RecordedMethodCallResult GetDrives() /// public RecordedMethodCallResult New( Func? driveName = null, - [CallerArgumentExpression(nameof(driveName))] string? driveNameExpression = null) + [CallerArgumentExpression(nameof(driveName))] + string? driveNameExpression = null) => Build(nameof(IDriveInfoFactory.New), ParameterMatcher.From("driveName", driveName, driveNameExpression)); @@ -49,8 +51,9 @@ public RecordedMethodCallResult New( /// Recorded calls to . /// public RecordedMethodCallResult Wrap( - Func? driveInfo = null, - [CallerArgumentExpression(nameof(driveInfo))] string? driveInfoExpression = null) + Func? driveInfo = null, + [CallerArgumentExpression(nameof(driveInfo))] + string? driveInfoExpression = null) => Build(nameof(IDriveInfoFactory.Wrap), ParameterMatcher.From("driveInfo", driveInfo, driveInfoExpression)); diff --git a/Source/aweXpect.Testably/Recorded/RecordedDriveInfoInstance.cs b/Source/aweXpect.Testably/Recorded/RecordedDriveInfoInstance.cs index af8b92a..aefa77d 100644 --- a/Source/aweXpect.Testably/Recorded/RecordedDriveInfoInstance.cs +++ b/Source/aweXpect.Testably/Recorded/RecordedDriveInfoInstance.cs @@ -10,9 +10,9 @@ namespace aweXpect.Testably.Recorded; /// public sealed class RecordedDriveInfoInstance { - private readonly IThat _subject; - private readonly string _driveName; private readonly string _bucketDescription; + private readonly string _driveName; + private readonly IThat _subject; internal RecordedDriveInfoInstance(IThat subject, string driveName) { diff --git a/Source/aweXpect.Testably/Recorded/RecordedFileInfoBucket.cs b/Source/aweXpect.Testably/Recorded/RecordedFileInfoBucket.cs index 67cf795..ca64a40 100644 --- a/Source/aweXpect.Testably/Recorded/RecordedFileInfoBucket.cs +++ b/Source/aweXpect.Testably/Recorded/RecordedFileInfoBucket.cs @@ -1,4 +1,5 @@ using System; +using System.IO; using System.IO.Abstractions; using System.Runtime.CompilerServices; using aweXpect.Core; @@ -35,7 +36,8 @@ public RecordedFileInfoInstance this[string path] /// public RecordedMethodCallResult New( Func? fileName = null, - [CallerArgumentExpression(nameof(fileName))] string? fileNameExpression = null) + [CallerArgumentExpression(nameof(fileName))] + string? fileNameExpression = null) => Build(nameof(IFileInfoFactory.New), ParameterMatcher.From("fileName", fileName, fileNameExpression)); @@ -43,8 +45,9 @@ public RecordedMethodCallResult New( /// Recorded calls to . /// public RecordedMethodCallResult Wrap( - Func? fileInfo = null, - [CallerArgumentExpression(nameof(fileInfo))] string? fileInfoExpression = null) + Func? fileInfo = null, + [CallerArgumentExpression(nameof(fileInfo))] + string? fileInfoExpression = null) => Build(nameof(IFileInfoFactory.Wrap), ParameterMatcher.From("fileInfo", fileInfo, fileInfoExpression)); diff --git a/Source/aweXpect.Testably/Recorded/RecordedFileInfoInstance.cs b/Source/aweXpect.Testably/Recorded/RecordedFileInfoInstance.cs index a6509b5..e924094 100644 --- a/Source/aweXpect.Testably/Recorded/RecordedFileInfoInstance.cs +++ b/Source/aweXpect.Testably/Recorded/RecordedFileInfoInstance.cs @@ -15,9 +15,9 @@ namespace aweXpect.Testably.Recorded; /// public sealed class RecordedFileInfoInstance { - private readonly IThat _subject; - private readonly string _path; private readonly string _bucketDescription; + private readonly string _path; + private readonly IThat _subject; internal RecordedFileInfoInstance(IThat subject, string path) { @@ -26,6 +26,116 @@ internal RecordedFileInfoInstance(IThat subject, string p _bucketDescription = $"FileInfo[\"{path}\"]"; } + /// + /// Recorded accesses to via . + /// + public RecordedProperty Attributes + => Property(nameof(IFileSystemInfo.Attributes)); + + /// + /// Recorded accesses to . + /// + public RecordedProperty CreationTime + => Property(nameof(IFileSystemInfo.CreationTime)); + + /// + /// Recorded accesses to . + /// + public RecordedProperty CreationTimeUtc + => Property(nameof(IFileSystemInfo.CreationTimeUtc)); + + /// + /// Recorded accesses to . + /// + public RecordedProperty Directory + => Property(nameof(IFileInfo.Directory)); + + /// + /// Recorded accesses to . + /// + public RecordedProperty DirectoryName + => Property(nameof(IFileInfo.DirectoryName)); + + /// + /// Recorded accesses to . + /// + public RecordedProperty Exists + => Property(nameof(IFileSystemInfo.Exists)); + + /// + /// Recorded accesses to . + /// + public RecordedProperty Extension + => Property(nameof(IFileSystemInfo.Extension)); + + /// + /// Recorded accesses to . + /// + public RecordedProperty FullName + => Property(nameof(IFileSystemInfo.FullName)); + + /// + /// Recorded accesses to . + /// + public RecordedProperty IsReadOnly + => Property(nameof(IFileInfo.IsReadOnly)); + + /// + /// Recorded accesses to . + /// + public RecordedProperty LastAccessTime + => Property(nameof(IFileSystemInfo.LastAccessTime)); + + /// + /// Recorded accesses to . + /// + public RecordedProperty LastAccessTimeUtc + => Property(nameof(IFileSystemInfo.LastAccessTimeUtc)); + + /// + /// Recorded accesses to . + /// + public RecordedProperty LastWriteTime + => Property(nameof(IFileSystemInfo.LastWriteTime)); + + /// + /// Recorded accesses to . + /// + public RecordedProperty LastWriteTimeUtc + => Property(nameof(IFileSystemInfo.LastWriteTimeUtc)); + + /// + /// Recorded accesses to . + /// + public RecordedProperty Length + => Property(nameof(IFileInfo.Length)); + + /// + /// Recorded accesses to IFileSystemInfo.LinkTarget. + /// + public RecordedProperty LinkTarget +#if NET6_0_OR_GREATER + => Property(nameof(IFileSystemInfo.LinkTarget)); +#else + => Property("LinkTarget"); +#endif + + /// + /// Recorded accesses to . + /// + public RecordedProperty Name + => Property(nameof(IFileSystemInfo.Name)); + + /// + /// Recorded accesses to IFileSystemInfo.UnixFileMode. + /// + public RecordedProperty UnixFileMode +#if NET7_0_OR_GREATER + => Property(nameof(IFileSystemInfo.UnixFileMode)); +#else + => Property("UnixFileMode"); +#endif + /// /// Recorded calls to . /// @@ -38,8 +148,10 @@ public RecordedMethodCallResult AppendText() public RecordedMethodCallResult CopyTo( Func? destFileName = null, Func? overwrite = null, - [CallerArgumentExpression(nameof(destFileName))] string? destFileNameExpression = null, - [CallerArgumentExpression(nameof(overwrite))] string? overwriteExpression = null) + [CallerArgumentExpression(nameof(destFileName))] + string? destFileNameExpression = null, + [CallerArgumentExpression(nameof(overwrite))] + string? overwriteExpression = null) => Build(nameof(IFileInfo.CopyTo), ParameterMatcher.From("destFileName", destFileName, destFileNameExpression), ParameterMatcher.From("overwrite", overwrite, overwriteExpression)); @@ -55,7 +167,8 @@ public RecordedMethodCallResult Create() /// public RecordedMethodCallResult CreateAsSymbolicLink( Func? pathToTarget = null, - [CallerArgumentExpression(nameof(pathToTarget))] string? pathToTargetExpression = null) + [CallerArgumentExpression(nameof(pathToTarget))] + string? pathToTargetExpression = null) => Build("CreateAsSymbolicLink", ParameterMatcher.From("pathToTarget", pathToTarget, pathToTargetExpression)); @@ -89,8 +202,10 @@ public RecordedMethodCallResult Encrypt() public RecordedMethodCallResult MoveTo( Func? destFileName = null, Func? overwrite = null, - [CallerArgumentExpression(nameof(destFileName))] string? destFileNameExpression = null, - [CallerArgumentExpression(nameof(overwrite))] string? overwriteExpression = null) + [CallerArgumentExpression(nameof(destFileName))] + string? destFileNameExpression = null, + [CallerArgumentExpression(nameof(overwrite))] + string? overwriteExpression = null) => Build(nameof(IFileInfo.MoveTo), ParameterMatcher.From("destFileName", destFileName, destFileNameExpression), ParameterMatcher.From("overwrite", overwrite, overwriteExpression)); @@ -108,9 +223,12 @@ public RecordedMethodCallResult Open( Func? mode = null, Func? access = null, Func? share = null, - [CallerArgumentExpression(nameof(mode))] string? modeExpression = null, - [CallerArgumentExpression(nameof(access))] string? accessExpression = null, - [CallerArgumentExpression(nameof(share))] string? shareExpression = null) + [CallerArgumentExpression(nameof(mode))] + string? modeExpression = null, + [CallerArgumentExpression(nameof(access))] + string? accessExpression = null, + [CallerArgumentExpression(nameof(share))] + string? shareExpression = null) => Build(nameof(IFileInfo.Open), ParameterMatcher.From("mode", mode, modeExpression), ParameterMatcher.From("access", access, accessExpression), @@ -147,9 +265,12 @@ public RecordedMethodCallResult Replace( Func? destinationFileName = null, Func? destinationBackupFileName = null, Func? ignoreMetadataErrors = null, - [CallerArgumentExpression(nameof(destinationFileName))] string? destinationFileNameExpression = null, - [CallerArgumentExpression(nameof(destinationBackupFileName))] string? destinationBackupFileNameExpression = null, - [CallerArgumentExpression(nameof(ignoreMetadataErrors))] string? ignoreMetadataErrorsExpression = null) + [CallerArgumentExpression(nameof(destinationFileName))] + string? destinationFileNameExpression = null, + [CallerArgumentExpression(nameof(destinationBackupFileName))] + string? destinationBackupFileNameExpression = null, + [CallerArgumentExpression(nameof(ignoreMetadataErrors))] + string? ignoreMetadataErrorsExpression = null) => Build(nameof(IFileInfo.Replace), ParameterMatcher.From("destinationFileName", destinationFileName, destinationFileNameExpression), ParameterMatcher.From("destinationBackupFileName", destinationBackupFileName, destinationBackupFileNameExpression), @@ -160,120 +281,11 @@ public RecordedMethodCallResult Replace( /// public RecordedMethodCallResult ResolveLinkTarget( Func? returnFinalTarget = null, - [CallerArgumentExpression(nameof(returnFinalTarget))] string? returnFinalTargetExpression = null) + [CallerArgumentExpression(nameof(returnFinalTarget))] + string? returnFinalTargetExpression = null) => Build("ResolveLinkTarget", ParameterMatcher.From("returnFinalTarget", returnFinalTarget, returnFinalTargetExpression)); - /// - /// Recorded accesses to via . - /// - public RecordedProperty Attributes - => Property(nameof(IFileSystemInfo.Attributes)); - - /// - /// Recorded accesses to . - /// - public RecordedProperty CreationTime - => Property(nameof(IFileSystemInfo.CreationTime)); - - /// - /// Recorded accesses to . - /// - public RecordedProperty CreationTimeUtc - => Property(nameof(IFileSystemInfo.CreationTimeUtc)); - - /// - /// Recorded accesses to . - /// - public RecordedProperty Directory - => Property(nameof(IFileInfo.Directory)); - - /// - /// Recorded accesses to . - /// - public RecordedProperty DirectoryName - => Property(nameof(IFileInfo.DirectoryName)); - - /// - /// Recorded accesses to . - /// - public RecordedProperty Exists - => Property(nameof(IFileSystemInfo.Exists)); - - /// - /// Recorded accesses to . - /// - public RecordedProperty Extension - => Property(nameof(IFileSystemInfo.Extension)); - - /// - /// Recorded accesses to . - /// - public RecordedProperty FullName - => Property(nameof(IFileSystemInfo.FullName)); - - /// - /// Recorded accesses to . - /// - public RecordedProperty IsReadOnly - => Property(nameof(IFileInfo.IsReadOnly)); - - /// - /// Recorded accesses to . - /// - public RecordedProperty LastAccessTime - => Property(nameof(IFileSystemInfo.LastAccessTime)); - - /// - /// Recorded accesses to . - /// - public RecordedProperty LastAccessTimeUtc - => Property(nameof(IFileSystemInfo.LastAccessTimeUtc)); - - /// - /// Recorded accesses to . - /// - public RecordedProperty LastWriteTime - => Property(nameof(IFileSystemInfo.LastWriteTime)); - - /// - /// Recorded accesses to . - /// - public RecordedProperty LastWriteTimeUtc - => Property(nameof(IFileSystemInfo.LastWriteTimeUtc)); - - /// - /// Recorded accesses to . - /// - public RecordedProperty Length - => Property(nameof(IFileInfo.Length)); - - /// - /// Recorded accesses to IFileSystemInfo.LinkTarget. - /// - public RecordedProperty LinkTarget -#if NET6_0_OR_GREATER - => Property(nameof(IFileSystemInfo.LinkTarget)); -#else - => Property("LinkTarget"); -#endif - - /// - /// Recorded accesses to . - /// - public RecordedProperty Name - => Property(nameof(IFileSystemInfo.Name)); - - /// - /// Recorded accesses to IFileSystemInfo.UnixFileMode. - /// - public RecordedProperty UnixFileMode -#if NET7_0_OR_GREATER - => Property(nameof(IFileSystemInfo.UnixFileMode)); -#else - => Property("UnixFileMode"); -#endif - private RecordedProperty Property(string propertyName) { string path = _path; diff --git a/Source/aweXpect.Testably/Recorded/RecordedFileMethods.cs b/Source/aweXpect.Testably/Recorded/RecordedFileMethods.cs index d2f73d6..9bdbd31 100644 --- a/Source/aweXpect.Testably/Recorded/RecordedFileMethods.cs +++ b/Source/aweXpect.Testably/Recorded/RecordedFileMethods.cs @@ -37,8 +37,10 @@ internal RecordedFileMethods(IThat subject) public RecordedMethodCallResult AppendAllBytes( Func? path = null, Func? bytes = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null, - [CallerArgumentExpression(nameof(bytes))] string? bytesExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null, + [CallerArgumentExpression(nameof(bytes))] + string? bytesExpression = null) => Build("AppendAllBytes", ParameterMatcher.From("path", path, pathExpression), ParameterMatcher.From("bytes", bytes, bytesExpression)); @@ -51,8 +53,10 @@ public RecordedMethodCallResult AppendAllBytes( public RecordedMethodCallResult AppendAllBytesAsync( Func? path = null, Func? bytes = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null, - [CallerArgumentExpression(nameof(bytes))] string? bytesExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null, + [CallerArgumentExpression(nameof(bytes))] + string? bytesExpression = null) => Build("AppendAllBytesAsync", ParameterMatcher.From("path", path, pathExpression), ParameterMatcher.From("bytes", bytes, bytesExpression)); @@ -61,8 +65,10 @@ public RecordedMethodCallResult AppendAllBytesAsync( public RecordedMethodCallResult AppendAllLines( Func? path = null, Func? encoding = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null, - [CallerArgumentExpression(nameof(encoding))] string? encodingExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null, + [CallerArgumentExpression(nameof(encoding))] + string? encodingExpression = null) => Build(nameof(IFile.AppendAllLines), ParameterMatcher.From("path", path, pathExpression), ParameterMatcher.From("contents", null, null), @@ -76,8 +82,10 @@ public RecordedMethodCallResult AppendAllLines( public RecordedMethodCallResult AppendAllLinesAsync( Func? path = null, Func? encoding = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null, - [CallerArgumentExpression(nameof(encoding))] string? encodingExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null, + [CallerArgumentExpression(nameof(encoding))] + string? encodingExpression = null) => Build("AppendAllLinesAsync", ParameterMatcher.From("path", path, pathExpression), ParameterMatcher.From("contents", null, null), @@ -88,9 +96,12 @@ public RecordedMethodCallResult AppendAllText( Func? path = null, Func? contents = null, Func? encoding = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null, - [CallerArgumentExpression(nameof(contents))] string? contentsExpression = null, - [CallerArgumentExpression(nameof(encoding))] string? encodingExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null, + [CallerArgumentExpression(nameof(contents))] + string? contentsExpression = null, + [CallerArgumentExpression(nameof(encoding))] + string? encodingExpression = null) => Build(nameof(IFile.AppendAllText), ParameterMatcher.From("path", path, pathExpression), ParameterMatcher.From("contents", contents, contentsExpression), @@ -101,9 +112,12 @@ public RecordedMethodCallResult AppendAllTextAsync( Func? path = null, Func? contents = null, Func? encoding = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null, - [CallerArgumentExpression(nameof(contents))] string? contentsExpression = null, - [CallerArgumentExpression(nameof(encoding))] string? encodingExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null, + [CallerArgumentExpression(nameof(contents))] + string? contentsExpression = null, + [CallerArgumentExpression(nameof(encoding))] + string? encodingExpression = null) => Build("AppendAllTextAsync", ParameterMatcher.From("path", path, pathExpression), ParameterMatcher.From("contents", contents, contentsExpression), @@ -112,7 +126,8 @@ public RecordedMethodCallResult AppendAllTextAsync( /// Recorded calls to . public RecordedMethodCallResult AppendText( Func? path = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null) => Build(nameof(IFile.AppendText), ParameterMatcher.From("path", path, pathExpression)); @@ -121,9 +136,12 @@ public RecordedMethodCallResult Copy( Func? sourceFileName = null, Func? destFileName = null, Func? overwrite = null, - [CallerArgumentExpression(nameof(sourceFileName))] string? sourceFileNameExpression = null, - [CallerArgumentExpression(nameof(destFileName))] string? destFileNameExpression = null, - [CallerArgumentExpression(nameof(overwrite))] string? overwriteExpression = null) + [CallerArgumentExpression(nameof(sourceFileName))] + string? sourceFileNameExpression = null, + [CallerArgumentExpression(nameof(destFileName))] + string? destFileNameExpression = null, + [CallerArgumentExpression(nameof(overwrite))] + string? overwriteExpression = null) => Build(nameof(IFile.Copy), ParameterMatcher.From("sourceFileName", sourceFileName, sourceFileNameExpression), ParameterMatcher.From("destFileName", destFileName, destFileNameExpression), @@ -134,9 +152,12 @@ public RecordedMethodCallResult Create( Func? path = null, Func? bufferSize = null, Func? options = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null, - [CallerArgumentExpression(nameof(bufferSize))] string? bufferSizeExpression = null, - [CallerArgumentExpression(nameof(options))] string? optionsExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null, + [CallerArgumentExpression(nameof(bufferSize))] + string? bufferSizeExpression = null, + [CallerArgumentExpression(nameof(options))] + string? optionsExpression = null) => Build(nameof(IFile.Create), ParameterMatcher.From("path", path, pathExpression), ParameterMatcher.From("bufferSize", bufferSize, bufferSizeExpression), @@ -146,8 +167,10 @@ public RecordedMethodCallResult Create( public RecordedMethodCallResult CreateSymbolicLink( Func? path = null, Func? pathToTarget = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null, - [CallerArgumentExpression(nameof(pathToTarget))] string? pathToTargetExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null, + [CallerArgumentExpression(nameof(pathToTarget))] + string? pathToTargetExpression = null) => Build("CreateSymbolicLink", ParameterMatcher.From("path", path, pathExpression), ParameterMatcher.From("pathToTarget", pathToTarget, pathToTargetExpression)); @@ -155,84 +178,96 @@ public RecordedMethodCallResult CreateSymbolicLink( /// Recorded calls to . public RecordedMethodCallResult CreateText( Func? path = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null) => Build(nameof(IFile.CreateText), ParameterMatcher.From("path", path, pathExpression)); /// Recorded calls to . public RecordedMethodCallResult Decrypt( Func? path = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null) => Build(nameof(IFile.Decrypt), ParameterMatcher.From("path", path, pathExpression)); /// Recorded calls to . public RecordedMethodCallResult Delete( Func? path = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null) => Build(nameof(IFile.Delete), ParameterMatcher.From("path", path, pathExpression)); /// Recorded calls to . public RecordedMethodCallResult Encrypt( Func? path = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null) => Build(nameof(IFile.Encrypt), ParameterMatcher.From("path", path, pathExpression)); /// Recorded calls to . public RecordedMethodCallResult Exists( Func? path = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null) => Build(nameof(IFile.Exists), ParameterMatcher.From("path", path, pathExpression)); /// Recorded calls to and overloads. public RecordedMethodCallResult GetAttributes( Func? path = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null) => Build(nameof(IFile.GetAttributes), ParameterMatcher.From("path", path, pathExpression)); /// Recorded calls to and overloads. public RecordedMethodCallResult GetCreationTime( Func? path = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null) => Build(nameof(IFile.GetCreationTime), ParameterMatcher.From("path", path, pathExpression)); /// Recorded calls to and overloads. public RecordedMethodCallResult GetCreationTimeUtc( Func? path = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null) => Build(nameof(IFile.GetCreationTimeUtc), ParameterMatcher.From("path", path, pathExpression)); /// Recorded calls to and overloads. public RecordedMethodCallResult GetLastAccessTime( Func? path = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null) => Build(nameof(IFile.GetLastAccessTime), ParameterMatcher.From("path", path, pathExpression)); /// Recorded calls to and overloads. public RecordedMethodCallResult GetLastAccessTimeUtc( Func? path = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null) => Build(nameof(IFile.GetLastAccessTimeUtc), ParameterMatcher.From("path", path, pathExpression)); /// Recorded calls to and overloads. public RecordedMethodCallResult GetLastWriteTime( Func? path = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null) => Build(nameof(IFile.GetLastWriteTime), ParameterMatcher.From("path", path, pathExpression)); /// Recorded calls to and overloads. public RecordedMethodCallResult GetLastWriteTimeUtc( Func? path = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null) => Build(nameof(IFile.GetLastWriteTimeUtc), ParameterMatcher.From("path", path, pathExpression)); @@ -250,9 +285,12 @@ public RecordedMethodCallResult Move( Func? sourceFileName = null, Func? destFileName = null, Func? overwrite = null, - [CallerArgumentExpression(nameof(sourceFileName))] string? sourceFileNameExpression = null, - [CallerArgumentExpression(nameof(destFileName))] string? destFileNameExpression = null, - [CallerArgumentExpression(nameof(overwrite))] string? overwriteExpression = null) + [CallerArgumentExpression(nameof(sourceFileName))] + string? sourceFileNameExpression = null, + [CallerArgumentExpression(nameof(destFileName))] + string? destFileNameExpression = null, + [CallerArgumentExpression(nameof(overwrite))] + string? overwriteExpression = null) => Build(nameof(IFile.Move), ParameterMatcher.From("sourceFileName", sourceFileName, sourceFileNameExpression), ParameterMatcher.From("destFileName", destFileName, destFileNameExpression), @@ -270,10 +308,14 @@ public RecordedMethodCallResult Open( Func? mode = null, Func? access = null, Func? share = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null, - [CallerArgumentExpression(nameof(mode))] string? modeExpression = null, - [CallerArgumentExpression(nameof(access))] string? accessExpression = null, - [CallerArgumentExpression(nameof(share))] string? shareExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null, + [CallerArgumentExpression(nameof(mode))] + string? modeExpression = null, + [CallerArgumentExpression(nameof(access))] + string? accessExpression = null, + [CallerArgumentExpression(nameof(share))] + string? shareExpression = null) => Build(nameof(IFile.Open), ParameterMatcher.From("path", path, pathExpression), ParameterMatcher.From("mode", mode, modeExpression), @@ -284,35 +326,40 @@ public RecordedMethodCallResult Open( /// Recorded calls to . public RecordedMethodCallResult OpenRead( Func? path = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null) => Build(nameof(IFile.OpenRead), ParameterMatcher.From("path", path, pathExpression)); /// Recorded calls to . public RecordedMethodCallResult OpenText( Func? path = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null) => Build(nameof(IFile.OpenText), ParameterMatcher.From("path", path, pathExpression)); /// Recorded calls to . public RecordedMethodCallResult OpenWrite( Func? path = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null) => Build(nameof(IFile.OpenWrite), ParameterMatcher.From("path", path, pathExpression)); /// Recorded calls to . public RecordedMethodCallResult ReadAllBytes( Func? path = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null) => Build(nameof(IFile.ReadAllBytes), ParameterMatcher.From("path", path, pathExpression)); /// Recorded calls to IFile.ReadAllBytesAsync(string, CancellationToken). public RecordedMethodCallResult ReadAllBytesAsync( Func? path = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null) => Build("ReadAllBytesAsync", ParameterMatcher.From("path", path, pathExpression)); @@ -320,8 +367,10 @@ public RecordedMethodCallResult ReadAllBytesAsync( public RecordedMethodCallResult ReadAllLines( Func? path = null, Func? encoding = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null, - [CallerArgumentExpression(nameof(encoding))] string? encodingExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null, + [CallerArgumentExpression(nameof(encoding))] + string? encodingExpression = null) => Build(nameof(IFile.ReadAllLines), ParameterMatcher.From("path", path, pathExpression), ParameterMatcher.From("encoding", encoding, encodingExpression)); @@ -330,8 +379,10 @@ public RecordedMethodCallResult ReadAllLines( public RecordedMethodCallResult ReadAllLinesAsync( Func? path = null, Func? encoding = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null, - [CallerArgumentExpression(nameof(encoding))] string? encodingExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null, + [CallerArgumentExpression(nameof(encoding))] + string? encodingExpression = null) => Build("ReadAllLinesAsync", ParameterMatcher.From("path", path, pathExpression), ParameterMatcher.From("encoding", encoding, encodingExpression)); @@ -340,8 +391,10 @@ public RecordedMethodCallResult ReadAllLinesAsync( public RecordedMethodCallResult ReadAllText( Func? path = null, Func? encoding = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null, - [CallerArgumentExpression(nameof(encoding))] string? encodingExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null, + [CallerArgumentExpression(nameof(encoding))] + string? encodingExpression = null) => Build(nameof(IFile.ReadAllText), ParameterMatcher.From("path", path, pathExpression), ParameterMatcher.From("encoding", encoding, encodingExpression)); @@ -350,8 +403,10 @@ public RecordedMethodCallResult ReadAllText( public RecordedMethodCallResult ReadAllTextAsync( Func? path = null, Func? encoding = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null, - [CallerArgumentExpression(nameof(encoding))] string? encodingExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null, + [CallerArgumentExpression(nameof(encoding))] + string? encodingExpression = null) => Build("ReadAllTextAsync", ParameterMatcher.From("path", path, pathExpression), ParameterMatcher.From("encoding", encoding, encodingExpression)); @@ -360,8 +415,10 @@ public RecordedMethodCallResult ReadAllTextAsync( public RecordedMethodCallResult ReadLines( Func? path = null, Func? encoding = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null, - [CallerArgumentExpression(nameof(encoding))] string? encodingExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null, + [CallerArgumentExpression(nameof(encoding))] + string? encodingExpression = null) => Build(nameof(IFile.ReadLines), ParameterMatcher.From("path", path, pathExpression), ParameterMatcher.From("encoding", encoding, encodingExpression)); @@ -370,8 +427,10 @@ public RecordedMethodCallResult ReadLines( public RecordedMethodCallResult ReadLinesAsync( Func? path = null, Func? encoding = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null, - [CallerArgumentExpression(nameof(encoding))] string? encodingExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null, + [CallerArgumentExpression(nameof(encoding))] + string? encodingExpression = null) => Build("ReadLinesAsync", ParameterMatcher.From("path", path, pathExpression), ParameterMatcher.From("encoding", encoding, encodingExpression)); @@ -383,10 +442,14 @@ public RecordedMethodCallResult Replace( Func? destinationFileName = null, Func? destinationBackupFileName = null, Func? ignoreMetadataErrors = null, - [CallerArgumentExpression(nameof(sourceFileName))] string? sourceFileNameExpression = null, - [CallerArgumentExpression(nameof(destinationFileName))] string? destinationFileNameExpression = null, - [CallerArgumentExpression(nameof(destinationBackupFileName))] string? destinationBackupFileNameExpression = null, - [CallerArgumentExpression(nameof(ignoreMetadataErrors))] string? ignoreMetadataErrorsExpression = null) + [CallerArgumentExpression(nameof(sourceFileName))] + string? sourceFileNameExpression = null, + [CallerArgumentExpression(nameof(destinationFileName))] + string? destinationFileNameExpression = null, + [CallerArgumentExpression(nameof(destinationBackupFileName))] + string? destinationBackupFileNameExpression = null, + [CallerArgumentExpression(nameof(ignoreMetadataErrors))] + string? ignoreMetadataErrorsExpression = null) => Build(nameof(IFile.Replace), ParameterMatcher.From("sourceFileName", sourceFileName, sourceFileNameExpression), ParameterMatcher.From("destinationFileName", destinationFileName, destinationFileNameExpression), @@ -398,8 +461,10 @@ public RecordedMethodCallResult Replace( public RecordedMethodCallResult ResolveLinkTarget( Func? linkPath = null, Func? returnFinalTarget = null, - [CallerArgumentExpression(nameof(linkPath))] string? linkPathExpression = null, - [CallerArgumentExpression(nameof(returnFinalTarget))] string? returnFinalTargetExpression = null) + [CallerArgumentExpression(nameof(linkPath))] + string? linkPathExpression = null, + [CallerArgumentExpression(nameof(returnFinalTarget))] + string? returnFinalTargetExpression = null) => Build("ResolveLinkTarget", ParameterMatcher.From("linkPath", linkPath, linkPathExpression), ParameterMatcher.From("returnFinalTarget", returnFinalTarget, returnFinalTargetExpression)); @@ -408,8 +473,10 @@ public RecordedMethodCallResult ResolveLinkTarget( public RecordedMethodCallResult SetAttributes( Func? path = null, Func? fileAttributes = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null, - [CallerArgumentExpression(nameof(fileAttributes))] string? fileAttributesExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null, + [CallerArgumentExpression(nameof(fileAttributes))] + string? fileAttributesExpression = null) => Build(nameof(IFile.SetAttributes), ParameterMatcher.From("path", path, pathExpression), ParameterMatcher.From("fileAttributes", fileAttributes, fileAttributesExpression)); @@ -418,8 +485,10 @@ public RecordedMethodCallResult SetAttributes( public RecordedMethodCallResult SetCreationTime( Func? path = null, Func? creationTime = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null, - [CallerArgumentExpression(nameof(creationTime))] string? creationTimeExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null, + [CallerArgumentExpression(nameof(creationTime))] + string? creationTimeExpression = null) => Build(nameof(IFile.SetCreationTime), ParameterMatcher.From("path", path, pathExpression), ParameterMatcher.From("creationTime", creationTime, creationTimeExpression)); @@ -428,8 +497,10 @@ public RecordedMethodCallResult SetCreationTime( public RecordedMethodCallResult SetCreationTimeUtc( Func? path = null, Func? creationTimeUtc = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null, - [CallerArgumentExpression(nameof(creationTimeUtc))] string? creationTimeUtcExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null, + [CallerArgumentExpression(nameof(creationTimeUtc))] + string? creationTimeUtcExpression = null) => Build(nameof(IFile.SetCreationTimeUtc), ParameterMatcher.From("path", path, pathExpression), ParameterMatcher.From("creationTimeUtc", creationTimeUtc, creationTimeUtcExpression)); @@ -438,8 +509,10 @@ public RecordedMethodCallResult SetCreationTimeUtc( public RecordedMethodCallResult SetLastAccessTime( Func? path = null, Func? lastAccessTime = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null, - [CallerArgumentExpression(nameof(lastAccessTime))] string? lastAccessTimeExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null, + [CallerArgumentExpression(nameof(lastAccessTime))] + string? lastAccessTimeExpression = null) => Build(nameof(IFile.SetLastAccessTime), ParameterMatcher.From("path", path, pathExpression), ParameterMatcher.From("lastAccessTime", lastAccessTime, lastAccessTimeExpression)); @@ -448,8 +521,10 @@ public RecordedMethodCallResult SetLastAccessTime( public RecordedMethodCallResult SetLastAccessTimeUtc( Func? path = null, Func? lastAccessTimeUtc = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null, - [CallerArgumentExpression(nameof(lastAccessTimeUtc))] string? lastAccessTimeUtcExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null, + [CallerArgumentExpression(nameof(lastAccessTimeUtc))] + string? lastAccessTimeUtcExpression = null) => Build(nameof(IFile.SetLastAccessTimeUtc), ParameterMatcher.From("path", path, pathExpression), ParameterMatcher.From("lastAccessTimeUtc", lastAccessTimeUtc, lastAccessTimeUtcExpression)); @@ -458,8 +533,10 @@ public RecordedMethodCallResult SetLastAccessTimeUtc( public RecordedMethodCallResult SetLastWriteTime( Func? path = null, Func? lastWriteTime = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null, - [CallerArgumentExpression(nameof(lastWriteTime))] string? lastWriteTimeExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null, + [CallerArgumentExpression(nameof(lastWriteTime))] + string? lastWriteTimeExpression = null) => Build(nameof(IFile.SetLastWriteTime), ParameterMatcher.From("path", path, pathExpression), ParameterMatcher.From("lastWriteTime", lastWriteTime, lastWriteTimeExpression)); @@ -468,8 +545,10 @@ public RecordedMethodCallResult SetLastWriteTime( public RecordedMethodCallResult SetLastWriteTimeUtc( Func? path = null, Func? lastWriteTimeUtc = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null, - [CallerArgumentExpression(nameof(lastWriteTimeUtc))] string? lastWriteTimeUtcExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null, + [CallerArgumentExpression(nameof(lastWriteTimeUtc))] + string? lastWriteTimeUtcExpression = null) => Build(nameof(IFile.SetLastWriteTimeUtc), ParameterMatcher.From("path", path, pathExpression), ParameterMatcher.From("lastWriteTimeUtc", lastWriteTimeUtc, lastWriteTimeUtcExpression)); @@ -490,8 +569,10 @@ public RecordedMethodCallResult SetUnixFileMode( public RecordedMethodCallResult WriteAllBytes( Func? path = null, Func? bytes = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null, - [CallerArgumentExpression(nameof(bytes))] string? bytesExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null, + [CallerArgumentExpression(nameof(bytes))] + string? bytesExpression = null) => Build(nameof(IFile.WriteAllBytes), ParameterMatcher.From("path", path, pathExpression), ParameterMatcher.From("bytes", bytes, bytesExpression)); @@ -504,8 +585,10 @@ public RecordedMethodCallResult WriteAllBytes( public RecordedMethodCallResult WriteAllBytesAsync( Func? path = null, Func? bytes = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null, - [CallerArgumentExpression(nameof(bytes))] string? bytesExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null, + [CallerArgumentExpression(nameof(bytes))] + string? bytesExpression = null) => Build("WriteAllBytesAsync", ParameterMatcher.From("path", path, pathExpression), ParameterMatcher.From("bytes", bytes, bytesExpression)); @@ -514,8 +597,10 @@ public RecordedMethodCallResult WriteAllBytesAsync( public RecordedMethodCallResult WriteAllLines( Func? path = null, Func? encoding = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null, - [CallerArgumentExpression(nameof(encoding))] string? encodingExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null, + [CallerArgumentExpression(nameof(encoding))] + string? encodingExpression = null) => Build(nameof(IFile.WriteAllLines), ParameterMatcher.From("path", path, pathExpression), ParameterMatcher.From("contents", null, null), @@ -529,8 +614,10 @@ public RecordedMethodCallResult WriteAllLines( public RecordedMethodCallResult WriteAllLinesAsync( Func? path = null, Func? encoding = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null, - [CallerArgumentExpression(nameof(encoding))] string? encodingExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null, + [CallerArgumentExpression(nameof(encoding))] + string? encodingExpression = null) => Build("WriteAllLinesAsync", ParameterMatcher.From("path", path, pathExpression), ParameterMatcher.From("contents", null, null), @@ -541,9 +628,12 @@ public RecordedMethodCallResult WriteAllText( Func? path = null, Func? contents = null, Func? encoding = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null, - [CallerArgumentExpression(nameof(contents))] string? contentsExpression = null, - [CallerArgumentExpression(nameof(encoding))] string? encodingExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null, + [CallerArgumentExpression(nameof(contents))] + string? contentsExpression = null, + [CallerArgumentExpression(nameof(encoding))] + string? encodingExpression = null) => Build(nameof(IFile.WriteAllText), ParameterMatcher.From("path", path, pathExpression), ParameterMatcher.From("contents", contents, contentsExpression), @@ -554,9 +644,12 @@ public RecordedMethodCallResult WriteAllTextAsync( Func? path = null, Func? contents = null, Func? encoding = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null, - [CallerArgumentExpression(nameof(contents))] string? contentsExpression = null, - [CallerArgumentExpression(nameof(encoding))] string? encodingExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null, + [CallerArgumentExpression(nameof(contents))] + string? contentsExpression = null, + [CallerArgumentExpression(nameof(encoding))] + string? encodingExpression = null) => Build("WriteAllTextAsync", ParameterMatcher.From("path", path, pathExpression), ParameterMatcher.From("contents", contents, contentsExpression), diff --git a/Source/aweXpect.Testably/Recorded/RecordedFileStreamBucket.cs b/Source/aweXpect.Testably/Recorded/RecordedFileStreamBucket.cs index 636e141..a6584eb 100644 --- a/Source/aweXpect.Testably/Recorded/RecordedFileStreamBucket.cs +++ b/Source/aweXpect.Testably/Recorded/RecordedFileStreamBucket.cs @@ -46,11 +46,16 @@ public RecordedMethodCallResult New( Func? access = null, Func? share = null, Func? bufferSize = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null, - [CallerArgumentExpression(nameof(mode))] string? modeExpression = null, - [CallerArgumentExpression(nameof(access))] string? accessExpression = null, - [CallerArgumentExpression(nameof(share))] string? shareExpression = null, - [CallerArgumentExpression(nameof(bufferSize))] string? bufferSizeExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null, + [CallerArgumentExpression(nameof(mode))] + string? modeExpression = null, + [CallerArgumentExpression(nameof(access))] + string? accessExpression = null, + [CallerArgumentExpression(nameof(share))] + string? shareExpression = null, + [CallerArgumentExpression(nameof(bufferSize))] + string? bufferSizeExpression = null) => Build(nameof(IFileStreamFactory.New), ParameterMatcher.From("path", path, pathExpression), ParameterMatcher.From("mode", mode, modeExpression), @@ -64,7 +69,8 @@ public RecordedMethodCallResult New( /// public RecordedMethodCallResult Wrap( Func? fileStream = null, - [CallerArgumentExpression(nameof(fileStream))] string? fileStreamExpression = null) + [CallerArgumentExpression(nameof(fileStream))] + string? fileStreamExpression = null) => Build(nameof(IFileStreamFactory.Wrap), ParameterMatcher.From("fileStream", fileStream, fileStreamExpression)); diff --git a/Source/aweXpect.Testably/Recorded/RecordedFileStreamInstance.cs b/Source/aweXpect.Testably/Recorded/RecordedFileStreamInstance.cs index cd63a3f..f7e20b9 100644 --- a/Source/aweXpect.Testably/Recorded/RecordedFileStreamInstance.cs +++ b/Source/aweXpect.Testably/Recorded/RecordedFileStreamInstance.cs @@ -20,9 +20,9 @@ namespace aweXpect.Testably.Recorded; /// public sealed class RecordedFileStreamInstance { - private readonly IThat _subject; - private readonly string _path; private readonly string _bucketDescription; + private readonly string _path; + private readonly IThat _subject; internal RecordedFileStreamInstance(IThat subject, string path) { @@ -31,6 +31,36 @@ internal RecordedFileStreamInstance(IThat subject, string _bucketDescription = $"FileStream[\"{path}\"]"; } + /// Recorded accesses to . + public RecordedProperty CanRead => Property(nameof(Stream.CanRead)); + + /// Recorded accesses to . + public RecordedProperty CanSeek => Property(nameof(Stream.CanSeek)); + + /// Recorded accesses to . + public RecordedProperty CanTimeout => Property(nameof(Stream.CanTimeout)); + + /// Recorded accesses to . + public RecordedProperty CanWrite => Property(nameof(Stream.CanWrite)); + + /// Recorded accesses to . + public RecordedProperty IsAsync => Property(nameof(FileSystemStream.IsAsync)); + + /// Recorded accesses to . + public RecordedProperty Length => Property(nameof(Stream.Length)); + + /// Recorded accesses to . + public RecordedProperty Name => Property(nameof(FileSystemStream.Name)); + + /// Recorded accesses to . + public RecordedProperty Position => Property(nameof(Stream.Position)); + + /// Recorded accesses to . + public RecordedProperty ReadTimeout => Property(nameof(Stream.ReadTimeout)); + + /// Recorded accesses to . + public RecordedProperty WriteTimeout => Property(nameof(Stream.WriteTimeout)); + /// Recorded calls to . public RecordedMethodCallResult Close() => Build(nameof(Stream.Close)); @@ -39,8 +69,10 @@ public RecordedMethodCallResult Close() public RecordedMethodCallResult CopyTo( Func? destination = null, Func? bufferSize = null, - [CallerArgumentExpression(nameof(destination))] string? destinationExpression = null, - [CallerArgumentExpression(nameof(bufferSize))] string? bufferSizeExpression = null) + [CallerArgumentExpression(nameof(destination))] + string? destinationExpression = null, + [CallerArgumentExpression(nameof(bufferSize))] + string? bufferSizeExpression = null) => Build(nameof(Stream.CopyTo), ParameterMatcher.From("destination", destination, destinationExpression), ParameterMatcher.From("bufferSize", bufferSize, bufferSizeExpression)); @@ -49,8 +81,10 @@ public RecordedMethodCallResult CopyTo( public RecordedMethodCallResult CopyToAsync( Func? destination = null, Func? bufferSize = null, - [CallerArgumentExpression(nameof(destination))] string? destinationExpression = null, - [CallerArgumentExpression(nameof(bufferSize))] string? bufferSizeExpression = null) + [CallerArgumentExpression(nameof(destination))] + string? destinationExpression = null, + [CallerArgumentExpression(nameof(bufferSize))] + string? bufferSizeExpression = null) => Build(nameof(Stream.CopyToAsync), ParameterMatcher.From("destination", destination, destinationExpression), ParameterMatcher.From("bufferSize", bufferSize, bufferSizeExpression)); @@ -58,14 +92,16 @@ public RecordedMethodCallResult CopyToAsync( /// Recorded calls to and . public RecordedMethodCallResult Flush( Func? flushToDisk = null, - [CallerArgumentExpression(nameof(flushToDisk))] string? flushToDiskExpression = null) + [CallerArgumentExpression(nameof(flushToDisk))] + string? flushToDiskExpression = null) => Build(nameof(Stream.Flush), ParameterMatcher.From("flushToDisk", flushToDisk, flushToDiskExpression)); /// Recorded calls to and overloads. public RecordedMethodCallResult FlushAsync( Func? cancellationToken = null, - [CallerArgumentExpression(nameof(cancellationToken))] string? cancellationTokenExpression = null) + [CallerArgumentExpression(nameof(cancellationToken))] + string? cancellationTokenExpression = null) => Build(nameof(Stream.FlushAsync), ParameterMatcher.From("cancellationToken", cancellationToken, cancellationTokenExpression)); @@ -74,9 +110,12 @@ public RecordedMethodCallResult Read( Func? buffer = null, Func? offset = null, Func? count = null, - [CallerArgumentExpression(nameof(buffer))] string? bufferExpression = null, - [CallerArgumentExpression(nameof(offset))] string? offsetExpression = null, - [CallerArgumentExpression(nameof(count))] string? countExpression = null) + [CallerArgumentExpression(nameof(buffer))] + string? bufferExpression = null, + [CallerArgumentExpression(nameof(offset))] + string? offsetExpression = null, + [CallerArgumentExpression(nameof(count))] + string? countExpression = null) => Build(nameof(Stream.Read), ParameterMatcher.From("buffer", buffer, bufferExpression), ParameterMatcher.From("offset", offset, offsetExpression), @@ -87,9 +126,12 @@ public RecordedMethodCallResult ReadAsync( Func? buffer = null, Func? offset = null, Func? count = null, - [CallerArgumentExpression(nameof(buffer))] string? bufferExpression = null, - [CallerArgumentExpression(nameof(offset))] string? offsetExpression = null, - [CallerArgumentExpression(nameof(count))] string? countExpression = null) + [CallerArgumentExpression(nameof(buffer))] + string? bufferExpression = null, + [CallerArgumentExpression(nameof(offset))] + string? offsetExpression = null, + [CallerArgumentExpression(nameof(count))] + string? countExpression = null) => Build(nameof(Stream.ReadAsync), ParameterMatcher.From("buffer", buffer, bufferExpression), ParameterMatcher.From("offset", offset, offsetExpression), @@ -103,8 +145,10 @@ public RecordedMethodCallResult ReadByte() public RecordedMethodCallResult Seek( Func? offset = null, Func? origin = null, - [CallerArgumentExpression(nameof(offset))] string? offsetExpression = null, - [CallerArgumentExpression(nameof(origin))] string? originExpression = null) + [CallerArgumentExpression(nameof(offset))] + string? offsetExpression = null, + [CallerArgumentExpression(nameof(origin))] + string? originExpression = null) => Build(nameof(Stream.Seek), ParameterMatcher.From("offset", offset, offsetExpression), ParameterMatcher.From("origin", origin, originExpression)); @@ -112,7 +156,8 @@ public RecordedMethodCallResult Seek( /// Recorded calls to . public RecordedMethodCallResult SetLength( Func? value = null, - [CallerArgumentExpression(nameof(value))] string? valueExpression = null) + [CallerArgumentExpression(nameof(value))] + string? valueExpression = null) => Build(nameof(Stream.SetLength), ParameterMatcher.From("value", value, valueExpression)); @@ -121,9 +166,12 @@ public RecordedMethodCallResult Write( Func? buffer = null, Func? offset = null, Func? count = null, - [CallerArgumentExpression(nameof(buffer))] string? bufferExpression = null, - [CallerArgumentExpression(nameof(offset))] string? offsetExpression = null, - [CallerArgumentExpression(nameof(count))] string? countExpression = null) + [CallerArgumentExpression(nameof(buffer))] + string? bufferExpression = null, + [CallerArgumentExpression(nameof(offset))] + string? offsetExpression = null, + [CallerArgumentExpression(nameof(count))] + string? countExpression = null) => Build(nameof(Stream.Write), ParameterMatcher.From("buffer", buffer, bufferExpression), ParameterMatcher.From("offset", offset, offsetExpression), @@ -134,9 +182,12 @@ public RecordedMethodCallResult WriteAsync( Func? buffer = null, Func? offset = null, Func? count = null, - [CallerArgumentExpression(nameof(buffer))] string? bufferExpression = null, - [CallerArgumentExpression(nameof(offset))] string? offsetExpression = null, - [CallerArgumentExpression(nameof(count))] string? countExpression = null) + [CallerArgumentExpression(nameof(buffer))] + string? bufferExpression = null, + [CallerArgumentExpression(nameof(offset))] + string? offsetExpression = null, + [CallerArgumentExpression(nameof(count))] + string? countExpression = null) => Build(nameof(Stream.WriteAsync), ParameterMatcher.From("buffer", buffer, bufferExpression), ParameterMatcher.From("offset", offset, offsetExpression), @@ -145,40 +196,11 @@ public RecordedMethodCallResult WriteAsync( /// Recorded calls to . public RecordedMethodCallResult WriteByte( Func? value = null, - [CallerArgumentExpression(nameof(value))] string? valueExpression = null) + [CallerArgumentExpression(nameof(value))] + string? valueExpression = null) => Build(nameof(Stream.WriteByte), ParameterMatcher.From("value", value, valueExpression)); - /// Recorded accesses to . - public RecordedProperty CanRead => Property(nameof(Stream.CanRead)); - - /// Recorded accesses to . - public RecordedProperty CanSeek => Property(nameof(Stream.CanSeek)); - - /// Recorded accesses to . - public RecordedProperty CanTimeout => Property(nameof(Stream.CanTimeout)); - - /// Recorded accesses to . - public RecordedProperty CanWrite => Property(nameof(Stream.CanWrite)); - - /// Recorded accesses to . - public RecordedProperty IsAsync => Property(nameof(FileSystemStream.IsAsync)); - - /// Recorded accesses to . - public RecordedProperty Length => Property(nameof(Stream.Length)); - - /// Recorded accesses to . - public RecordedProperty Name => Property(nameof(FileSystemStream.Name)); - - /// Recorded accesses to . - public RecordedProperty Position => Property(nameof(Stream.Position)); - - /// Recorded accesses to . - public RecordedProperty ReadTimeout => Property(nameof(Stream.ReadTimeout)); - - /// Recorded accesses to . - public RecordedProperty WriteTimeout => Property(nameof(Stream.WriteTimeout)); - private RecordedProperty Property(string propertyName) { string path = _path; diff --git a/Source/aweXpect.Testably/Recorded/RecordedFileSystemWatcherBucket.cs b/Source/aweXpect.Testably/Recorded/RecordedFileSystemWatcherBucket.cs index b76b837..d2cdbc6 100644 --- a/Source/aweXpect.Testably/Recorded/RecordedFileSystemWatcherBucket.cs +++ b/Source/aweXpect.Testably/Recorded/RecordedFileSystemWatcherBucket.cs @@ -37,8 +37,10 @@ public RecordedFileSystemWatcherInstance this[string path] public RecordedMethodCallResult New( Func? path = null, Func? filter = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null, - [CallerArgumentExpression(nameof(filter))] string? filterExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null, + [CallerArgumentExpression(nameof(filter))] + string? filterExpression = null) => Build(nameof(IFileSystemWatcherFactory.New), ParameterMatcher.From("path", path, pathExpression), ParameterMatcher.From("filter", filter, filterExpression)); @@ -48,7 +50,8 @@ public RecordedMethodCallResult New( /// public RecordedMethodCallResult Wrap( Func? fileSystemWatcher = null, - [CallerArgumentExpression(nameof(fileSystemWatcher))] string? fileSystemWatcherExpression = null) + [CallerArgumentExpression(nameof(fileSystemWatcher))] + string? fileSystemWatcherExpression = null) => Build(nameof(IFileSystemWatcherFactory.Wrap), ParameterMatcher.From("fileSystemWatcher", fileSystemWatcher, fileSystemWatcherExpression)); diff --git a/Source/aweXpect.Testably/Recorded/RecordedFileSystemWatcherInstance.cs b/Source/aweXpect.Testably/Recorded/RecordedFileSystemWatcherInstance.cs index 47ba620..427fa26 100644 --- a/Source/aweXpect.Testably/Recorded/RecordedFileSystemWatcherInstance.cs +++ b/Source/aweXpect.Testably/Recorded/RecordedFileSystemWatcherInstance.cs @@ -15,9 +15,9 @@ namespace aweXpect.Testably.Recorded; /// public sealed class RecordedFileSystemWatcherInstance { - private readonly IThat _subject; - private readonly string _path; private readonly string _bucketDescription; + private readonly string _path; + private readonly IThat _subject; internal RecordedFileSystemWatcherInstance(IThat subject, string path) { @@ -26,29 +26,6 @@ internal RecordedFileSystemWatcherInstance(IThat subject, _bucketDescription = $"FileSystemWatcher[\"{path}\"]"; } - /// Recorded calls to . - public RecordedMethodCallResult BeginInit() - => Build(nameof(IFileSystemWatcher.BeginInit)); - - /// Recorded calls to . - public RecordedMethodCallResult EndInit() - => Build(nameof(IFileSystemWatcher.EndInit)); - - /// Recorded calls to and overloads. - /// - /// The TimeSpan overload records a at parameter position 1 while - /// expects an ; filtering by - /// only matches the WaitForChanged(WatcherChangeTypes, int) overload. - /// - public RecordedMethodCallResult WaitForChanged( - Func? changeType = null, - Func? timeout = null, - [CallerArgumentExpression(nameof(changeType))] string? changeTypeExpression = null, - [CallerArgumentExpression(nameof(timeout))] string? timeoutExpression = null) - => Build(nameof(IFileSystemWatcher.WaitForChanged), - ParameterMatcher.From("changeType", changeType, changeTypeExpression), - ParameterMatcher.From("timeout", timeout, timeoutExpression)); - /// Recorded accesses to . public RecordedProperty EnableRaisingEvents => Property(nameof(IFileSystemWatcher.EnableRaisingEvents)); @@ -80,6 +57,31 @@ public RecordedMethodCallResult WaitForChanged( /// Recorded accesses to . public RecordedProperty SynchronizingObject => Property(nameof(IFileSystemWatcher.SynchronizingObject)); + /// Recorded calls to . + public RecordedMethodCallResult BeginInit() + => Build(nameof(IFileSystemWatcher.BeginInit)); + + /// Recorded calls to . + public RecordedMethodCallResult EndInit() + => Build(nameof(IFileSystemWatcher.EndInit)); + + /// Recorded calls to and overloads. + /// + /// The TimeSpan overload records a at parameter position 1 while + /// expects an ; filtering by + /// only matches the WaitForChanged(WatcherChangeTypes, int) overload. + /// + public RecordedMethodCallResult WaitForChanged( + Func? changeType = null, + Func? timeout = null, + [CallerArgumentExpression(nameof(changeType))] + string? changeTypeExpression = null, + [CallerArgumentExpression(nameof(timeout))] + string? timeoutExpression = null) + => Build(nameof(IFileSystemWatcher.WaitForChanged), + ParameterMatcher.From("changeType", changeType, changeTypeExpression), + ParameterMatcher.From("timeout", timeout, timeoutExpression)); + private RecordedProperty Property(string propertyName) { string path = _path; diff --git a/Source/aweXpect.Testably/Recorded/RecordedFileVersionInfoBucket.cs b/Source/aweXpect.Testably/Recorded/RecordedFileVersionInfoBucket.cs index b2777c6..c4fa0ce 100644 --- a/Source/aweXpect.Testably/Recorded/RecordedFileVersionInfoBucket.cs +++ b/Source/aweXpect.Testably/Recorded/RecordedFileVersionInfoBucket.cs @@ -36,7 +36,8 @@ public RecordedFileVersionInfoInstance this[string fileName] /// public RecordedMethodCallResult GetVersionInfo( Func? fileName = null, - [CallerArgumentExpression(nameof(fileName))] string? fileNameExpression = null) + [CallerArgumentExpression(nameof(fileName))] + string? fileNameExpression = null) => Build(nameof(IFileVersionInfoFactory.GetVersionInfo), ParameterMatcher.From("fileName", fileName, fileNameExpression)); diff --git a/Source/aweXpect.Testably/Recorded/RecordedFileVersionInfoInstance.cs b/Source/aweXpect.Testably/Recorded/RecordedFileVersionInfoInstance.cs index 4197cd2..07cc498 100644 --- a/Source/aweXpect.Testably/Recorded/RecordedFileVersionInfoInstance.cs +++ b/Source/aweXpect.Testably/Recorded/RecordedFileVersionInfoInstance.cs @@ -10,9 +10,9 @@ namespace aweXpect.Testably.Recorded; /// public sealed class RecordedFileVersionInfoInstance { - private readonly IThat _subject; - private readonly string _fileName; private readonly string _bucketDescription; + private readonly string _fileName; + private readonly IThat _subject; internal RecordedFileVersionInfoInstance(IThat subject, string fileName) { diff --git a/Source/aweXpect.Testably/Recorded/RecordedPathMethods.cs b/Source/aweXpect.Testably/Recorded/RecordedPathMethods.cs index 28f1f97..5a274a8 100644 --- a/Source/aweXpect.Testably/Recorded/RecordedPathMethods.cs +++ b/Source/aweXpect.Testably/Recorded/RecordedPathMethods.cs @@ -28,12 +28,30 @@ internal RecordedPathMethods(IThat subject) _subject = subject; } + /// Recorded accesses to . + public RecordedProperty AltDirectorySeparatorChar + => new(_subject, s => s.Path, BucketDescription, nameof(IPath.AltDirectorySeparatorChar)); + + /// Recorded accesses to . + public RecordedProperty DirectorySeparatorChar + => new(_subject, s => s.Path, BucketDescription, nameof(IPath.DirectorySeparatorChar)); + + /// Recorded accesses to . + public RecordedProperty PathSeparator + => new(_subject, s => s.Path, BucketDescription, nameof(IPath.PathSeparator)); + + /// Recorded accesses to . + public RecordedProperty VolumeSeparatorChar + => new(_subject, s => s.Path, BucketDescription, nameof(IPath.VolumeSeparatorChar)); + /// Recorded calls to . public RecordedMethodCallResult ChangeExtension( Func? path = null, Func? extension = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null, - [CallerArgumentExpression(nameof(extension))] string? extensionExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null, + [CallerArgumentExpression(nameof(extension))] + string? extensionExpression = null) => Build(nameof(IPath.ChangeExtension), ParameterMatcher.From("path", path, pathExpression), ParameterMatcher.From("extension", extension, extensionExpression)); @@ -45,10 +63,14 @@ public RecordedMethodCallResult Combine( Func? path2 = null, Func? path3 = null, Func? path4 = null, - [CallerArgumentExpression(nameof(path1))] string? path1Expression = null, - [CallerArgumentExpression(nameof(path2))] string? path2Expression = null, - [CallerArgumentExpression(nameof(path3))] string? path3Expression = null, - [CallerArgumentExpression(nameof(path4))] string? path4Expression = null) + [CallerArgumentExpression(nameof(path1))] + string? path1Expression = null, + [CallerArgumentExpression(nameof(path2))] + string? path2Expression = null, + [CallerArgumentExpression(nameof(path3))] + string? path3Expression = null, + [CallerArgumentExpression(nameof(path4))] + string? path4Expression = null) => Build(nameof(IPath.Combine), ParameterMatcher.From("path1", path1, path1Expression), ParameterMatcher.From("path2", path2, path2Expression), @@ -60,42 +82,48 @@ public RecordedMethodCallResult Combine( /// The ReadOnlySpan<char> overload is not mirrored. public RecordedMethodCallResult EndsInDirectorySeparator( Func? path = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null) => Build("EndsInDirectorySeparator", ParameterMatcher.From("path", path, pathExpression)); /// Recorded calls to IPath.Exists(string?). public RecordedMethodCallResult Exists( Func? path = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null) => Build("Exists", ParameterMatcher.From("path", path, pathExpression)); /// Recorded calls to and overloads. public RecordedMethodCallResult GetDirectoryName( Func? path = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null) => Build(nameof(IPath.GetDirectoryName), ParameterMatcher.From("path", path, pathExpression)); /// Recorded calls to and overloads. public RecordedMethodCallResult GetExtension( Func? path = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null) => Build(nameof(IPath.GetExtension), ParameterMatcher.From("path", path, pathExpression)); /// Recorded calls to and overloads. public RecordedMethodCallResult GetFileName( Func? path = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null) => Build(nameof(IPath.GetFileName), ParameterMatcher.From("path", path, pathExpression)); /// Recorded calls to and overloads. public RecordedMethodCallResult GetFileNameWithoutExtension( Func? path = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null) => Build(nameof(IPath.GetFileNameWithoutExtension), ParameterMatcher.From("path", path, pathExpression)); @@ -103,8 +131,10 @@ public RecordedMethodCallResult GetFileNameWithoutExtension( public RecordedMethodCallResult GetFullPath( Func? path = null, Func? basePath = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null, - [CallerArgumentExpression(nameof(basePath))] string? basePathExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null, + [CallerArgumentExpression(nameof(basePath))] + string? basePathExpression = null) => Build(nameof(IPath.GetFullPath), ParameterMatcher.From("path", path, pathExpression), ParameterMatcher.From("basePath", basePath, basePathExpression)); @@ -120,7 +150,8 @@ public RecordedMethodCallResult GetInvalidPathChars() /// Recorded calls to and overloads. public RecordedMethodCallResult GetPathRoot( Func? path = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null) => Build(nameof(IPath.GetPathRoot), ParameterMatcher.From("path", path, pathExpression)); @@ -132,8 +163,10 @@ public RecordedMethodCallResult GetRandomFileName() public RecordedMethodCallResult GetRelativePath( Func? relativeTo = null, Func? path = null, - [CallerArgumentExpression(nameof(relativeTo))] string? relativeToExpression = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null) + [CallerArgumentExpression(nameof(relativeTo))] + string? relativeToExpression = null, + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null) => Build("GetRelativePath", ParameterMatcher.From("relativeTo", relativeTo, relativeToExpression), ParameterMatcher.From("path", path, pathExpression)); @@ -149,21 +182,24 @@ public RecordedMethodCallResult GetTempPath() /// Recorded calls to and overloads. public RecordedMethodCallResult HasExtension( Func? path = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null) => Build(nameof(IPath.HasExtension), ParameterMatcher.From("path", path, pathExpression)); /// Recorded calls to IPath.IsPathFullyQualified(string). public RecordedMethodCallResult IsPathFullyQualified( Func? path = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null) => Build("IsPathFullyQualified", ParameterMatcher.From("path", path, pathExpression)); /// Recorded calls to and overloads. public RecordedMethodCallResult IsPathRooted( Func? path = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null) => Build(nameof(IPath.IsPathRooted), ParameterMatcher.From("path", path, pathExpression)); @@ -178,10 +214,14 @@ public RecordedMethodCallResult Join( Func? path2 = null, Func? path3 = null, Func? path4 = null, - [CallerArgumentExpression(nameof(path1))] string? path1Expression = null, - [CallerArgumentExpression(nameof(path2))] string? path2Expression = null, - [CallerArgumentExpression(nameof(path3))] string? path3Expression = null, - [CallerArgumentExpression(nameof(path4))] string? path4Expression = null) + [CallerArgumentExpression(nameof(path1))] + string? path1Expression = null, + [CallerArgumentExpression(nameof(path2))] + string? path2Expression = null, + [CallerArgumentExpression(nameof(path3))] + string? path3Expression = null, + [CallerArgumentExpression(nameof(path4))] + string? path4Expression = null) => Build("Join", ParameterMatcher.From("path1", path1, path1Expression), ParameterMatcher.From("path2", path2, path2Expression), @@ -193,26 +233,11 @@ public RecordedMethodCallResult Join( /// The ReadOnlySpan<char> overload is not mirrored. public RecordedMethodCallResult TrimEndingDirectorySeparator( Func? path = null, - [CallerArgumentExpression(nameof(path))] string? pathExpression = null) + [CallerArgumentExpression(nameof(path))] + string? pathExpression = null) => Build("TrimEndingDirectorySeparator", ParameterMatcher.From("path", path, pathExpression)); - /// Recorded accesses to . - public RecordedProperty AltDirectorySeparatorChar - => new(_subject, s => s.Path, BucketDescription, nameof(IPath.AltDirectorySeparatorChar)); - - /// Recorded accesses to . - public RecordedProperty DirectorySeparatorChar - => new(_subject, s => s.Path, BucketDescription, nameof(IPath.DirectorySeparatorChar)); - - /// Recorded accesses to . - public RecordedProperty PathSeparator - => new(_subject, s => s.Path, BucketDescription, nameof(IPath.PathSeparator)); - - /// Recorded accesses to . - public RecordedProperty VolumeSeparatorChar - => new(_subject, s => s.Path, BucketDescription, nameof(IPath.VolumeSeparatorChar)); - private RecordedMethodCallResult Build(string methodName, params ParameterMatcher[] matchers) { Quantifier quantifier = new(); diff --git a/Source/aweXpect.Testably/Recorded/RecordedProperty.cs b/Source/aweXpect.Testably/Recorded/RecordedProperty.cs index 0c30a21..2c0c0df 100644 --- a/Source/aweXpect.Testably/Recorded/RecordedProperty.cs +++ b/Source/aweXpect.Testably/Recorded/RecordedProperty.cs @@ -12,10 +12,10 @@ namespace aweXpect.Testably.Recorded; /// public sealed class RecordedProperty { - private readonly IThat _subject; - private readonly Func _bucketSelector; private readonly string _bucketDescription; + private readonly Func _bucketSelector; private readonly string _propertyName; + private readonly IThat _subject; internal RecordedProperty( IThat subject, diff --git a/Source/aweXpect.Testably/Results/DriveResult.cs b/Source/aweXpect.Testably/Results/DriveResult.cs index 1ff95e1..8517244 100644 --- a/Source/aweXpect.Testably/Results/DriveResult.cs +++ b/Source/aweXpect.Testably/Results/DriveResult.cs @@ -30,6 +30,6 @@ internal DriveResult( /// public IThat Which => new ThatSubject( - _expectationBuilder.ForWhich( + _expectationBuilder.ForWhich( _resolver, " which ")); } diff --git a/Tests/aweXpect.Testably.Api.Tests/Expected/aweXpect.Testably_net10.0.txt b/Tests/aweXpect.Testably.Api.Tests/Expected/aweXpect.Testably_net10.0.txt index 3f08b06..c53cc43 100644 --- a/Tests/aweXpect.Testably.Api.Tests/Expected/aweXpect.Testably_net10.0.txt +++ b/Tests/aweXpect.Testably.Api.Tests/Expected/aweXpect.Testably_net10.0.txt @@ -110,19 +110,38 @@ namespace aweXpect.Testably } public static class FileVersionInfoExtensions { + public static aweXpect.Results.StringEqualityTypeResult> HasComments(this aweXpect.Core.IThat source, string? expected) { } public static aweXpect.Results.StringEqualityTypeResult> HasCompanyName(this aweXpect.Core.IThat source, string? expected) { } + public static aweXpect.Results.AndOrResult> HasFileBuildPart(this aweXpect.Core.IThat source, int expected) { } public static aweXpect.Results.StringEqualityTypeResult> HasFileDescription(this aweXpect.Core.IThat source, string? expected) { } + public static aweXpect.Results.AndOrResult> HasFileMajorPart(this aweXpect.Core.IThat source, int expected) { } + public static aweXpect.Results.AndOrResult> HasFileMinorPart(this aweXpect.Core.IThat source, int expected) { } + public static aweXpect.Results.StringEqualityTypeResult> HasFileName(this aweXpect.Core.IThat source, string? expected) { } + public static aweXpect.Results.AndOrResult> HasFilePrivatePart(this aweXpect.Core.IThat source, int expected) { } public static aweXpect.Results.StringEqualityTypeResult> HasFileVersion(this aweXpect.Core.IThat source, string? expected) { } + public static aweXpect.Results.StringEqualityTypeResult> HasInternalName(this aweXpect.Core.IThat source, string? expected) { } public static aweXpect.Results.StringEqualityTypeResult> HasLanguage(this aweXpect.Core.IThat source, string? expected) { } + public static aweXpect.Results.StringEqualityTypeResult> HasLegalCopyright(this aweXpect.Core.IThat source, string? expected) { } + public static aweXpect.Results.StringEqualityTypeResult> HasLegalTrademarks(this aweXpect.Core.IThat source, string? expected) { } public static aweXpect.Results.StringEqualityTypeResult> HasOriginalFilename(this aweXpect.Core.IThat source, string? expected) { } + public static aweXpect.Results.StringEqualityTypeResult> HasPrivateBuild(this aweXpect.Core.IThat source, string? expected) { } + public static aweXpect.Results.AndOrResult> HasProductBuildPart(this aweXpect.Core.IThat source, int expected) { } + public static aweXpect.Results.AndOrResult> HasProductMajorPart(this aweXpect.Core.IThat source, int expected) { } + public static aweXpect.Results.AndOrResult> HasProductMinorPart(this aweXpect.Core.IThat source, int expected) { } public static aweXpect.Results.StringEqualityTypeResult> HasProductName(this aweXpect.Core.IThat source, string? expected) { } + public static aweXpect.Results.AndOrResult> HasProductPrivatePart(this aweXpect.Core.IThat source, int expected) { } public static aweXpect.Results.StringEqualityTypeResult> HasProductVersion(this aweXpect.Core.IThat source, string? expected) { } + public static aweXpect.Results.StringEqualityTypeResult> HasSpecialBuild(this aweXpect.Core.IThat source, string? expected) { } public static aweXpect.Results.AndOrResult> IsDebug(this aweXpect.Core.IThat source) { } public static aweXpect.Results.AndOrResult> IsNotDebug(this aweXpect.Core.IThat source) { } public static aweXpect.Results.AndOrResult> IsNotPatched(this aweXpect.Core.IThat source) { } public static aweXpect.Results.AndOrResult> IsNotPreRelease(this aweXpect.Core.IThat source) { } + public static aweXpect.Results.AndOrResult> IsNotPrivateBuild(this aweXpect.Core.IThat source) { } + public static aweXpect.Results.AndOrResult> IsNotSpecialBuild(this aweXpect.Core.IThat source) { } public static aweXpect.Results.AndOrResult> IsPatched(this aweXpect.Core.IThat source) { } public static aweXpect.Results.AndOrResult> IsPreRelease(this aweXpect.Core.IThat source) { } + public static aweXpect.Results.AndOrResult> IsPrivateBuild(this aweXpect.Core.IThat source) { } + public static aweXpect.Results.AndOrResult> IsSpecialBuild(this aweXpect.Core.IThat source) { } } public static class StatisticsExtensions { diff --git a/Tests/aweXpect.Testably.Api.Tests/Expected/aweXpect.Testably_net8.0.txt b/Tests/aweXpect.Testably.Api.Tests/Expected/aweXpect.Testably_net8.0.txt index d0289e3..05cbfd0 100644 --- a/Tests/aweXpect.Testably.Api.Tests/Expected/aweXpect.Testably_net8.0.txt +++ b/Tests/aweXpect.Testably.Api.Tests/Expected/aweXpect.Testably_net8.0.txt @@ -100,19 +100,38 @@ namespace aweXpect.Testably } public static class FileVersionInfoExtensions { + public static aweXpect.Results.StringEqualityTypeResult> HasComments(this aweXpect.Core.IThat source, string? expected) { } public static aweXpect.Results.StringEqualityTypeResult> HasCompanyName(this aweXpect.Core.IThat source, string? expected) { } + public static aweXpect.Results.AndOrResult> HasFileBuildPart(this aweXpect.Core.IThat source, int expected) { } public static aweXpect.Results.StringEqualityTypeResult> HasFileDescription(this aweXpect.Core.IThat source, string? expected) { } + public static aweXpect.Results.AndOrResult> HasFileMajorPart(this aweXpect.Core.IThat source, int expected) { } + public static aweXpect.Results.AndOrResult> HasFileMinorPart(this aweXpect.Core.IThat source, int expected) { } + public static aweXpect.Results.StringEqualityTypeResult> HasFileName(this aweXpect.Core.IThat source, string? expected) { } + public static aweXpect.Results.AndOrResult> HasFilePrivatePart(this aweXpect.Core.IThat source, int expected) { } public static aweXpect.Results.StringEqualityTypeResult> HasFileVersion(this aweXpect.Core.IThat source, string? expected) { } + public static aweXpect.Results.StringEqualityTypeResult> HasInternalName(this aweXpect.Core.IThat source, string? expected) { } public static aweXpect.Results.StringEqualityTypeResult> HasLanguage(this aweXpect.Core.IThat source, string? expected) { } + public static aweXpect.Results.StringEqualityTypeResult> HasLegalCopyright(this aweXpect.Core.IThat source, string? expected) { } + public static aweXpect.Results.StringEqualityTypeResult> HasLegalTrademarks(this aweXpect.Core.IThat source, string? expected) { } public static aweXpect.Results.StringEqualityTypeResult> HasOriginalFilename(this aweXpect.Core.IThat source, string? expected) { } + public static aweXpect.Results.StringEqualityTypeResult> HasPrivateBuild(this aweXpect.Core.IThat source, string? expected) { } + public static aweXpect.Results.AndOrResult> HasProductBuildPart(this aweXpect.Core.IThat source, int expected) { } + public static aweXpect.Results.AndOrResult> HasProductMajorPart(this aweXpect.Core.IThat source, int expected) { } + public static aweXpect.Results.AndOrResult> HasProductMinorPart(this aweXpect.Core.IThat source, int expected) { } public static aweXpect.Results.StringEqualityTypeResult> HasProductName(this aweXpect.Core.IThat source, string? expected) { } + public static aweXpect.Results.AndOrResult> HasProductPrivatePart(this aweXpect.Core.IThat source, int expected) { } public static aweXpect.Results.StringEqualityTypeResult> HasProductVersion(this aweXpect.Core.IThat source, string? expected) { } + public static aweXpect.Results.StringEqualityTypeResult> HasSpecialBuild(this aweXpect.Core.IThat source, string? expected) { } public static aweXpect.Results.AndOrResult> IsDebug(this aweXpect.Core.IThat source) { } public static aweXpect.Results.AndOrResult> IsNotDebug(this aweXpect.Core.IThat source) { } public static aweXpect.Results.AndOrResult> IsNotPatched(this aweXpect.Core.IThat source) { } public static aweXpect.Results.AndOrResult> IsNotPreRelease(this aweXpect.Core.IThat source) { } + public static aweXpect.Results.AndOrResult> IsNotPrivateBuild(this aweXpect.Core.IThat source) { } + public static aweXpect.Results.AndOrResult> IsNotSpecialBuild(this aweXpect.Core.IThat source) { } public static aweXpect.Results.AndOrResult> IsPatched(this aweXpect.Core.IThat source) { } public static aweXpect.Results.AndOrResult> IsPreRelease(this aweXpect.Core.IThat source) { } + public static aweXpect.Results.AndOrResult> IsPrivateBuild(this aweXpect.Core.IThat source) { } + public static aweXpect.Results.AndOrResult> IsSpecialBuild(this aweXpect.Core.IThat source) { } } public static class StatisticsExtensions { diff --git a/Tests/aweXpect.Testably.Api.Tests/Expected/aweXpect.Testably_netstandard2.0.txt b/Tests/aweXpect.Testably.Api.Tests/Expected/aweXpect.Testably_netstandard2.0.txt index 409a211..5057991 100644 --- a/Tests/aweXpect.Testably.Api.Tests/Expected/aweXpect.Testably_netstandard2.0.txt +++ b/Tests/aweXpect.Testably.Api.Tests/Expected/aweXpect.Testably_netstandard2.0.txt @@ -100,19 +100,38 @@ namespace aweXpect.Testably } public static class FileVersionInfoExtensions { + public static aweXpect.Results.StringEqualityTypeResult> HasComments(this aweXpect.Core.IThat source, string? expected) { } public static aweXpect.Results.StringEqualityTypeResult> HasCompanyName(this aweXpect.Core.IThat source, string? expected) { } + public static aweXpect.Results.AndOrResult> HasFileBuildPart(this aweXpect.Core.IThat source, int expected) { } public static aweXpect.Results.StringEqualityTypeResult> HasFileDescription(this aweXpect.Core.IThat source, string? expected) { } + public static aweXpect.Results.AndOrResult> HasFileMajorPart(this aweXpect.Core.IThat source, int expected) { } + public static aweXpect.Results.AndOrResult> HasFileMinorPart(this aweXpect.Core.IThat source, int expected) { } + public static aweXpect.Results.StringEqualityTypeResult> HasFileName(this aweXpect.Core.IThat source, string? expected) { } + public static aweXpect.Results.AndOrResult> HasFilePrivatePart(this aweXpect.Core.IThat source, int expected) { } public static aweXpect.Results.StringEqualityTypeResult> HasFileVersion(this aweXpect.Core.IThat source, string? expected) { } + public static aweXpect.Results.StringEqualityTypeResult> HasInternalName(this aweXpect.Core.IThat source, string? expected) { } public static aweXpect.Results.StringEqualityTypeResult> HasLanguage(this aweXpect.Core.IThat source, string? expected) { } + public static aweXpect.Results.StringEqualityTypeResult> HasLegalCopyright(this aweXpect.Core.IThat source, string? expected) { } + public static aweXpect.Results.StringEqualityTypeResult> HasLegalTrademarks(this aweXpect.Core.IThat source, string? expected) { } public static aweXpect.Results.StringEqualityTypeResult> HasOriginalFilename(this aweXpect.Core.IThat source, string? expected) { } + public static aweXpect.Results.StringEqualityTypeResult> HasPrivateBuild(this aweXpect.Core.IThat source, string? expected) { } + public static aweXpect.Results.AndOrResult> HasProductBuildPart(this aweXpect.Core.IThat source, int expected) { } + public static aweXpect.Results.AndOrResult> HasProductMajorPart(this aweXpect.Core.IThat source, int expected) { } + public static aweXpect.Results.AndOrResult> HasProductMinorPart(this aweXpect.Core.IThat source, int expected) { } public static aweXpect.Results.StringEqualityTypeResult> HasProductName(this aweXpect.Core.IThat source, string? expected) { } + public static aweXpect.Results.AndOrResult> HasProductPrivatePart(this aweXpect.Core.IThat source, int expected) { } public static aweXpect.Results.StringEqualityTypeResult> HasProductVersion(this aweXpect.Core.IThat source, string? expected) { } + public static aweXpect.Results.StringEqualityTypeResult> HasSpecialBuild(this aweXpect.Core.IThat source, string? expected) { } public static aweXpect.Results.AndOrResult> IsDebug(this aweXpect.Core.IThat source) { } public static aweXpect.Results.AndOrResult> IsNotDebug(this aweXpect.Core.IThat source) { } public static aweXpect.Results.AndOrResult> IsNotPatched(this aweXpect.Core.IThat source) { } public static aweXpect.Results.AndOrResult> IsNotPreRelease(this aweXpect.Core.IThat source) { } + public static aweXpect.Results.AndOrResult> IsNotPrivateBuild(this aweXpect.Core.IThat source) { } + public static aweXpect.Results.AndOrResult> IsNotSpecialBuild(this aweXpect.Core.IThat source) { } public static aweXpect.Results.AndOrResult> IsPatched(this aweXpect.Core.IThat source) { } public static aweXpect.Results.AndOrResult> IsPreRelease(this aweXpect.Core.IThat source) { } + public static aweXpect.Results.AndOrResult> IsPrivateBuild(this aweXpect.Core.IThat source) { } + public static aweXpect.Results.AndOrResult> IsSpecialBuild(this aweXpect.Core.IThat source) { } } public static class StatisticsExtensions { diff --git a/Tests/aweXpect.Testably.Tests/FileSystem.TriggeredNotification.Tests.cs b/Tests/aweXpect.Testably.Tests/FileSystem.TriggeredNotification.Tests.cs index 4217ab2..35c5b28 100644 --- a/Tests/aweXpect.Testably.Tests/FileSystem.TriggeredNotification.Tests.cs +++ b/Tests/aweXpect.Testably.Tests/FileSystem.TriggeredNotification.Tests.cs @@ -1,4 +1,3 @@ -using System.Collections.Generic; using System.IO; using aweXpect.Core; using Testably.Abstractions.Testing; diff --git a/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasComments.Tests.cs b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasComments.Tests.cs index d9ac903..3ce0e87 100644 --- a/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasComments.Tests.cs +++ b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasComments.Tests.cs @@ -9,6 +9,25 @@ public sealed class HasComments { public sealed class Tests { + [Fact] + public async Task ShouldSupportAndComposition() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v + .SetComments("Acme comment") + .SetCompanyName("Acme")); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).HasComments("Acme comment").And.HasCompanyName("Acme"); + } + + await That(Act).DoesNotThrow(); + } + [Fact] public async Task WhenCommentsDiffers_ShouldFail() { @@ -51,25 +70,6 @@ async Task Act() await That(Act).DoesNotThrow(); } - - [Fact] - public async Task ShouldSupportAndComposition() - { - MockFileSystem fileSystem = new(); - fileSystem.WithFileVersionInfo("*.dll", v => v - .SetComments("Acme comment") - .SetCompanyName("Acme")); - // ReSharper disable once MethodHasAsyncOverload - fileSystem.File.WriteAllText("Acme.dll", ""); - IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); - - async Task Act() - { - await That(info).HasComments("Acme comment").And.HasCompanyName("Acme"); - } - - await That(Act).DoesNotThrow(); - } } } } diff --git a/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasCompanyName.Tests.cs b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasCompanyName.Tests.cs index 1a85e28..97356f6 100644 --- a/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasCompanyName.Tests.cs +++ b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasCompanyName.Tests.cs @@ -9,6 +9,25 @@ public sealed class HasCompanyName { public sealed class Tests { + [Fact] + public async Task ShouldSupportAndComposition() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v + .SetCompanyName("Acme") + .SetProductName("Anvil")); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).HasCompanyName("Acme").And.HasProductName("Anvil"); + } + + await That(Act).DoesNotThrow(); + } + [Fact] public async Task WhenCompanyNameDiffers_ShouldFail() { @@ -51,25 +70,6 @@ async Task Act() await That(Act).DoesNotThrow(); } - - [Fact] - public async Task ShouldSupportAndComposition() - { - MockFileSystem fileSystem = new(); - fileSystem.WithFileVersionInfo("*.dll", v => v - .SetCompanyName("Acme") - .SetProductName("Anvil")); - // ReSharper disable once MethodHasAsyncOverload - fileSystem.File.WriteAllText("Acme.dll", ""); - IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); - - async Task Act() - { - await That(info).HasCompanyName("Acme").And.HasProductName("Anvil"); - } - - await That(Act).DoesNotThrow(); - } } } } diff --git a/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasFileBuildPart.Tests.cs b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasFileBuildPart.Tests.cs index 4d67fc7..a96bc84 100644 --- a/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasFileBuildPart.Tests.cs +++ b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasFileBuildPart.Tests.cs @@ -10,17 +10,19 @@ public sealed class HasFileBuildPart public sealed class Tests { [Fact] - public async Task WhenFileBuildPartMatches_ShouldSucceed() + public async Task ShouldSupportAndComposition() { MockFileSystem fileSystem = new(); - fileSystem.WithFileVersionInfo("*.dll", v => v.SetFileVersion("1.2.3.4")); + fileSystem.WithFileVersionInfo("*.dll", v => v + .SetFileVersion("1.2.3.4") + .SetCompanyName("Acme")); // ReSharper disable once MethodHasAsyncOverload fileSystem.File.WriteAllText("Acme.dll", ""); IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); async Task Act() { - await That(info).HasFileBuildPart(3); + await That(info).HasFileBuildPart(3).And.HasCompanyName("Acme"); } await That(Act).DoesNotThrow(); @@ -49,19 +51,17 @@ but it was 3 } [Fact] - public async Task ShouldSupportAndComposition() + public async Task WhenFileBuildPartMatches_ShouldSucceed() { MockFileSystem fileSystem = new(); - fileSystem.WithFileVersionInfo("*.dll", v => v - .SetFileVersion("1.2.3.4") - .SetCompanyName("Acme")); + fileSystem.WithFileVersionInfo("*.dll", v => v.SetFileVersion("1.2.3.4")); // ReSharper disable once MethodHasAsyncOverload fileSystem.File.WriteAllText("Acme.dll", ""); IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); async Task Act() { - await That(info).HasFileBuildPart(3).And.HasCompanyName("Acme"); + await That(info).HasFileBuildPart(3); } await That(Act).DoesNotThrow(); diff --git a/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasFileDescription.Tests.cs b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasFileDescription.Tests.cs index 6a7a2df..c389ce1 100644 --- a/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasFileDescription.Tests.cs +++ b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasFileDescription.Tests.cs @@ -9,6 +9,25 @@ public sealed class HasFileDescription { public sealed class Tests { + [Fact] + public async Task ShouldSupportAndComposition() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v + .SetFileDescription("Acme runtime") + .SetCompanyName("Acme")); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).HasFileDescription("Acme runtime").And.HasCompanyName("Acme"); + } + + await That(Act).DoesNotThrow(); + } + [Fact] public async Task WhenFileDescriptionDiffers_ShouldFail() { @@ -51,25 +70,6 @@ async Task Act() await That(Act).DoesNotThrow(); } - - [Fact] - public async Task ShouldSupportAndComposition() - { - MockFileSystem fileSystem = new(); - fileSystem.WithFileVersionInfo("*.dll", v => v - .SetFileDescription("Acme runtime") - .SetCompanyName("Acme")); - // ReSharper disable once MethodHasAsyncOverload - fileSystem.File.WriteAllText("Acme.dll", ""); - IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); - - async Task Act() - { - await That(info).HasFileDescription("Acme runtime").And.HasCompanyName("Acme"); - } - - await That(Act).DoesNotThrow(); - } } } } diff --git a/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasFileMajorPart.Tests.cs b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasFileMajorPart.Tests.cs index b6275c1..33ac01c 100644 --- a/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasFileMajorPart.Tests.cs +++ b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasFileMajorPart.Tests.cs @@ -10,17 +10,19 @@ public sealed class HasFileMajorPart public sealed class Tests { [Fact] - public async Task WhenFileMajorPartMatches_ShouldSucceed() + public async Task ShouldSupportAndComposition() { MockFileSystem fileSystem = new(); - fileSystem.WithFileVersionInfo("*.dll", v => v.SetFileVersion("1.2.3.4")); + fileSystem.WithFileVersionInfo("*.dll", v => v + .SetFileVersion("1.2.3.4") + .SetCompanyName("Acme")); // ReSharper disable once MethodHasAsyncOverload fileSystem.File.WriteAllText("Acme.dll", ""); IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); async Task Act() { - await That(info).HasFileMajorPart(1); + await That(info).HasFileMajorPart(1).And.HasCompanyName("Acme"); } await That(Act).DoesNotThrow(); @@ -49,19 +51,17 @@ but it was 1 } [Fact] - public async Task ShouldSupportAndComposition() + public async Task WhenFileMajorPartMatches_ShouldSucceed() { MockFileSystem fileSystem = new(); - fileSystem.WithFileVersionInfo("*.dll", v => v - .SetFileVersion("1.2.3.4") - .SetCompanyName("Acme")); + fileSystem.WithFileVersionInfo("*.dll", v => v.SetFileVersion("1.2.3.4")); // ReSharper disable once MethodHasAsyncOverload fileSystem.File.WriteAllText("Acme.dll", ""); IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); async Task Act() { - await That(info).HasFileMajorPart(1).And.HasCompanyName("Acme"); + await That(info).HasFileMajorPart(1); } await That(Act).DoesNotThrow(); diff --git a/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasFileMinorPart.Tests.cs b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasFileMinorPart.Tests.cs index 0a24ba9..b677ca3 100644 --- a/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasFileMinorPart.Tests.cs +++ b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasFileMinorPart.Tests.cs @@ -10,17 +10,19 @@ public sealed class HasFileMinorPart public sealed class Tests { [Fact] - public async Task WhenFileMinorPartMatches_ShouldSucceed() + public async Task ShouldSupportAndComposition() { MockFileSystem fileSystem = new(); - fileSystem.WithFileVersionInfo("*.dll", v => v.SetFileVersion("1.2.3.4")); + fileSystem.WithFileVersionInfo("*.dll", v => v + .SetFileVersion("1.2.3.4") + .SetCompanyName("Acme")); // ReSharper disable once MethodHasAsyncOverload fileSystem.File.WriteAllText("Acme.dll", ""); IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); async Task Act() { - await That(info).HasFileMinorPart(2); + await That(info).HasFileMinorPart(2).And.HasCompanyName("Acme"); } await That(Act).DoesNotThrow(); @@ -49,19 +51,17 @@ but it was 2 } [Fact] - public async Task ShouldSupportAndComposition() + public async Task WhenFileMinorPartMatches_ShouldSucceed() { MockFileSystem fileSystem = new(); - fileSystem.WithFileVersionInfo("*.dll", v => v - .SetFileVersion("1.2.3.4") - .SetCompanyName("Acme")); + fileSystem.WithFileVersionInfo("*.dll", v => v.SetFileVersion("1.2.3.4")); // ReSharper disable once MethodHasAsyncOverload fileSystem.File.WriteAllText("Acme.dll", ""); IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); async Task Act() { - await That(info).HasFileMinorPart(2).And.HasCompanyName("Acme"); + await That(info).HasFileMinorPart(2); } await That(Act).DoesNotThrow(); diff --git a/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasFileName.Tests.cs b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasFileName.Tests.cs index a1d874b..8ba896c 100644 --- a/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasFileName.Tests.cs +++ b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasFileName.Tests.cs @@ -10,7 +10,7 @@ public sealed class HasFileName public sealed class Tests { [Fact] - public async Task WhenFileNameMatches_ShouldSucceed() + public async Task ShouldSupportAndComposition() { MockFileSystem fileSystem = new(); fileSystem.WithFileVersionInfo("*.dll", v => v.SetCompanyName("Acme")); @@ -20,7 +20,7 @@ public async Task WhenFileNameMatches_ShouldSucceed() async Task Act() { - await That(info).HasFileName(info.FileName); + await That(info).HasFileName(info.FileName).And.HasCompanyName("Acme"); } await That(Act).DoesNotThrow(); @@ -45,7 +45,7 @@ await That(Act).ThrowsException() } [Fact] - public async Task ShouldSupportAndComposition() + public async Task WhenFileNameMatches_ShouldSucceed() { MockFileSystem fileSystem = new(); fileSystem.WithFileVersionInfo("*.dll", v => v.SetCompanyName("Acme")); @@ -55,7 +55,7 @@ public async Task ShouldSupportAndComposition() async Task Act() { - await That(info).HasFileName(info.FileName).And.HasCompanyName("Acme"); + await That(info).HasFileName(info.FileName); } await That(Act).DoesNotThrow(); diff --git a/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasFilePrivatePart.Tests.cs b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasFilePrivatePart.Tests.cs index 0dde353..293bbaa 100644 --- a/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasFilePrivatePart.Tests.cs +++ b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasFilePrivatePart.Tests.cs @@ -10,17 +10,19 @@ public sealed class HasFilePrivatePart public sealed class Tests { [Fact] - public async Task WhenFilePrivatePartMatches_ShouldSucceed() + public async Task ShouldSupportAndComposition() { MockFileSystem fileSystem = new(); - fileSystem.WithFileVersionInfo("*.dll", v => v.SetFileVersion("1.2.3.4")); + fileSystem.WithFileVersionInfo("*.dll", v => v + .SetFileVersion("1.2.3.4") + .SetCompanyName("Acme")); // ReSharper disable once MethodHasAsyncOverload fileSystem.File.WriteAllText("Acme.dll", ""); IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); async Task Act() { - await That(info).HasFilePrivatePart(4); + await That(info).HasFilePrivatePart(4).And.HasCompanyName("Acme"); } await That(Act).DoesNotThrow(); @@ -49,19 +51,17 @@ but it was 4 } [Fact] - public async Task ShouldSupportAndComposition() + public async Task WhenFilePrivatePartMatches_ShouldSucceed() { MockFileSystem fileSystem = new(); - fileSystem.WithFileVersionInfo("*.dll", v => v - .SetFileVersion("1.2.3.4") - .SetCompanyName("Acme")); + fileSystem.WithFileVersionInfo("*.dll", v => v.SetFileVersion("1.2.3.4")); // ReSharper disable once MethodHasAsyncOverload fileSystem.File.WriteAllText("Acme.dll", ""); IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); async Task Act() { - await That(info).HasFilePrivatePart(4).And.HasCompanyName("Acme"); + await That(info).HasFilePrivatePart(4); } await That(Act).DoesNotThrow(); diff --git a/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasFileVersion.Tests.cs b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasFileVersion.Tests.cs index d17520d..42d105a 100644 --- a/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasFileVersion.Tests.cs +++ b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasFileVersion.Tests.cs @@ -9,6 +9,25 @@ public sealed class HasFileVersion { public sealed class Tests { + [Fact] + public async Task ShouldSupportAndComposition() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v + .SetFileVersion("1.2.3.4") + .SetProductVersion("1.2")); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).HasFileVersion("1.2.3.4").And.HasProductVersion("1.2"); + } + + await That(Act).DoesNotThrow(); + } + [Fact] public async Task WhenFileVersionDiffers_ShouldFail() { @@ -51,25 +70,6 @@ async Task Act() await That(Act).DoesNotThrow(); } - - [Fact] - public async Task ShouldSupportAndComposition() - { - MockFileSystem fileSystem = new(); - fileSystem.WithFileVersionInfo("*.dll", v => v - .SetFileVersion("1.2.3.4") - .SetProductVersion("1.2")); - // ReSharper disable once MethodHasAsyncOverload - fileSystem.File.WriteAllText("Acme.dll", ""); - IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); - - async Task Act() - { - await That(info).HasFileVersion("1.2.3.4").And.HasProductVersion("1.2"); - } - - await That(Act).DoesNotThrow(); - } } } } diff --git a/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasInternalName.Tests.cs b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasInternalName.Tests.cs index bb2e22d..6c31071 100644 --- a/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasInternalName.Tests.cs +++ b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasInternalName.Tests.cs @@ -9,6 +9,25 @@ public sealed class HasInternalName { public sealed class Tests { + [Fact] + public async Task ShouldSupportAndComposition() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v + .SetInternalName("AcmeInternal") + .SetCompanyName("Acme")); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).HasInternalName("AcmeInternal").And.HasCompanyName("Acme"); + } + + await That(Act).DoesNotThrow(); + } + [Fact] public async Task WhenInternalNameDiffers_ShouldFail() { @@ -51,25 +70,6 @@ async Task Act() await That(Act).DoesNotThrow(); } - - [Fact] - public async Task ShouldSupportAndComposition() - { - MockFileSystem fileSystem = new(); - fileSystem.WithFileVersionInfo("*.dll", v => v - .SetInternalName("AcmeInternal") - .SetCompanyName("Acme")); - // ReSharper disable once MethodHasAsyncOverload - fileSystem.File.WriteAllText("Acme.dll", ""); - IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); - - async Task Act() - { - await That(info).HasInternalName("AcmeInternal").And.HasCompanyName("Acme"); - } - - await That(Act).DoesNotThrow(); - } } } } diff --git a/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasLanguage.Tests.cs b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasLanguage.Tests.cs index 9a74e32..aa80309 100644 --- a/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasLanguage.Tests.cs +++ b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasLanguage.Tests.cs @@ -9,6 +9,25 @@ public sealed class HasLanguage { public sealed class Tests { + [Fact] + public async Task ShouldSupportAndComposition() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v + .SetLanguage("English (United States)") + .SetCompanyName("Acme")); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).HasLanguage("English (United States)").And.HasCompanyName("Acme"); + } + + await That(Act).DoesNotThrow(); + } + [Fact] public async Task WhenLanguageDiffers_ShouldFail() { @@ -51,25 +70,6 @@ async Task Act() await That(Act).DoesNotThrow(); } - - [Fact] - public async Task ShouldSupportAndComposition() - { - MockFileSystem fileSystem = new(); - fileSystem.WithFileVersionInfo("*.dll", v => v - .SetLanguage("English (United States)") - .SetCompanyName("Acme")); - // ReSharper disable once MethodHasAsyncOverload - fileSystem.File.WriteAllText("Acme.dll", ""); - IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); - - async Task Act() - { - await That(info).HasLanguage("English (United States)").And.HasCompanyName("Acme"); - } - - await That(Act).DoesNotThrow(); - } } } } diff --git a/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasLegalCopyright.Tests.cs b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasLegalCopyright.Tests.cs index 04ab6de..881c76a 100644 --- a/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasLegalCopyright.Tests.cs +++ b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasLegalCopyright.Tests.cs @@ -9,6 +9,25 @@ public sealed class HasLegalCopyright { public sealed class Tests { + [Fact] + public async Task ShouldSupportAndComposition() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v + .SetLegalCopyright("Acme (c)") + .SetCompanyName("Acme")); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).HasLegalCopyright("Acme (c)").And.HasCompanyName("Acme"); + } + + await That(Act).DoesNotThrow(); + } + [Fact] public async Task WhenLegalCopyrightDiffers_ShouldFail() { @@ -51,25 +70,6 @@ async Task Act() await That(Act).DoesNotThrow(); } - - [Fact] - public async Task ShouldSupportAndComposition() - { - MockFileSystem fileSystem = new(); - fileSystem.WithFileVersionInfo("*.dll", v => v - .SetLegalCopyright("Acme (c)") - .SetCompanyName("Acme")); - // ReSharper disable once MethodHasAsyncOverload - fileSystem.File.WriteAllText("Acme.dll", ""); - IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); - - async Task Act() - { - await That(info).HasLegalCopyright("Acme (c)").And.HasCompanyName("Acme"); - } - - await That(Act).DoesNotThrow(); - } } } } diff --git a/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasLegalTrademarks.Tests.cs b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasLegalTrademarks.Tests.cs index 2ad7a9c..d0629b6 100644 --- a/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasLegalTrademarks.Tests.cs +++ b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasLegalTrademarks.Tests.cs @@ -9,6 +9,25 @@ public sealed class HasLegalTrademarks { public sealed class Tests { + [Fact] + public async Task ShouldSupportAndComposition() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v + .SetLegalTrademarks("Acme (TM)") + .SetCompanyName("Acme")); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).HasLegalTrademarks("Acme (TM)").And.HasCompanyName("Acme"); + } + + await That(Act).DoesNotThrow(); + } + [Fact] public async Task WhenLegalTrademarksDiffers_ShouldFail() { @@ -51,25 +70,6 @@ async Task Act() await That(Act).DoesNotThrow(); } - - [Fact] - public async Task ShouldSupportAndComposition() - { - MockFileSystem fileSystem = new(); - fileSystem.WithFileVersionInfo("*.dll", v => v - .SetLegalTrademarks("Acme (TM)") - .SetCompanyName("Acme")); - // ReSharper disable once MethodHasAsyncOverload - fileSystem.File.WriteAllText("Acme.dll", ""); - IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); - - async Task Act() - { - await That(info).HasLegalTrademarks("Acme (TM)").And.HasCompanyName("Acme"); - } - - await That(Act).DoesNotThrow(); - } } } } diff --git a/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasOriginalFilename.Tests.cs b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasOriginalFilename.Tests.cs index 2962519..dc7e43b 100644 --- a/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasOriginalFilename.Tests.cs +++ b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasOriginalFilename.Tests.cs @@ -9,6 +9,25 @@ public sealed class HasOriginalFilename { public sealed class Tests { + [Fact] + public async Task ShouldSupportAndComposition() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v + .SetOriginalFilename("Acme.dll") + .SetCompanyName("Acme")); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).HasOriginalFilename("Acme.dll").And.HasCompanyName("Acme"); + } + + await That(Act).DoesNotThrow(); + } + [Fact] public async Task WhenOriginalFilenameDiffers_ShouldFail() { @@ -51,25 +70,6 @@ async Task Act() await That(Act).DoesNotThrow(); } - - [Fact] - public async Task ShouldSupportAndComposition() - { - MockFileSystem fileSystem = new(); - fileSystem.WithFileVersionInfo("*.dll", v => v - .SetOriginalFilename("Acme.dll") - .SetCompanyName("Acme")); - // ReSharper disable once MethodHasAsyncOverload - fileSystem.File.WriteAllText("Acme.dll", ""); - IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); - - async Task Act() - { - await That(info).HasOriginalFilename("Acme.dll").And.HasCompanyName("Acme"); - } - - await That(Act).DoesNotThrow(); - } } } } diff --git a/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasPrivateBuild.Tests.cs b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasPrivateBuild.Tests.cs index c6d6940..d00018c 100644 --- a/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasPrivateBuild.Tests.cs +++ b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasPrivateBuild.Tests.cs @@ -9,6 +9,25 @@ public sealed class HasPrivateBuild { public sealed class Tests { + [Fact] + public async Task ShouldSupportAndComposition() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v + .SetPrivateBuild("Acme") + .SetCompanyName("Acme")); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).HasPrivateBuild("Acme").And.HasCompanyName("Acme"); + } + + await That(Act).DoesNotThrow(); + } + [Fact] public async Task WhenPrivateBuildDiffers_ShouldFail() { @@ -51,25 +70,6 @@ async Task Act() await That(Act).DoesNotThrow(); } - - [Fact] - public async Task ShouldSupportAndComposition() - { - MockFileSystem fileSystem = new(); - fileSystem.WithFileVersionInfo("*.dll", v => v - .SetPrivateBuild("Acme") - .SetCompanyName("Acme")); - // ReSharper disable once MethodHasAsyncOverload - fileSystem.File.WriteAllText("Acme.dll", ""); - IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); - - async Task Act() - { - await That(info).HasPrivateBuild("Acme").And.HasCompanyName("Acme"); - } - - await That(Act).DoesNotThrow(); - } } } } diff --git a/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasProductBuildPart.Tests.cs b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasProductBuildPart.Tests.cs index 24a9fc4..c9edb55 100644 --- a/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasProductBuildPart.Tests.cs +++ b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasProductBuildPart.Tests.cs @@ -10,17 +10,19 @@ public sealed class HasProductBuildPart public sealed class Tests { [Fact] - public async Task WhenProductBuildPartMatches_ShouldSucceed() + public async Task ShouldSupportAndComposition() { MockFileSystem fileSystem = new(); - fileSystem.WithFileVersionInfo("*.dll", v => v.SetProductVersion("5.6.7.8")); + fileSystem.WithFileVersionInfo("*.dll", v => v + .SetProductVersion("5.6.7.8") + .SetCompanyName("Acme")); // ReSharper disable once MethodHasAsyncOverload fileSystem.File.WriteAllText("Acme.dll", ""); IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); async Task Act() { - await That(info).HasProductBuildPart(7); + await That(info).HasProductBuildPart(7).And.HasCompanyName("Acme"); } await That(Act).DoesNotThrow(); @@ -49,19 +51,17 @@ but it was 7 } [Fact] - public async Task ShouldSupportAndComposition() + public async Task WhenProductBuildPartMatches_ShouldSucceed() { MockFileSystem fileSystem = new(); - fileSystem.WithFileVersionInfo("*.dll", v => v - .SetProductVersion("5.6.7.8") - .SetCompanyName("Acme")); + fileSystem.WithFileVersionInfo("*.dll", v => v.SetProductVersion("5.6.7.8")); // ReSharper disable once MethodHasAsyncOverload fileSystem.File.WriteAllText("Acme.dll", ""); IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); async Task Act() { - await That(info).HasProductBuildPart(7).And.HasCompanyName("Acme"); + await That(info).HasProductBuildPart(7); } await That(Act).DoesNotThrow(); diff --git a/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasProductMajorPart.Tests.cs b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasProductMajorPart.Tests.cs index 12181d7..9c1dc39 100644 --- a/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasProductMajorPart.Tests.cs +++ b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasProductMajorPart.Tests.cs @@ -10,17 +10,19 @@ public sealed class HasProductMajorPart public sealed class Tests { [Fact] - public async Task WhenProductMajorPartMatches_ShouldSucceed() + public async Task ShouldSupportAndComposition() { MockFileSystem fileSystem = new(); - fileSystem.WithFileVersionInfo("*.dll", v => v.SetProductVersion("5.6.7.8")); + fileSystem.WithFileVersionInfo("*.dll", v => v + .SetProductVersion("5.6.7.8") + .SetCompanyName("Acme")); // ReSharper disable once MethodHasAsyncOverload fileSystem.File.WriteAllText("Acme.dll", ""); IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); async Task Act() { - await That(info).HasProductMajorPart(5); + await That(info).HasProductMajorPart(5).And.HasCompanyName("Acme"); } await That(Act).DoesNotThrow(); @@ -49,19 +51,17 @@ but it was 5 } [Fact] - public async Task ShouldSupportAndComposition() + public async Task WhenProductMajorPartMatches_ShouldSucceed() { MockFileSystem fileSystem = new(); - fileSystem.WithFileVersionInfo("*.dll", v => v - .SetProductVersion("5.6.7.8") - .SetCompanyName("Acme")); + fileSystem.WithFileVersionInfo("*.dll", v => v.SetProductVersion("5.6.7.8")); // ReSharper disable once MethodHasAsyncOverload fileSystem.File.WriteAllText("Acme.dll", ""); IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); async Task Act() { - await That(info).HasProductMajorPart(5).And.HasCompanyName("Acme"); + await That(info).HasProductMajorPart(5); } await That(Act).DoesNotThrow(); diff --git a/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasProductMinorPart.Tests.cs b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasProductMinorPart.Tests.cs index a28529a..ab9c603 100644 --- a/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasProductMinorPart.Tests.cs +++ b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasProductMinorPart.Tests.cs @@ -10,17 +10,19 @@ public sealed class HasProductMinorPart public sealed class Tests { [Fact] - public async Task WhenProductMinorPartMatches_ShouldSucceed() + public async Task ShouldSupportAndComposition() { MockFileSystem fileSystem = new(); - fileSystem.WithFileVersionInfo("*.dll", v => v.SetProductVersion("5.6.7.8")); + fileSystem.WithFileVersionInfo("*.dll", v => v + .SetProductVersion("5.6.7.8") + .SetCompanyName("Acme")); // ReSharper disable once MethodHasAsyncOverload fileSystem.File.WriteAllText("Acme.dll", ""); IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); async Task Act() { - await That(info).HasProductMinorPart(6); + await That(info).HasProductMinorPart(6).And.HasCompanyName("Acme"); } await That(Act).DoesNotThrow(); @@ -49,19 +51,17 @@ but it was 6 } [Fact] - public async Task ShouldSupportAndComposition() + public async Task WhenProductMinorPartMatches_ShouldSucceed() { MockFileSystem fileSystem = new(); - fileSystem.WithFileVersionInfo("*.dll", v => v - .SetProductVersion("5.6.7.8") - .SetCompanyName("Acme")); + fileSystem.WithFileVersionInfo("*.dll", v => v.SetProductVersion("5.6.7.8")); // ReSharper disable once MethodHasAsyncOverload fileSystem.File.WriteAllText("Acme.dll", ""); IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); async Task Act() { - await That(info).HasProductMinorPart(6).And.HasCompanyName("Acme"); + await That(info).HasProductMinorPart(6); } await That(Act).DoesNotThrow(); diff --git a/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasProductName.Tests.cs b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasProductName.Tests.cs index 2c16050..36ee110 100644 --- a/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasProductName.Tests.cs +++ b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasProductName.Tests.cs @@ -9,6 +9,25 @@ public sealed class HasProductName { public sealed class Tests { + [Fact] + public async Task ShouldSupportAndComposition() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v + .SetProductName("Anvil") + .SetCompanyName("Acme")); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).HasProductName("Anvil").And.HasCompanyName("Acme"); + } + + await That(Act).DoesNotThrow(); + } + [Fact] public async Task WhenProductNameDiffers_ShouldFail() { @@ -51,25 +70,6 @@ async Task Act() await That(Act).DoesNotThrow(); } - - [Fact] - public async Task ShouldSupportAndComposition() - { - MockFileSystem fileSystem = new(); - fileSystem.WithFileVersionInfo("*.dll", v => v - .SetProductName("Anvil") - .SetCompanyName("Acme")); - // ReSharper disable once MethodHasAsyncOverload - fileSystem.File.WriteAllText("Acme.dll", ""); - IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); - - async Task Act() - { - await That(info).HasProductName("Anvil").And.HasCompanyName("Acme"); - } - - await That(Act).DoesNotThrow(); - } } } } diff --git a/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasProductPrivatePart.Tests.cs b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasProductPrivatePart.Tests.cs index 1f1a555..dc1aaf4 100644 --- a/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasProductPrivatePart.Tests.cs +++ b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasProductPrivatePart.Tests.cs @@ -10,17 +10,19 @@ public sealed class HasProductPrivatePart public sealed class Tests { [Fact] - public async Task WhenProductPrivatePartMatches_ShouldSucceed() + public async Task ShouldSupportAndComposition() { MockFileSystem fileSystem = new(); - fileSystem.WithFileVersionInfo("*.dll", v => v.SetProductVersion("5.6.7.8")); + fileSystem.WithFileVersionInfo("*.dll", v => v + .SetProductVersion("5.6.7.8") + .SetCompanyName("Acme")); // ReSharper disable once MethodHasAsyncOverload fileSystem.File.WriteAllText("Acme.dll", ""); IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); async Task Act() { - await That(info).HasProductPrivatePart(8); + await That(info).HasProductPrivatePart(8).And.HasCompanyName("Acme"); } await That(Act).DoesNotThrow(); @@ -49,19 +51,17 @@ but it was 8 } [Fact] - public async Task ShouldSupportAndComposition() + public async Task WhenProductPrivatePartMatches_ShouldSucceed() { MockFileSystem fileSystem = new(); - fileSystem.WithFileVersionInfo("*.dll", v => v - .SetProductVersion("5.6.7.8") - .SetCompanyName("Acme")); + fileSystem.WithFileVersionInfo("*.dll", v => v.SetProductVersion("5.6.7.8")); // ReSharper disable once MethodHasAsyncOverload fileSystem.File.WriteAllText("Acme.dll", ""); IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); async Task Act() { - await That(info).HasProductPrivatePart(8).And.HasCompanyName("Acme"); + await That(info).HasProductPrivatePart(8); } await That(Act).DoesNotThrow(); diff --git a/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasProductVersion.Tests.cs b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasProductVersion.Tests.cs index 1f17b1a..dab95f5 100644 --- a/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasProductVersion.Tests.cs +++ b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasProductVersion.Tests.cs @@ -9,6 +9,25 @@ public sealed class HasProductVersion { public sealed class Tests { + [Fact] + public async Task ShouldSupportAndComposition() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v + .SetProductVersion("1.2") + .SetFileVersion("1.2.3.4")); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).HasProductVersion("1.2").And.HasFileVersion("1.2.3.4"); + } + + await That(Act).DoesNotThrow(); + } + [Fact] public async Task WhenProductVersionDiffers_ShouldFail() { @@ -51,25 +70,6 @@ async Task Act() await That(Act).DoesNotThrow(); } - - [Fact] - public async Task ShouldSupportAndComposition() - { - MockFileSystem fileSystem = new(); - fileSystem.WithFileVersionInfo("*.dll", v => v - .SetProductVersion("1.2") - .SetFileVersion("1.2.3.4")); - // ReSharper disable once MethodHasAsyncOverload - fileSystem.File.WriteAllText("Acme.dll", ""); - IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); - - async Task Act() - { - await That(info).HasProductVersion("1.2").And.HasFileVersion("1.2.3.4"); - } - - await That(Act).DoesNotThrow(); - } } } } diff --git a/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasSpecialBuild.Tests.cs b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasSpecialBuild.Tests.cs index 143a78a..0192e37 100644 --- a/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasSpecialBuild.Tests.cs +++ b/Tests/aweXpect.Testably.Tests/FileVersionInfo.HasSpecialBuild.Tests.cs @@ -9,6 +9,25 @@ public sealed class HasSpecialBuild { public sealed class Tests { + [Fact] + public async Task ShouldSupportAndComposition() + { + MockFileSystem fileSystem = new(); + fileSystem.WithFileVersionInfo("*.dll", v => v + .SetSpecialBuild("Acme") + .SetCompanyName("Acme")); + // ReSharper disable once MethodHasAsyncOverload + fileSystem.File.WriteAllText("Acme.dll", ""); + IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); + + async Task Act() + { + await That(info).HasSpecialBuild("Acme").And.HasCompanyName("Acme"); + } + + await That(Act).DoesNotThrow(); + } + [Fact] public async Task WhenSpecialBuildDiffers_ShouldFail() { @@ -51,25 +70,6 @@ async Task Act() await That(Act).DoesNotThrow(); } - - [Fact] - public async Task ShouldSupportAndComposition() - { - MockFileSystem fileSystem = new(); - fileSystem.WithFileVersionInfo("*.dll", v => v - .SetSpecialBuild("Acme") - .SetCompanyName("Acme")); - // ReSharper disable once MethodHasAsyncOverload - fileSystem.File.WriteAllText("Acme.dll", ""); - IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); - - async Task Act() - { - await That(info).HasSpecialBuild("Acme").And.HasCompanyName("Acme"); - } - - await That(Act).DoesNotThrow(); - } } } } diff --git a/Tests/aweXpect.Testably.Tests/FileVersionInfo.IsDebug.Tests.cs b/Tests/aweXpect.Testably.Tests/FileVersionInfo.IsDebug.Tests.cs index 3aac323..cc733d2 100644 --- a/Tests/aweXpect.Testably.Tests/FileVersionInfo.IsDebug.Tests.cs +++ b/Tests/aweXpect.Testably.Tests/FileVersionInfo.IsDebug.Tests.cs @@ -10,27 +10,29 @@ public sealed class IsDebug public sealed class Tests { [Fact] - public async Task WhenInfoIsDebug_ShouldSucceed() + public async Task ShouldSupportAndComposition() { MockFileSystem fileSystem = new(); - fileSystem.WithFileVersionInfo("*.dll", v => v.SetIsDebug(true)); + fileSystem.WithFileVersionInfo("*.dll", v => v + .SetIsDebug(true) + .SetCompanyName("Acme")); // ReSharper disable once MethodHasAsyncOverload fileSystem.File.WriteAllText("Acme.dll", ""); IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); async Task Act() { - await That(info).IsDebug(); + await That(info).IsDebug().And.HasCompanyName("Acme"); } await That(Act).DoesNotThrow(); } [Fact] - public async Task WhenInfoIsNotDebug_ShouldFail() + public async Task WhenInfoIsDebug_ShouldSucceed() { MockFileSystem fileSystem = new(); - fileSystem.WithFileVersionInfo("*.dll", v => v.SetIsDebug(false)); + fileSystem.WithFileVersionInfo("*.dll", v => v.SetIsDebug(true)); // ReSharper disable once MethodHasAsyncOverload fileSystem.File.WriteAllText("Acme.dll", ""); IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); @@ -40,31 +42,29 @@ async Task Act() await That(info).IsDebug(); } - await That(Act).ThrowsException() - .WithMessage(""" - Expected that info - is debug, - but it was not - """); + await That(Act).DoesNotThrow(); } [Fact] - public async Task ShouldSupportAndComposition() + public async Task WhenInfoIsNotDebug_ShouldFail() { MockFileSystem fileSystem = new(); - fileSystem.WithFileVersionInfo("*.dll", v => v - .SetIsDebug(true) - .SetCompanyName("Acme")); + fileSystem.WithFileVersionInfo("*.dll", v => v.SetIsDebug(false)); // ReSharper disable once MethodHasAsyncOverload fileSystem.File.WriteAllText("Acme.dll", ""); IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); async Task Act() { - await That(info).IsDebug().And.HasCompanyName("Acme"); + await That(info).IsDebug(); } - await That(Act).DoesNotThrow(); + await That(Act).ThrowsException() + .WithMessage(""" + Expected that info + is debug, + but it was not + """); } } } @@ -74,17 +74,19 @@ public sealed class IsNotDebug public sealed class Tests { [Fact] - public async Task WhenInfoIsNotDebug_ShouldSucceed() + public async Task ShouldSupportAndComposition() { MockFileSystem fileSystem = new(); - fileSystem.WithFileVersionInfo("*.dll", v => v.SetIsDebug(false)); + fileSystem.WithFileVersionInfo("*.dll", v => v + .SetIsDebug(false) + .SetCompanyName("Acme")); // ReSharper disable once MethodHasAsyncOverload fileSystem.File.WriteAllText("Acme.dll", ""); IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); async Task Act() { - await That(info).IsNotDebug(); + await That(info).IsNotDebug().And.HasCompanyName("Acme"); } await That(Act).DoesNotThrow(); @@ -113,19 +115,17 @@ but it was } [Fact] - public async Task ShouldSupportAndComposition() + public async Task WhenInfoIsNotDebug_ShouldSucceed() { MockFileSystem fileSystem = new(); - fileSystem.WithFileVersionInfo("*.dll", v => v - .SetIsDebug(false) - .SetCompanyName("Acme")); + fileSystem.WithFileVersionInfo("*.dll", v => v.SetIsDebug(false)); // ReSharper disable once MethodHasAsyncOverload fileSystem.File.WriteAllText("Acme.dll", ""); IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); async Task Act() { - await That(info).IsNotDebug().And.HasCompanyName("Acme"); + await That(info).IsNotDebug(); } await That(Act).DoesNotThrow(); diff --git a/Tests/aweXpect.Testably.Tests/FileVersionInfo.IsNotPrivateBuild.Tests.cs b/Tests/aweXpect.Testably.Tests/FileVersionInfo.IsNotPrivateBuild.Tests.cs index 06e0d9c..415dddd 100644 --- a/Tests/aweXpect.Testably.Tests/FileVersionInfo.IsNotPrivateBuild.Tests.cs +++ b/Tests/aweXpect.Testably.Tests/FileVersionInfo.IsNotPrivateBuild.Tests.cs @@ -10,27 +10,29 @@ public sealed class IsNotPrivateBuild public sealed class Tests { [Fact] - public async Task WhenInfoIsNotPrivateBuild_ShouldSucceed() + public async Task ShouldSupportAndComposition() { MockFileSystem fileSystem = new(); - fileSystem.WithFileVersionInfo("*.dll", v => v.SetIsPrivateBuild(false)); + fileSystem.WithFileVersionInfo("*.dll", v => v + .SetIsPrivateBuild(false) + .SetCompanyName("Acme")); // ReSharper disable once MethodHasAsyncOverload fileSystem.File.WriteAllText("Acme.dll", ""); IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); async Task Act() { - await That(info).IsNotPrivateBuild(); + await That(info).IsNotPrivateBuild().And.HasCompanyName("Acme"); } await That(Act).DoesNotThrow(); } [Fact] - public async Task WhenInfoIsPrivateBuild_ShouldFail() + public async Task WhenInfoIsNotPrivateBuild_ShouldSucceed() { MockFileSystem fileSystem = new(); - fileSystem.WithFileVersionInfo("*.dll", v => v.SetIsPrivateBuild(true)); + fileSystem.WithFileVersionInfo("*.dll", v => v.SetIsPrivateBuild(false)); // ReSharper disable once MethodHasAsyncOverload fileSystem.File.WriteAllText("Acme.dll", ""); IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); @@ -40,31 +42,29 @@ async Task Act() await That(info).IsNotPrivateBuild(); } - await That(Act).ThrowsException() - .WithMessage(""" - Expected that info - is not private build, - but it was - """); + await That(Act).DoesNotThrow(); } [Fact] - public async Task ShouldSupportAndComposition() + public async Task WhenInfoIsPrivateBuild_ShouldFail() { MockFileSystem fileSystem = new(); - fileSystem.WithFileVersionInfo("*.dll", v => v - .SetIsPrivateBuild(false) - .SetCompanyName("Acme")); + fileSystem.WithFileVersionInfo("*.dll", v => v.SetIsPrivateBuild(true)); // ReSharper disable once MethodHasAsyncOverload fileSystem.File.WriteAllText("Acme.dll", ""); IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); async Task Act() { - await That(info).IsNotPrivateBuild().And.HasCompanyName("Acme"); + await That(info).IsNotPrivateBuild(); } - await That(Act).DoesNotThrow(); + await That(Act).ThrowsException() + .WithMessage(""" + Expected that info + is not private build, + but it was + """); } } } diff --git a/Tests/aweXpect.Testably.Tests/FileVersionInfo.IsNotSpecialBuild.Tests.cs b/Tests/aweXpect.Testably.Tests/FileVersionInfo.IsNotSpecialBuild.Tests.cs index b62d5c9..97778c9 100644 --- a/Tests/aweXpect.Testably.Tests/FileVersionInfo.IsNotSpecialBuild.Tests.cs +++ b/Tests/aweXpect.Testably.Tests/FileVersionInfo.IsNotSpecialBuild.Tests.cs @@ -10,27 +10,29 @@ public sealed class IsNotSpecialBuild public sealed class Tests { [Fact] - public async Task WhenInfoIsNotSpecialBuild_ShouldSucceed() + public async Task ShouldSupportAndComposition() { MockFileSystem fileSystem = new(); - fileSystem.WithFileVersionInfo("*.dll", v => v.SetIsSpecialBuild(false)); + fileSystem.WithFileVersionInfo("*.dll", v => v + .SetIsSpecialBuild(false) + .SetCompanyName("Acme")); // ReSharper disable once MethodHasAsyncOverload fileSystem.File.WriteAllText("Acme.dll", ""); IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); async Task Act() { - await That(info).IsNotSpecialBuild(); + await That(info).IsNotSpecialBuild().And.HasCompanyName("Acme"); } await That(Act).DoesNotThrow(); } [Fact] - public async Task WhenInfoIsSpecialBuild_ShouldFail() + public async Task WhenInfoIsNotSpecialBuild_ShouldSucceed() { MockFileSystem fileSystem = new(); - fileSystem.WithFileVersionInfo("*.dll", v => v.SetIsSpecialBuild(true)); + fileSystem.WithFileVersionInfo("*.dll", v => v.SetIsSpecialBuild(false)); // ReSharper disable once MethodHasAsyncOverload fileSystem.File.WriteAllText("Acme.dll", ""); IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); @@ -40,31 +42,29 @@ async Task Act() await That(info).IsNotSpecialBuild(); } - await That(Act).ThrowsException() - .WithMessage(""" - Expected that info - is not special build, - but it was - """); + await That(Act).DoesNotThrow(); } [Fact] - public async Task ShouldSupportAndComposition() + public async Task WhenInfoIsSpecialBuild_ShouldFail() { MockFileSystem fileSystem = new(); - fileSystem.WithFileVersionInfo("*.dll", v => v - .SetIsSpecialBuild(false) - .SetCompanyName("Acme")); + fileSystem.WithFileVersionInfo("*.dll", v => v.SetIsSpecialBuild(true)); // ReSharper disable once MethodHasAsyncOverload fileSystem.File.WriteAllText("Acme.dll", ""); IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); async Task Act() { - await That(info).IsNotSpecialBuild().And.HasCompanyName("Acme"); + await That(info).IsNotSpecialBuild(); } - await That(Act).DoesNotThrow(); + await That(Act).ThrowsException() + .WithMessage(""" + Expected that info + is not special build, + but it was + """); } } } diff --git a/Tests/aweXpect.Testably.Tests/FileVersionInfo.IsPatched.Tests.cs b/Tests/aweXpect.Testably.Tests/FileVersionInfo.IsPatched.Tests.cs index a863166..43c0810 100644 --- a/Tests/aweXpect.Testably.Tests/FileVersionInfo.IsPatched.Tests.cs +++ b/Tests/aweXpect.Testably.Tests/FileVersionInfo.IsPatched.Tests.cs @@ -10,17 +10,19 @@ public sealed class IsPatched public sealed class Tests { [Fact] - public async Task WhenInfoIsPatched_ShouldSucceed() + public async Task ShouldSupportAndComposition() { MockFileSystem fileSystem = new(); - fileSystem.WithFileVersionInfo("*.dll", v => v.SetIsPatched(true)); + fileSystem.WithFileVersionInfo("*.dll", v => v + .SetIsPatched(true) + .SetCompanyName("Acme")); // ReSharper disable once MethodHasAsyncOverload fileSystem.File.WriteAllText("Acme.dll", ""); IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); async Task Act() { - await That(info).IsPatched(); + await That(info).IsPatched().And.HasCompanyName("Acme"); } await That(Act).DoesNotThrow(); @@ -49,19 +51,17 @@ but it was not } [Fact] - public async Task ShouldSupportAndComposition() + public async Task WhenInfoIsPatched_ShouldSucceed() { MockFileSystem fileSystem = new(); - fileSystem.WithFileVersionInfo("*.dll", v => v - .SetIsPatched(true) - .SetCompanyName("Acme")); + fileSystem.WithFileVersionInfo("*.dll", v => v.SetIsPatched(true)); // ReSharper disable once MethodHasAsyncOverload fileSystem.File.WriteAllText("Acme.dll", ""); IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); async Task Act() { - await That(info).IsPatched().And.HasCompanyName("Acme"); + await That(info).IsPatched(); } await That(Act).DoesNotThrow(); @@ -74,27 +74,29 @@ public sealed class IsNotPatched public sealed class Tests { [Fact] - public async Task WhenInfoIsNotPatched_ShouldSucceed() + public async Task ShouldSupportAndComposition() { MockFileSystem fileSystem = new(); - fileSystem.WithFileVersionInfo("*.dll", v => v.SetIsPatched(false)); + fileSystem.WithFileVersionInfo("*.dll", v => v + .SetIsPatched(false) + .SetCompanyName("Acme")); // ReSharper disable once MethodHasAsyncOverload fileSystem.File.WriteAllText("Acme.dll", ""); IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); async Task Act() { - await That(info).IsNotPatched(); + await That(info).IsNotPatched().And.HasCompanyName("Acme"); } await That(Act).DoesNotThrow(); } [Fact] - public async Task WhenInfoIsPatched_ShouldFail() + public async Task WhenInfoIsNotPatched_ShouldSucceed() { MockFileSystem fileSystem = new(); - fileSystem.WithFileVersionInfo("*.dll", v => v.SetIsPatched(true)); + fileSystem.WithFileVersionInfo("*.dll", v => v.SetIsPatched(false)); // ReSharper disable once MethodHasAsyncOverload fileSystem.File.WriteAllText("Acme.dll", ""); IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); @@ -104,31 +106,29 @@ async Task Act() await That(info).IsNotPatched(); } - await That(Act).ThrowsException() - .WithMessage(""" - Expected that info - is not patched, - but it was - """); + await That(Act).DoesNotThrow(); } [Fact] - public async Task ShouldSupportAndComposition() + public async Task WhenInfoIsPatched_ShouldFail() { MockFileSystem fileSystem = new(); - fileSystem.WithFileVersionInfo("*.dll", v => v - .SetIsPatched(false) - .SetCompanyName("Acme")); + fileSystem.WithFileVersionInfo("*.dll", v => v.SetIsPatched(true)); // ReSharper disable once MethodHasAsyncOverload fileSystem.File.WriteAllText("Acme.dll", ""); IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); async Task Act() { - await That(info).IsNotPatched().And.HasCompanyName("Acme"); + await That(info).IsNotPatched(); } - await That(Act).DoesNotThrow(); + await That(Act).ThrowsException() + .WithMessage(""" + Expected that info + is not patched, + but it was + """); } } } diff --git a/Tests/aweXpect.Testably.Tests/FileVersionInfo.IsPreRelease.Tests.cs b/Tests/aweXpect.Testably.Tests/FileVersionInfo.IsPreRelease.Tests.cs index 3b586ca..21e2017 100644 --- a/Tests/aweXpect.Testably.Tests/FileVersionInfo.IsPreRelease.Tests.cs +++ b/Tests/aweXpect.Testably.Tests/FileVersionInfo.IsPreRelease.Tests.cs @@ -10,17 +10,19 @@ public sealed class IsPreRelease public sealed class Tests { [Fact] - public async Task WhenInfoIsPreRelease_ShouldSucceed() + public async Task ShouldSupportAndComposition() { MockFileSystem fileSystem = new(); - fileSystem.WithFileVersionInfo("*.dll", v => v.SetIsPreRelease(true)); + fileSystem.WithFileVersionInfo("*.dll", v => v + .SetIsPreRelease(true) + .SetCompanyName("Acme")); // ReSharper disable once MethodHasAsyncOverload fileSystem.File.WriteAllText("Acme.dll", ""); IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); async Task Act() { - await That(info).IsPreRelease(); + await That(info).IsPreRelease().And.HasCompanyName("Acme"); } await That(Act).DoesNotThrow(); @@ -49,19 +51,17 @@ but it was not } [Fact] - public async Task ShouldSupportAndComposition() + public async Task WhenInfoIsPreRelease_ShouldSucceed() { MockFileSystem fileSystem = new(); - fileSystem.WithFileVersionInfo("*.dll", v => v - .SetIsPreRelease(true) - .SetCompanyName("Acme")); + fileSystem.WithFileVersionInfo("*.dll", v => v.SetIsPreRelease(true)); // ReSharper disable once MethodHasAsyncOverload fileSystem.File.WriteAllText("Acme.dll", ""); IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); async Task Act() { - await That(info).IsPreRelease().And.HasCompanyName("Acme"); + await That(info).IsPreRelease(); } await That(Act).DoesNotThrow(); @@ -74,27 +74,29 @@ public sealed class IsNotPreRelease public sealed class Tests { [Fact] - public async Task WhenInfoIsNotPreRelease_ShouldSucceed() + public async Task ShouldSupportAndComposition() { MockFileSystem fileSystem = new(); - fileSystem.WithFileVersionInfo("*.dll", v => v.SetIsPreRelease(false)); + fileSystem.WithFileVersionInfo("*.dll", v => v + .SetIsPreRelease(false) + .SetCompanyName("Acme")); // ReSharper disable once MethodHasAsyncOverload fileSystem.File.WriteAllText("Acme.dll", ""); IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); async Task Act() { - await That(info).IsNotPreRelease(); + await That(info).IsNotPreRelease().And.HasCompanyName("Acme"); } await That(Act).DoesNotThrow(); } [Fact] - public async Task WhenInfoIsPreRelease_ShouldFail() + public async Task WhenInfoIsNotPreRelease_ShouldSucceed() { MockFileSystem fileSystem = new(); - fileSystem.WithFileVersionInfo("*.dll", v => v.SetIsPreRelease(true)); + fileSystem.WithFileVersionInfo("*.dll", v => v.SetIsPreRelease(false)); // ReSharper disable once MethodHasAsyncOverload fileSystem.File.WriteAllText("Acme.dll", ""); IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); @@ -104,31 +106,29 @@ async Task Act() await That(info).IsNotPreRelease(); } - await That(Act).ThrowsException() - .WithMessage(""" - Expected that info - is not pre-release, - but it was - """); + await That(Act).DoesNotThrow(); } [Fact] - public async Task ShouldSupportAndComposition() + public async Task WhenInfoIsPreRelease_ShouldFail() { MockFileSystem fileSystem = new(); - fileSystem.WithFileVersionInfo("*.dll", v => v - .SetIsPreRelease(false) - .SetCompanyName("Acme")); + fileSystem.WithFileVersionInfo("*.dll", v => v.SetIsPreRelease(true)); // ReSharper disable once MethodHasAsyncOverload fileSystem.File.WriteAllText("Acme.dll", ""); IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); async Task Act() { - await That(info).IsNotPreRelease().And.HasCompanyName("Acme"); + await That(info).IsNotPreRelease(); } - await That(Act).DoesNotThrow(); + await That(Act).ThrowsException() + .WithMessage(""" + Expected that info + is not pre-release, + but it was + """); } } } diff --git a/Tests/aweXpect.Testably.Tests/FileVersionInfo.IsPrivateBuild.Tests.cs b/Tests/aweXpect.Testably.Tests/FileVersionInfo.IsPrivateBuild.Tests.cs index 9fc0c87..8930f7e 100644 --- a/Tests/aweXpect.Testably.Tests/FileVersionInfo.IsPrivateBuild.Tests.cs +++ b/Tests/aweXpect.Testably.Tests/FileVersionInfo.IsPrivateBuild.Tests.cs @@ -10,17 +10,19 @@ public sealed class IsPrivateBuild public sealed class Tests { [Fact] - public async Task WhenInfoIsPrivateBuild_ShouldSucceed() + public async Task ShouldSupportAndComposition() { MockFileSystem fileSystem = new(); - fileSystem.WithFileVersionInfo("*.dll", v => v.SetIsPrivateBuild(true)); + fileSystem.WithFileVersionInfo("*.dll", v => v + .SetIsPrivateBuild(true) + .SetCompanyName("Acme")); // ReSharper disable once MethodHasAsyncOverload fileSystem.File.WriteAllText("Acme.dll", ""); IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); async Task Act() { - await That(info).IsPrivateBuild(); + await That(info).IsPrivateBuild().And.HasCompanyName("Acme"); } await That(Act).DoesNotThrow(); @@ -49,19 +51,17 @@ but it was not } [Fact] - public async Task ShouldSupportAndComposition() + public async Task WhenInfoIsPrivateBuild_ShouldSucceed() { MockFileSystem fileSystem = new(); - fileSystem.WithFileVersionInfo("*.dll", v => v - .SetIsPrivateBuild(true) - .SetCompanyName("Acme")); + fileSystem.WithFileVersionInfo("*.dll", v => v.SetIsPrivateBuild(true)); // ReSharper disable once MethodHasAsyncOverload fileSystem.File.WriteAllText("Acme.dll", ""); IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); async Task Act() { - await That(info).IsPrivateBuild().And.HasCompanyName("Acme"); + await That(info).IsPrivateBuild(); } await That(Act).DoesNotThrow(); diff --git a/Tests/aweXpect.Testably.Tests/FileVersionInfo.IsSpecialBuild.Tests.cs b/Tests/aweXpect.Testably.Tests/FileVersionInfo.IsSpecialBuild.Tests.cs index 970f36c..4dcc806 100644 --- a/Tests/aweXpect.Testably.Tests/FileVersionInfo.IsSpecialBuild.Tests.cs +++ b/Tests/aweXpect.Testably.Tests/FileVersionInfo.IsSpecialBuild.Tests.cs @@ -10,17 +10,19 @@ public sealed class IsSpecialBuild public sealed class Tests { [Fact] - public async Task WhenInfoIsSpecialBuild_ShouldSucceed() + public async Task ShouldSupportAndComposition() { MockFileSystem fileSystem = new(); - fileSystem.WithFileVersionInfo("*.dll", v => v.SetIsSpecialBuild(true)); + fileSystem.WithFileVersionInfo("*.dll", v => v + .SetIsSpecialBuild(true) + .SetCompanyName("Acme")); // ReSharper disable once MethodHasAsyncOverload fileSystem.File.WriteAllText("Acme.dll", ""); IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); async Task Act() { - await That(info).IsSpecialBuild(); + await That(info).IsSpecialBuild().And.HasCompanyName("Acme"); } await That(Act).DoesNotThrow(); @@ -49,19 +51,17 @@ but it was not } [Fact] - public async Task ShouldSupportAndComposition() + public async Task WhenInfoIsSpecialBuild_ShouldSucceed() { MockFileSystem fileSystem = new(); - fileSystem.WithFileVersionInfo("*.dll", v => v - .SetIsSpecialBuild(true) - .SetCompanyName("Acme")); + fileSystem.WithFileVersionInfo("*.dll", v => v.SetIsSpecialBuild(true)); // ReSharper disable once MethodHasAsyncOverload fileSystem.File.WriteAllText("Acme.dll", ""); IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll"); async Task Act() { - await That(info).IsSpecialBuild().And.HasCompanyName("Acme"); + await That(info).IsSpecialBuild(); } await That(Act).DoesNotThrow();