Skip to content

Commit 26bcde9

Browse files
committed
Replace Verify with plain DiffPlex
This PR replaces the use of Verify.XunitV3 and Verify.DiffPlex with just DiffPlex
1 parent 5518373 commit 26bcde9

9 files changed

Lines changed: 56 additions & 25 deletions

File tree

‎.editorconfig‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ dotnet_diagnostic.MA0047.severity = none
393393
# Use an overload of 'GetHashCode' that has a StringComparison parameter
394394
dotnet_diagnostic.MA0074.severity = none
395395

396-
# Verify settings
396+
# Approval.Tests settings
397397
[*.{received,verified}.txt]
398398
charset = utf-8-bom
399399
end_of_line = lf

‎.gitattributes‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,5 @@
6464
#*.rtf diff=astextplain
6565
#*.RTF diff=astextplain
6666

67-
# Verify settings
67+
# Approval.Tests settings
6868
*.verified.txt text eol=lf working-tree-encoding=UTF-8

‎.github/dependabot.yml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ updates:
1919
xunit:
2020
patterns:
2121
- "xunit*"
22-
- "Verify*"
2322
nuke:
2423
patterns:
2524
- "Nuke*"

‎CONTRIBUTING.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ Please do:
7272
* Ensure that changes are covered by a new or existing set of unit tests which follow the Arrange-Act-Assert syntax such as is used [in this example](https://github.com/fluentassertions/fluentassertions/blob/daaf35b9b59b622c96d0c034e8972a020b2bee55/Tests/FluentAssertions.Shared.Specs/BasicEquivalencySpecs.cs#L33).
7373
* Also the code coverage reported by the coveralls must be non-decreasing unless accepted by the authors.
7474
* If the contribution adds a feature or fixes a bug, please update the [**release notes**](https://github.com/fluentassertions/fluentassertions/blob/develop/docs/_pages/releases.md), which is published on the [website](https://fluentassertions.com/releases).
75-
* If the contribution changes the public API, the changes needs to be included by running [`AcceptApiChanges.ps1`](https://github.com/fluentassertions/fluentassertions/tree/develop/AcceptApiChanges.ps1)/[`AcceptApiChanges.sh`](https://github.com/fluentassertions/fluentassertions/tree/develop/AcceptApiChanges.sh) or using Rider's [Verify Support](https://plugins.jetbrains.com/plugin/17240-verify-support) plug-in.
75+
* If the contribution changes the public API, the changes needs to be included by running [`AcceptApiChanges.ps1`](https://github.com/fluentassertions/fluentassertions/tree/develop/AcceptApiChanges.ps1)/[`AcceptApiChanges.sh`](https://github.com/fluentassertions/fluentassertions/tree/develop/AcceptApiChanges.sh).
7676

7777
Please do not:
7878

‎README.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ This package is shipped as a [NuGet package](https://www.nuget.org/packages/Flue
4242
You can either build the solution using Visual Studio or Rider, or use the `build.ps1` script to kick-off the [Nuke](https://nuke.build/) build process. This will build the package and run all tests.
4343

4444
## Approval Tests
45-
This is a special set of tests that use the [Verify](https://github.com/VerifyTests/Verify) project to verify whether you've introduced any breaking changes in the public API of the library.
45+
This is a special set of tests that use the [PublicApiGenerator](https://github.com/PublicApiGenerator/PublicApiGenerator) and [DiffPlex](https://github.com/mmanela/diffplex) projects to verify whether you've introduced any breaking changes in the public API of the library.
4646

47-
If you've verified the changes and decided they are valid, you can accept them using `AcceptApiChanges.ps1` or `AcceptApiChanges.sh`. Alternatively, you can use the [Verify Support](https://plugins.jetbrains.com/plugin/17240-verify-support) plug-in to compare the changes and accept them right from inside Rider. See also the [Contribution Guidelines](CONTRIBUTING.md).
47+
If you've verified the changes and decided they are valid, you can accept them using `AcceptApiChanges.ps1` or `AcceptApiChanges.sh`. See also the [Contribution Guidelines](CONTRIBUTING.md).
4848

4949

5050
# Usage

‎Tests/Approval.Tests/ApiApproval.cs‎

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,31 @@
22
using System.Linq;
33
using System.Reflection;
44
using System.Runtime.CompilerServices;
5-
using System.Threading.Tasks;
5+
using System.Text;
66
using System.Xml.Linq;
77
using System.Xml.XPath;
8+
using DiffPlex.DiffBuilder;
9+
using DiffPlex.DiffBuilder.Model;
810
using PublicApiGenerator;
9-
using VerifyTests;
10-
using VerifyTests.DiffPlex;
11-
using VerifyXunit;
1211
using Xunit;
1312

1413
namespace Approval.Tests;
1514

1615
public class ApiApproval
1716
{
18-
static ApiApproval() => VerifyDiffPlex.Initialize(OutputType.Minimal);
19-
2017
[Theory]
2118
[ClassData(typeof(TargetFrameworksTheoryData))]
22-
public Task ApproveApi(string framework)
19+
public void ApproveApi(string framework)
2320
{
2421
var configuration = typeof(ApiApproval).Assembly.GetCustomAttribute<AssemblyConfigurationAttribute>()!.Configuration;
2522
var assemblyFile = CombinedPaths("Src", "FluentAssertions.DataSets", "bin", configuration, framework, "FluentAssertions.DataSets.dll");
2623
var assembly = Assembly.LoadFile(assemblyFile);
2724
var publicApi = assembly.GeneratePublicApi(options: null);
25+
var expected = GetExpected(publicApi, framework);
26+
27+
var diff = InlineDiffBuilder.Diff(expected, publicApi);
2828

29-
return Verifier
30-
.Verify(publicApi)
31-
.ScrubLinesContaining("FrameworkDisplayName")
32-
.UseDirectory(Path.Combine("ApprovedApi", "FluentAssertions.DataSets"))
33-
.UseFileName(framework)
34-
.DisableDiff();
29+
Assert.False(diff.HasDifferences, StringifyDiff(diff));
3530
}
3631

3732
private class TargetFrameworksTheoryData : TheoryData<string>
@@ -50,4 +45,41 @@ private static string GetSolutionDirectory([CallerFilePath] string path = "") =>
5045

5146
private static string CombinedPaths(params string[] paths) =>
5247
Path.GetFullPath(Path.Combine(paths.Prepend(GetSolutionDirectory()).ToArray()));
48+
49+
private string GetExpected(string publicApi, string targetFramework, [CallerFilePath] string path = "")
50+
{
51+
var projectPath = Path.Combine(Path.GetDirectoryName(path)!, "ApprovedApi", "FluentAssertions.DataSets");
52+
var receivedPath = Path.Combine(projectPath, $"{targetFramework}.received.txt");
53+
var verifiedPath = Path.Combine(projectPath, $"{targetFramework}.verified.txt");
54+
55+
File.WriteAllText(receivedPath, publicApi);
56+
return File.Exists(verifiedPath) ? File.ReadAllText(verifiedPath) : string.Empty;
57+
}
58+
59+
private static string StringifyDiff(DiffPaneModel diff)
60+
{
61+
var builder = new StringBuilder();
62+
if (diff.HasDifferences)
63+
{
64+
foreach (var line in diff.Lines)
65+
{
66+
switch (line.Type)
67+
{
68+
case ChangeType.Inserted:
69+
builder.Append("+ ");
70+
break;
71+
case ChangeType.Deleted:
72+
builder.Append("- ");
73+
break;
74+
default:
75+
// omit unchanged files
76+
continue;
77+
}
78+
79+
builder.AppendLine(line.Text);
80+
}
81+
}
82+
83+
return builder.ToString();
84+
}
5385
}

‎Tests/Approval.Tests/Approval.Tests.csproj‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,11 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9+
<PackageReference Include="DiffPlex" Version="1.9.0" />
910
<PackageReference Include="FluentAssertions" Version="8.0.0" />
1011
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
11-
<PackageReference Include="xunit.v3.core" Version="4.0.1" />
1212
<PackageReference Include="PublicApiGenerator" Version="11.5.4" />
13-
<PackageReference Include="Verify.DiffPlex" Version="[3.3.1]" />
14-
<!-- See OSMF terms before upgrading: https://github.com/VerifyTests/Verify#open-source-maintenance-fee -->
15-
<PackageReference Include="Verify.XunitV3" Version="[32.0.1,33.0.0)" />
13+
<PackageReference Include="xunit.v3" Version="4.0.1" />
1614
</ItemGroup>
1715

1816
<ItemGroup>

‎Tests/Approval.Tests/ApprovedApi/FluentAssertions.DataSets/net47.verified.txt‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
[assembly: FluentAssertions.CustomAssertionsAssembly]
1+
[assembly: FluentAssertions.CustomAssertionsAssembly]
22
[assembly: FluentAssertions.Extensibility.AssertionEngineInitializer(typeof(FluentAssertions.DataSets.InitializeDataSetSupport), "Initialize")]
33
[assembly: System.Reflection.AssemblyMetadata("RepositoryUrl", "https://github.com/fluentassertions/fluentassertions.datasets")]
44
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo(@"FluentAssertions.DataSets.Specs, PublicKey=00240000048000009400000006020000002400005253413100040000010001002d25ff515c85b13ba08f61d466cff5d80a7f28ba197bbf8796085213e7a3406f970d2a4874932fed35db546e89af2da88c194bf1b7f7ac70de7988c78406f7629c547283061282a825616eb7eb48a9514a7570942936020a9bb37dca9ff60b778309900851575614491c6d25018fadb75828f4c7a17bf2d7dc86e7b6eafc5d8f")]
5+
[assembly: System.Runtime.Versioning.TargetFramework(".NETFramework,Version=v4.7", FrameworkDisplayName=".NET Framework 4.7")]
56
namespace FluentAssertions
67
{
78
public static class AssertionExtensions

‎Tests/Approval.Tests/ApprovedApi/FluentAssertions.DataSets/net6.0.verified.txt‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
[assembly: FluentAssertions.CustomAssertionsAssembly]
1+
[assembly: FluentAssertions.CustomAssertionsAssembly]
22
[assembly: FluentAssertions.Extensibility.AssertionEngineInitializer(typeof(FluentAssertions.DataSets.InitializeDataSetSupport), "Initialize")]
33
[assembly: System.Reflection.AssemblyMetadata("RepositoryUrl", "https://github.com/fluentassertions/fluentassertions.datasets")]
44
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo(@"FluentAssertions.DataSets.Specs, PublicKey=00240000048000009400000006020000002400005253413100040000010001002d25ff515c85b13ba08f61d466cff5d80a7f28ba197bbf8796085213e7a3406f970d2a4874932fed35db546e89af2da88c194bf1b7f7ac70de7988c78406f7629c547283061282a825616eb7eb48a9514a7570942936020a9bb37dca9ff60b778309900851575614491c6d25018fadb75828f4c7a17bf2d7dc86e7b6eafc5d8f")]
5+
[assembly: System.Runtime.Versioning.TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName=".NET 6.0")]
56
namespace FluentAssertions
67
{
78
public static class AssertionExtensions

0 commit comments

Comments
 (0)