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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 34 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
26 changes: 26 additions & 0 deletions Source/aweXpect.Testably/FileVersionInfoExtensions.HasComments.cs
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// Verifies that the <see cref="IFileVersionInfo" /> has the <paramref name="expected" /> comments.
/// </summary>
public static StringEqualityTypeResult<IFileVersionInfo, IThat<IFileVersionInfo>> HasComments(
this IThat<IFileVersionInfo> source,
string? expected)
{
StringEqualityOptions options = new();
return new StringEqualityTypeResult<IFileVersionInfo, IThat<IFileVersionInfo>>(
source.Get().ExpectationBuilder.AddConstraint((it, grammars)
=> new FileVersionInfoConstraints.HasStringPropertyConstraint(
it, grammars, v => v.Comments, options, expected, "comments")),
source,
options);
}
}
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// Verifies that the <see cref="IFileVersionInfo" /> has the <paramref name="expected" /> file build part.
/// </summary>
public static AndOrResult<IFileVersionInfo, IThat<IFileVersionInfo>> HasFileBuildPart(
this IThat<IFileVersionInfo> source,
int expected)
=> new(
source.Get().ExpectationBuilder.AddConstraint((it, grammars)
=> new FileVersionInfoConstraints.HasInt32PropertyConstraint(
it, grammars, v => v.FileBuildPart, expected, "file build part")),
source);
}
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// Verifies that the <see cref="IFileVersionInfo" /> has the <paramref name="expected" /> file major part.
/// </summary>
public static AndOrResult<IFileVersionInfo, IThat<IFileVersionInfo>> HasFileMajorPart(
this IThat<IFileVersionInfo> source,
int expected)
=> new(
source.Get().ExpectationBuilder.AddConstraint((it, grammars)
=> new FileVersionInfoConstraints.HasInt32PropertyConstraint(
it, grammars, v => v.FileMajorPart, expected, "file major part")),
source);
}
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// Verifies that the <see cref="IFileVersionInfo" /> has the <paramref name="expected" /> file minor part.
/// </summary>
public static AndOrResult<IFileVersionInfo, IThat<IFileVersionInfo>> HasFileMinorPart(
this IThat<IFileVersionInfo> source,
int expected)
=> new(
source.Get().ExpectationBuilder.AddConstraint((it, grammars)
=> new FileVersionInfoConstraints.HasInt32PropertyConstraint(
it, grammars, v => v.FileMinorPart, expected, "file minor part")),
source);
}
26 changes: 26 additions & 0 deletions Source/aweXpect.Testably/FileVersionInfoExtensions.HasFileName.cs
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// Verifies that the <see cref="IFileVersionInfo" /> has the <paramref name="expected" /> file name.
/// </summary>
public static StringEqualityTypeResult<IFileVersionInfo, IThat<IFileVersionInfo>> HasFileName(
this IThat<IFileVersionInfo> source,
string? expected)
{
StringEqualityOptions options = new();
return new StringEqualityTypeResult<IFileVersionInfo, IThat<IFileVersionInfo>>(
source.Get().ExpectationBuilder.AddConstraint((it, grammars)
=> new FileVersionInfoConstraints.HasStringPropertyConstraint(
it, grammars, v => v.FileName, options, expected, "file name")),
source,
options);
}
}
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// Verifies that the <see cref="IFileVersionInfo" /> has the <paramref name="expected" /> file private part.
/// </summary>
public static AndOrResult<IFileVersionInfo, IThat<IFileVersionInfo>> HasFilePrivatePart(
this IThat<IFileVersionInfo> source,
int expected)
=> new(
source.Get().ExpectationBuilder.AddConstraint((it, grammars)
=> new FileVersionInfoConstraints.HasInt32PropertyConstraint(
it, grammars, v => v.FilePrivatePart, expected, "file private part")),
source);
}
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// Verifies that the <see cref="IFileVersionInfo" /> has the <paramref name="expected" /> internal name.
/// </summary>
public static StringEqualityTypeResult<IFileVersionInfo, IThat<IFileVersionInfo>> HasInternalName(
this IThat<IFileVersionInfo> source,
string? expected)
{
StringEqualityOptions options = new();
return new StringEqualityTypeResult<IFileVersionInfo, IThat<IFileVersionInfo>>(
source.Get().ExpectationBuilder.AddConstraint((it, grammars)
=> new FileVersionInfoConstraints.HasStringPropertyConstraint(
it, grammars, v => v.InternalName, options, expected, "internal name")),
source,
options);
}
}
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// Verifies that the <see cref="IFileVersionInfo" /> has the <paramref name="expected" /> legal copyright.
/// </summary>
public static StringEqualityTypeResult<IFileVersionInfo, IThat<IFileVersionInfo>> HasLegalCopyright(
this IThat<IFileVersionInfo> source,
string? expected)
{
StringEqualityOptions options = new();
return new StringEqualityTypeResult<IFileVersionInfo, IThat<IFileVersionInfo>>(
source.Get().ExpectationBuilder.AddConstraint((it, grammars)
=> new FileVersionInfoConstraints.HasStringPropertyConstraint(
it, grammars, v => v.LegalCopyright, options, expected, "legal copyright")),
source,
options);
}
}
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// Verifies that the <see cref="IFileVersionInfo" /> has the <paramref name="expected" /> legal trademarks.
/// </summary>
public static StringEqualityTypeResult<IFileVersionInfo, IThat<IFileVersionInfo>> HasLegalTrademarks(
this IThat<IFileVersionInfo> source,
string? expected)
{
StringEqualityOptions options = new();
return new StringEqualityTypeResult<IFileVersionInfo, IThat<IFileVersionInfo>>(
source.Get().ExpectationBuilder.AddConstraint((it, grammars)
=> new FileVersionInfoConstraints.HasStringPropertyConstraint(
it, grammars, v => v.LegalTrademarks, options, expected, "legal trademarks")),
source,
options);
}
}
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// Verifies that the <see cref="IFileVersionInfo" /> has the <paramref name="expected" /> private build.
/// </summary>
public static StringEqualityTypeResult<IFileVersionInfo, IThat<IFileVersionInfo>> HasPrivateBuild(
this IThat<IFileVersionInfo> source,
string? expected)
{
StringEqualityOptions options = new();
return new StringEqualityTypeResult<IFileVersionInfo, IThat<IFileVersionInfo>>(
source.Get().ExpectationBuilder.AddConstraint((it, grammars)
=> new FileVersionInfoConstraints.HasStringPropertyConstraint(
it, grammars, v => v.PrivateBuild, options, expected, "private build")),
source,
options);
}
}
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// Verifies that the <see cref="IFileVersionInfo" /> has the <paramref name="expected" /> product build part.
/// </summary>
public static AndOrResult<IFileVersionInfo, IThat<IFileVersionInfo>> HasProductBuildPart(
this IThat<IFileVersionInfo> source,
int expected)
=> new(
source.Get().ExpectationBuilder.AddConstraint((it, grammars)
=> new FileVersionInfoConstraints.HasInt32PropertyConstraint(
it, grammars, v => v.ProductBuildPart, expected, "product build part")),
source);
}
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// Verifies that the <see cref="IFileVersionInfo" /> has the <paramref name="expected" /> product major part.
/// </summary>
public static AndOrResult<IFileVersionInfo, IThat<IFileVersionInfo>> HasProductMajorPart(
this IThat<IFileVersionInfo> source,
int expected)
=> new(
source.Get().ExpectationBuilder.AddConstraint((it, grammars)
=> new FileVersionInfoConstraints.HasInt32PropertyConstraint(
it, grammars, v => v.ProductMajorPart, expected, "product major part")),
source);
}
Original file line number Diff line number Diff line change
@@ -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
{
/// <summary>
/// Verifies that the <see cref="IFileVersionInfo" /> has the <paramref name="expected" /> product minor part.
/// </summary>
public static AndOrResult<IFileVersionInfo, IThat<IFileVersionInfo>> HasProductMinorPart(
this IThat<IFileVersionInfo> source,
int expected)
=> new(
source.Get().ExpectationBuilder.AddConstraint((it, grammars)
=> new FileVersionInfoConstraints.HasInt32PropertyConstraint(
it, grammars, v => v.ProductMinorPart, expected, "product minor part")),
source);
}
Loading
Loading