From 39c9a65ffc397c0ed183def9fe9afacde8b6ac44 Mon Sep 17 00:00:00 2001 From: Simon Cropp Date: Sat, 1 Jun 2024 12:27:49 +1000 Subject: [PATCH] remove shoudly --- src/Directory.Packages.props | 1 - .../GlobalUsings.cs | 1 - .../TestBase.cs | 25 +++++++++++-------- ...Verify.MSTest.SourceGenerator.Tests.csproj | 1 - 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props index 0ed2e90362..54dca38c9b 100644 --- a/src/Directory.Packages.props +++ b/src/Directory.Packages.props @@ -25,7 +25,6 @@ - diff --git a/src/Verify.MSTest.SourceGenerator.Tests/GlobalUsings.cs b/src/Verify.MSTest.SourceGenerator.Tests/GlobalUsings.cs index fb55680aa4..7624663527 100644 --- a/src/Verify.MSTest.SourceGenerator.Tests/GlobalUsings.cs +++ b/src/Verify.MSTest.SourceGenerator.Tests/GlobalUsings.cs @@ -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; \ No newline at end of file diff --git a/src/Verify.MSTest.SourceGenerator.Tests/TestBase.cs b/src/Verify.MSTest.SourceGenerator.Tests/TestBase.cs index c08bb30ba2..efbe51de5a 100644 --- a/src/Verify.MSTest.SourceGenerator.Tests/TestBase.cs +++ b/src/Verify.MSTest.SourceGenerator.Tests/TestBase.cs @@ -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? expectedDiagnostics = null) + private protected async Task VerifyGenerator(GeneratorDriverResults results, IReadOnlyList? 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()); @@ -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); + } } } } diff --git a/src/Verify.MSTest.SourceGenerator.Tests/Verify.MSTest.SourceGenerator.Tests.csproj b/src/Verify.MSTest.SourceGenerator.Tests/Verify.MSTest.SourceGenerator.Tests.csproj index 4ec2de5f2a..04a252d634 100644 --- a/src/Verify.MSTest.SourceGenerator.Tests/Verify.MSTest.SourceGenerator.Tests.csproj +++ b/src/Verify.MSTest.SourceGenerator.Tests/Verify.MSTest.SourceGenerator.Tests.csproj @@ -9,7 +9,6 @@ -