Skip to content

Commit

Permalink
Remove reference to Verify in Datadog.Trace.Tests
Browse files Browse the repository at this point in the history
Verify uses v5.0.0 of the Logging abstractions library, which is unfortunately incompatible with v2.x of the aspnetcore libraries

Resorted to a poor man's version instead
  • Loading branch information
andrewlock committed Aug 12, 2021
1 parent 2410acd commit ce17f0d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
1 change: 0 additions & 1 deletion test/Datadog.Trace.Tests/Datadog.Trace.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,5 @@

<ItemGroup Condition=" '$(TargetFramework)' != 'net452'">
<PackageReference Include="PublicApiGenerator" Version="10.2.0" />
<PackageReference Include="Verify.Xunit" Version="11.23.1" />
</ItemGroup>
</Project>
27 changes: 18 additions & 9 deletions test/Datadog.Trace.Tests/PublicApiTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,20 @@
// </copyright>

#if !NET452
using System.Linq;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using FluentAssertions;
using PublicApiGenerator;
using VerifyXunit;
using Xunit;

namespace Datadog.Trace.Tests
{
[UsesVerify]
public class PublicApiTests
{
[Fact]
public Task PublicApiHasNotChanged()
public void PublicApiHasNotChanged()
{
var assembly = typeof(Tracer).Assembly;
var publicApi = assembly.GeneratePublicApi();
Expand All @@ -34,9 +32,20 @@ public Task PublicApiHasNotChanged()

var targetFramework = attribute.FrameworkName.Contains(".NETFramework") ? "net4" : "netcoreapp";

return Verifier.Verify(publicApi)
.UseDirectory("Snapshots")
.UseTextForParameters(targetFramework);
// poor-man's VerifyTests.Verify, because Verify has incompatible dependencies with ASP.NET Core
var snapshotDirectory = Path.Combine(Directory.GetParent(GetThisSourceFile()).FullName, "Snapshots");
var receivedPath = Path.Combine(snapshotDirectory, $"PublicApiTests.PublicApiHasNotChanged_{targetFramework}.received.txt");
var verifiedPath = Path.Combine(snapshotDirectory, $"PublicApiTests.PublicApiHasNotChanged_{targetFramework}.verified.txt");

File.WriteAllText(receivedPath, publicApi);
var expected = File.Exists(verifiedPath) ? File.ReadAllText(verifiedPath) : string.Empty;

publicApi.Should().Be(expected, "Public API should match the verified API. Update verified snapshot when the public API changes as appropriate");
}

private static string GetThisSourceFile([CallerFilePath] string filePath = null)
{
return filePath;
}
}
}
Expand Down

0 comments on commit ce17f0d

Please sign in to comment.