Skip to content

Commit

Permalink
remove shoudly
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp committed Jun 1, 2024
1 parent f2d9f95 commit 39c9a65
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
1 change: 0 additions & 1 deletion src/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
<PackageVersion Include="Polyfill" Version="5.3.0" />
<PackageVersion Include="ProjectDefaults" Version="1.0.127" />
<PackageVersion Include="PublicApiGenerator" Version="11.1.0" />
<PackageVersion Include="Shouldly" Version="4.2.1" />
<PackageVersion Include="SimpleInfoName" Version="2.2.0" />
<PackageVersion Include="System.Drawing.Common" Version="8.0.6" />
<PackageVersion Include="System.IO.Compression" Version="4.3.0" />
Expand Down
1 change: 0 additions & 1 deletion src/Verify.MSTest.SourceGenerator.Tests/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
global using System.Collections.Immutable;
global using Microsoft.CodeAnalysis;
global using Microsoft.CodeAnalysis.CSharp;
global using Shouldly;
global using VerifyMSTest.SourceGenerator;
global using Xunit.Abstractions;
25 changes: 15 additions & 10 deletions src/Verify.MSTest.SourceGenerator.Tests/TestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,20 @@ public abstract class TestBase(ITestOutputHelper output)
private protected TestDriver TestDriver { get; } = new([new UsesVerifyGenerator().AsSourceGenerator()]);
protected ITestOutputHelper Output { get; } = output;

private protected async Task VerifyGenerator(GeneratorDriverResults results, IEnumerable<string>? expectedDiagnostics = null)
private protected async Task VerifyGenerator(GeneratorDriverResults results, IReadOnlyList<string>? expectedDiagnostics = null)
{
var first = results.FirstRun;
Output.WriteLine($"First run of generators took: {first.TimingInfo.ElapsedTime}");
var cached = results.CachedRun;
Output.WriteLine($"Cached re-run of generators took: {cached.TimingInfo.ElapsedTime}");

expectedDiagnostics ??= [];
results.outputCompilation.GetDiagnostics().ShouldAllBe(_ => expectedDiagnostics.Contains(_.Id));
if (expectedDiagnostics != null)
{
foreach (var diagnostic in results.outputCompilation.GetDiagnostics())
{
Assert.Contains(diagnostic.Id, expectedDiagnostics);
}
}

await Verify(first.RunResult.SelectGeneratedSources());

Expand All @@ -22,22 +27,22 @@ private protected async Task VerifyGenerator(GeneratorDriverResults results, IEn
var trackedSteps1 = first.RunResult.GetTrackedSteps(trackingNames);
var trackedSteps2 = cached.RunResult.GetTrackedSteps(trackingNames);

trackedSteps2.Keys.ShouldBe(trackedSteps1.Keys);
Assert.Equal(trackedSteps2.Keys, trackedSteps1.Keys);
foreach (var (key, steps1) in trackedSteps1)
{
var steps2 = trackedSteps2[key];

steps2.Length.ShouldBe(steps1.Length);
Assert.Equal(steps2.Length, steps1.Length);
for (var i = 0; i < steps1.Length; i++)
{
var outputs1 = steps1[i].Outputs;
var outputs2 = steps2[i].Outputs;

outputs1.Select(_ => _.Value)
.ShouldBe(outputs2.Select(_ => _.Value));
outputs2.Select(_ => _.Reason)
.ShouldAllBe(_ => _ == IncrementalStepRunReason.Cached ||
_ == IncrementalStepRunReason.Unchanged);
Assert.Equal(outputs1.Select(_ => _.Value), outputs2.Select(_ => _.Value));
foreach (var output in outputs2)
{
Assert.True(output.Reason is IncrementalStepRunReason.Cached or IncrementalStepRunReason.Unchanged);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

<ItemGroup>
<PackageReference Include="MSTest.TestFramework" />
<PackageReference Include="Shouldly" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="Xunit" />
<PackageReference Include="xunit.runner.visualstudio" PrivateAssets="all" />
Expand Down

0 comments on commit 39c9a65

Please sign in to comment.