Skip to content

Commit 4a672f8

Browse files
authored
feat: complete IFileVersionInfo expectations (#152)
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`.
1 parent 1f4b37c commit 4a672f8

69 files changed

Lines changed: 2934 additions & 787 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -202,29 +202,43 @@ fileSystem.File.WriteAllText("Acme.dll", "");
202202
IFileVersionInfo info = fileSystem.FileVersionInfo.GetVersionInfo("Acme.dll");
203203

204204
await That(info).HasCompanyName("Acme").And.HasProductName("Anvil");
205-
await That(info).HasFileVersion("1.2.3.4");
205+
await That(info).HasFileVersion("1.2.3.4").And.HasFileMajorPart(1);
206206
await That(info).IsDebug().And.IsNotPreRelease();
207207
```
208208

209-
Dedicated assertions exist for the common fields (`HasCompanyName`,
210-
`HasProductName`, `HasFileDescription`, `HasFileVersion`, `HasProductVersion`,
211-
`HasOriginalFilename`, `HasLanguage`), plus the boolean pairs
212-
`IsDebug` / `IsNotDebug`, `IsPreRelease` / `IsNotPreRelease` and
213-
`IsPatched` / `IsNotPatched`.
214-
215-
| Property | Assertion |
216-
|-----------------------|--------------------------------------------|
217-
| `CompanyName` | `HasCompanyName(string)` |
218-
| `ProductName` | `HasProductName(string)` |
219-
| `FileDescription` | `HasFileDescription(string)` |
220-
| `FileVersion` | `HasFileVersion(string)` |
221-
| `ProductVersion` | `HasProductVersion(string)` |
222-
| `OriginalFilename` | `HasOriginalFilename(string)` |
223-
| `Language` | `HasLanguage(string)` |
224-
| `IsDebug` | `IsDebug()` / `IsNotDebug()` |
225-
| `IsPreRelease` | `IsPreRelease()` / `IsNotPreRelease()` |
226-
| `IsPatched` | `IsPatched()` / `IsNotPatched()` |
227-
| _other_ (e.g. `Comments`, `LegalCopyright`, `FileMajorPart`) | `await That(info.X).Is…` |
209+
Dedicated assertions cover every `IFileVersionInfo` property — strings via
210+
`Has…(string)`, the integer version parts via `Has…(int)` and the booleans
211+
as `Is…()` / `IsNot…()` pairs.
212+
213+
| Property | Assertion |
214+
|----------------------|--------------------------------------------|
215+
| `Comments` | `HasComments(string)` |
216+
| `CompanyName` | `HasCompanyName(string)` |
217+
| `FileDescription` | `HasFileDescription(string)` |
218+
| `FileName` | `HasFileName(string)` |
219+
| `FileVersion` | `HasFileVersion(string)` |
220+
| `InternalName` | `HasInternalName(string)` |
221+
| `Language` | `HasLanguage(string)` |
222+
| `LegalCopyright` | `HasLegalCopyright(string)` |
223+
| `LegalTrademarks` | `HasLegalTrademarks(string)` |
224+
| `OriginalFilename` | `HasOriginalFilename(string)` |
225+
| `PrivateBuild` | `HasPrivateBuild(string)` |
226+
| `ProductName` | `HasProductName(string)` |
227+
| `ProductVersion` | `HasProductVersion(string)` |
228+
| `SpecialBuild` | `HasSpecialBuild(string)` |
229+
| `FileBuildPart` | `HasFileBuildPart(int)` |
230+
| `FileMajorPart` | `HasFileMajorPart(int)` |
231+
| `FileMinorPart` | `HasFileMinorPart(int)` |
232+
| `FilePrivatePart` | `HasFilePrivatePart(int)` |
233+
| `ProductBuildPart` | `HasProductBuildPart(int)` |
234+
| `ProductMajorPart` | `HasProductMajorPart(int)` |
235+
| `ProductMinorPart` | `HasProductMinorPart(int)` |
236+
| `ProductPrivatePart` | `HasProductPrivatePart(int)` |
237+
| `IsDebug` | `IsDebug()` / `IsNotDebug()` |
238+
| `IsPatched` | `IsPatched()` / `IsNotPatched()` |
239+
| `IsPreRelease` | `IsPreRelease()` / `IsNotPreRelease()` |
240+
| `IsPrivateBuild` | `IsPrivateBuild()` / `IsNotPrivateBuild()` |
241+
| `IsSpecialBuild` | `IsSpecialBuild()` / `IsNotSpecialBuild()` |
228242

229243
## File-system notifications
230244

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System.IO.Abstractions;
2+
using aweXpect.Core;
3+
using aweXpect.Options;
4+
using aweXpect.Results;
5+
using aweXpect.Testably.Helpers;
6+
7+
namespace aweXpect.Testably;
8+
9+
public static partial class FileVersionInfoExtensions
10+
{
11+
/// <summary>
12+
/// Verifies that the <see cref="IFileVersionInfo" /> has the <paramref name="expected" /> comments.
13+
/// </summary>
14+
public static StringEqualityTypeResult<IFileVersionInfo, IThat<IFileVersionInfo>> HasComments(
15+
this IThat<IFileVersionInfo> source,
16+
string? expected)
17+
{
18+
StringEqualityOptions options = new();
19+
return new StringEqualityTypeResult<IFileVersionInfo, IThat<IFileVersionInfo>>(
20+
source.Get().ExpectationBuilder.AddConstraint((it, grammars)
21+
=> new FileVersionInfoConstraints.HasStringPropertyConstraint(
22+
it, grammars, v => v.Comments, options, expected, "comments")),
23+
source,
24+
options);
25+
}
26+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System.IO.Abstractions;
2+
using aweXpect.Core;
3+
using aweXpect.Results;
4+
using aweXpect.Testably.Helpers;
5+
6+
namespace aweXpect.Testably;
7+
8+
public static partial class FileVersionInfoExtensions
9+
{
10+
/// <summary>
11+
/// Verifies that the <see cref="IFileVersionInfo" /> has the <paramref name="expected" /> file build part.
12+
/// </summary>
13+
public static AndOrResult<IFileVersionInfo, IThat<IFileVersionInfo>> HasFileBuildPart(
14+
this IThat<IFileVersionInfo> source,
15+
int expected)
16+
=> new(
17+
source.Get().ExpectationBuilder.AddConstraint((it, grammars)
18+
=> new FileVersionInfoConstraints.HasInt32PropertyConstraint(
19+
it, grammars, v => v.FileBuildPart, expected, "file build part")),
20+
source);
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System.IO.Abstractions;
2+
using aweXpect.Core;
3+
using aweXpect.Results;
4+
using aweXpect.Testably.Helpers;
5+
6+
namespace aweXpect.Testably;
7+
8+
public static partial class FileVersionInfoExtensions
9+
{
10+
/// <summary>
11+
/// Verifies that the <see cref="IFileVersionInfo" /> has the <paramref name="expected" /> file major part.
12+
/// </summary>
13+
public static AndOrResult<IFileVersionInfo, IThat<IFileVersionInfo>> HasFileMajorPart(
14+
this IThat<IFileVersionInfo> source,
15+
int expected)
16+
=> new(
17+
source.Get().ExpectationBuilder.AddConstraint((it, grammars)
18+
=> new FileVersionInfoConstraints.HasInt32PropertyConstraint(
19+
it, grammars, v => v.FileMajorPart, expected, "file major part")),
20+
source);
21+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System.IO.Abstractions;
2+
using aweXpect.Core;
3+
using aweXpect.Results;
4+
using aweXpect.Testably.Helpers;
5+
6+
namespace aweXpect.Testably;
7+
8+
public static partial class FileVersionInfoExtensions
9+
{
10+
/// <summary>
11+
/// Verifies that the <see cref="IFileVersionInfo" /> has the <paramref name="expected" /> file minor part.
12+
/// </summary>
13+
public static AndOrResult<IFileVersionInfo, IThat<IFileVersionInfo>> HasFileMinorPart(
14+
this IThat<IFileVersionInfo> source,
15+
int expected)
16+
=> new(
17+
source.Get().ExpectationBuilder.AddConstraint((it, grammars)
18+
=> new FileVersionInfoConstraints.HasInt32PropertyConstraint(
19+
it, grammars, v => v.FileMinorPart, expected, "file minor part")),
20+
source);
21+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System.IO.Abstractions;
2+
using aweXpect.Core;
3+
using aweXpect.Options;
4+
using aweXpect.Results;
5+
using aweXpect.Testably.Helpers;
6+
7+
namespace aweXpect.Testably;
8+
9+
public static partial class FileVersionInfoExtensions
10+
{
11+
/// <summary>
12+
/// Verifies that the <see cref="IFileVersionInfo" /> has the <paramref name="expected" /> file name.
13+
/// </summary>
14+
public static StringEqualityTypeResult<IFileVersionInfo, IThat<IFileVersionInfo>> HasFileName(
15+
this IThat<IFileVersionInfo> source,
16+
string? expected)
17+
{
18+
StringEqualityOptions options = new();
19+
return new StringEqualityTypeResult<IFileVersionInfo, IThat<IFileVersionInfo>>(
20+
source.Get().ExpectationBuilder.AddConstraint((it, grammars)
21+
=> new FileVersionInfoConstraints.HasStringPropertyConstraint(
22+
it, grammars, v => v.FileName, options, expected, "file name")),
23+
source,
24+
options);
25+
}
26+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System.IO.Abstractions;
2+
using aweXpect.Core;
3+
using aweXpect.Results;
4+
using aweXpect.Testably.Helpers;
5+
6+
namespace aweXpect.Testably;
7+
8+
public static partial class FileVersionInfoExtensions
9+
{
10+
/// <summary>
11+
/// Verifies that the <see cref="IFileVersionInfo" /> has the <paramref name="expected" /> file private part.
12+
/// </summary>
13+
public static AndOrResult<IFileVersionInfo, IThat<IFileVersionInfo>> HasFilePrivatePart(
14+
this IThat<IFileVersionInfo> source,
15+
int expected)
16+
=> new(
17+
source.Get().ExpectationBuilder.AddConstraint((it, grammars)
18+
=> new FileVersionInfoConstraints.HasInt32PropertyConstraint(
19+
it, grammars, v => v.FilePrivatePart, expected, "file private part")),
20+
source);
21+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System.IO.Abstractions;
2+
using aweXpect.Core;
3+
using aweXpect.Options;
4+
using aweXpect.Results;
5+
using aweXpect.Testably.Helpers;
6+
7+
namespace aweXpect.Testably;
8+
9+
public static partial class FileVersionInfoExtensions
10+
{
11+
/// <summary>
12+
/// Verifies that the <see cref="IFileVersionInfo" /> has the <paramref name="expected" /> internal name.
13+
/// </summary>
14+
public static StringEqualityTypeResult<IFileVersionInfo, IThat<IFileVersionInfo>> HasInternalName(
15+
this IThat<IFileVersionInfo> source,
16+
string? expected)
17+
{
18+
StringEqualityOptions options = new();
19+
return new StringEqualityTypeResult<IFileVersionInfo, IThat<IFileVersionInfo>>(
20+
source.Get().ExpectationBuilder.AddConstraint((it, grammars)
21+
=> new FileVersionInfoConstraints.HasStringPropertyConstraint(
22+
it, grammars, v => v.InternalName, options, expected, "internal name")),
23+
source,
24+
options);
25+
}
26+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System.IO.Abstractions;
2+
using aweXpect.Core;
3+
using aweXpect.Options;
4+
using aweXpect.Results;
5+
using aweXpect.Testably.Helpers;
6+
7+
namespace aweXpect.Testably;
8+
9+
public static partial class FileVersionInfoExtensions
10+
{
11+
/// <summary>
12+
/// Verifies that the <see cref="IFileVersionInfo" /> has the <paramref name="expected" /> legal copyright.
13+
/// </summary>
14+
public static StringEqualityTypeResult<IFileVersionInfo, IThat<IFileVersionInfo>> HasLegalCopyright(
15+
this IThat<IFileVersionInfo> source,
16+
string? expected)
17+
{
18+
StringEqualityOptions options = new();
19+
return new StringEqualityTypeResult<IFileVersionInfo, IThat<IFileVersionInfo>>(
20+
source.Get().ExpectationBuilder.AddConstraint((it, grammars)
21+
=> new FileVersionInfoConstraints.HasStringPropertyConstraint(
22+
it, grammars, v => v.LegalCopyright, options, expected, "legal copyright")),
23+
source,
24+
options);
25+
}
26+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System.IO.Abstractions;
2+
using aweXpect.Core;
3+
using aweXpect.Options;
4+
using aweXpect.Results;
5+
using aweXpect.Testably.Helpers;
6+
7+
namespace aweXpect.Testably;
8+
9+
public static partial class FileVersionInfoExtensions
10+
{
11+
/// <summary>
12+
/// Verifies that the <see cref="IFileVersionInfo" /> has the <paramref name="expected" /> legal trademarks.
13+
/// </summary>
14+
public static StringEqualityTypeResult<IFileVersionInfo, IThat<IFileVersionInfo>> HasLegalTrademarks(
15+
this IThat<IFileVersionInfo> source,
16+
string? expected)
17+
{
18+
StringEqualityOptions options = new();
19+
return new StringEqualityTypeResult<IFileVersionInfo, IThat<IFileVersionInfo>>(
20+
source.Get().ExpectationBuilder.AddConstraint((it, grammars)
21+
=> new FileVersionInfoConstraints.HasStringPropertyConstraint(
22+
it, grammars, v => v.LegalTrademarks, options, expected, "legal trademarks")),
23+
source,
24+
options);
25+
}
26+
}

0 commit comments

Comments
 (0)