diff --git a/tests/NetEvolve.FrameShift.Tests.Integration/Analyzers/CultureMutationTests.cs b/tests/NetEvolve.FrameShift.Tests.Integration/Analyzers/CultureMutationTests.cs index 9c520fa..03944f0 100644 --- a/tests/NetEvolve.FrameShift.Tests.Integration/Analyzers/CultureMutationTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Integration/Analyzers/CultureMutationTests.cs @@ -355,10 +355,13 @@ public async Task Analyze_UntestedOrdinalComparison_ReportsAGapPerRemainingCompa var diagnostics = await RunAsync(compilation, [CreateManifest(AnchorMemberId)]).ConfigureAwait(false); - _ = await Assert.That(Errors(compilation)).IsEmpty(); - _ = await Assert.That(Gaps(diagnostics)).IsEqualTo(ExpectAt(ComparisonLine, _ordinalMutants)); - _ = await Assert.That(Trivial(diagnostics)).IsEqualTo(DiagnosticAssertions.NoDiagnostics); - _ = await Assert.That(AnalyzerRunner.OfId(diagnostics, DiagnosticIds.InvalidTestSurfaceManifest)).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(Errors(compilation)).IsEmpty(); + _ = await Assert.That(Gaps(diagnostics)).IsEqualTo(ExpectAt(ComparisonLine, _ordinalMutants)); + _ = await Assert.That(Trivial(diagnostics)).IsEqualTo(DiagnosticAssertions.NoDiagnostics); + _ = await Assert.That(AnalyzerRunner.OfId(diagnostics, DiagnosticIds.InvalidTestSurfaceManifest)).IsEmpty(); + } } /// @@ -373,8 +376,13 @@ public async Task Analyze_CoveredOrdinalComparison_ReportsNothing() var diagnostics = await RunAsync(compilation, [CreateManifest(ComparisonMemberId)]).ConfigureAwait(false); - _ = await Assert.That(Errors(compilation)).IsEmpty(); - _ = await Assert.That(DiagnosticAssertions.Describe(diagnostics)).IsEqualTo(DiagnosticAssertions.NoDiagnostics); + using (Assert.Multiple()) + { + _ = await Assert.That(Errors(compilation)).IsEmpty(); + _ = await Assert + .That(DiagnosticAssertions.Describe(diagnostics)) + .IsEqualTo(DiagnosticAssertions.NoDiagnostics); + } } /// @@ -388,16 +396,19 @@ public async Task Analyze_UntestedInvariantCultureFormatting_ReportsTheCultureSw var diagnostics = await RunAsync(compilation, [CreateManifest(AnchorMemberId)]).ConfigureAwait(false); - _ = await Assert.That(Errors(compilation)).IsEmpty(); - _ = await Assert - .That(Gaps(diagnostics)) - .IsEqualTo( - Expect( - (FormatLine, "InvariantCulture => CurrentCulture"), - (FormatLine, "CultureInfo.InvariantCulture => (removed)") - ) - ); - _ = await Assert.That(Trivial(diagnostics)).IsEqualTo(DiagnosticAssertions.NoDiagnostics); + using (Assert.Multiple()) + { + _ = await Assert.That(Errors(compilation)).IsEmpty(); + _ = await Assert + .That(Gaps(diagnostics)) + .IsEqualTo( + Expect( + (FormatLine, "InvariantCulture => CurrentCulture"), + (FormatLine, "CultureInfo.InvariantCulture => (removed)") + ) + ); + _ = await Assert.That(Trivial(diagnostics)).IsEqualTo(DiagnosticAssertions.NoDiagnostics); + } } /// @@ -414,17 +425,20 @@ public async Task Analyze_ProviderRemovalWithoutAMatchingOverload_IsDroppedAsANo var diagnostics = await RunAsync(compilation, [CreateManifest(AnchorMemberId)]).ConfigureAwait(false); - _ = await Assert.That(Errors(compilation)).IsEmpty(); - _ = await Assert - .That(Gaps(diagnostics)) - .IsEqualTo( - Expect( - (RemovableProviderLine, "CultureInfo.InvariantCulture => (removed)"), - (RemovableProviderLine, "InvariantCulture => CurrentCulture"), - (RequiredProviderLine, "InvariantCulture => CurrentCulture") - ) - ); - _ = await Assert.That(Trivial(diagnostics)).IsEqualTo(DiagnosticAssertions.NoDiagnostics); + using (Assert.Multiple()) + { + _ = await Assert.That(Errors(compilation)).IsEmpty(); + _ = await Assert + .That(Gaps(diagnostics)) + .IsEqualTo( + Expect( + (RemovableProviderLine, "CultureInfo.InvariantCulture => (removed)"), + (RemovableProviderLine, "InvariantCulture => CurrentCulture"), + (RequiredProviderLine, "InvariantCulture => CurrentCulture") + ) + ); + _ = await Assert.That(Trivial(diagnostics)).IsEqualTo(DiagnosticAssertions.NoDiagnostics); + } } /// @@ -468,17 +482,20 @@ public async Task Analyze_UntestedInvariantCaseConversion_ReportsOnlyTheConversi .Summarise(AnalyzerRunner.OfId(diagnostics, DiagnosticIds.UnreachableMutationPoint)) .Select(summary => summary.Line); - _ = await Assert.That(Errors(compilation)).IsEmpty(); - _ = await Assert - .That(Gaps(diagnostics)) - .IsEqualTo( - Expect( - (CaseConversionLine, "ToUpperInvariant => ToUpper"), - (CaseConversionLine, "ToUpperInvariant => ToLowerInvariant") - ) - ); - _ = await Assert.That(lines.Distinct()).IsEquivalentTo(new[] { CaseConversionLine }); - _ = await Assert.That(Trivial(diagnostics)).IsEqualTo(DiagnosticAssertions.NoDiagnostics); + using (Assert.Multiple()) + { + _ = await Assert.That(Errors(compilation)).IsEmpty(); + _ = await Assert + .That(Gaps(diagnostics)) + .IsEqualTo( + Expect( + (CaseConversionLine, "ToUpperInvariant => ToUpper"), + (CaseConversionLine, "ToUpperInvariant => ToLowerInvariant") + ) + ); + _ = await Assert.That(lines.Distinct()).IsEquivalentTo(new[] { CaseConversionLine }); + _ = await Assert.That(Trivial(diagnostics)).IsEqualTo(DiagnosticAssertions.NoDiagnostics); + } } /// @@ -492,24 +509,27 @@ public async Task Analyze_UntestedRegexOptions_ReportsAGapPerOfferedFlag() var diagnostics = await RunAsync(compilation, [CreateManifest(AnchorMemberId)]).ConfigureAwait(false); - _ = await Assert.That(Errors(compilation)).IsEmpty(); - _ = await Assert - .That(Gaps(diagnostics)) - .IsEqualTo( - ExpectAt( - RegexOptionsLine, - [ - "RegexOptions - IgnoreCase", - "RegexOptions + CultureInvariant", - "RegexOptions + Multiline", - "RegexOptions + Singleline", - "RegexOptions + ExplicitCapture", - "RegexOptions + IgnorePatternWhitespace", - "RegexOptions + RightToLeft", - ] - ) - ); - _ = await Assert.That(Trivial(diagnostics)).IsEqualTo(DiagnosticAssertions.NoDiagnostics); + using (Assert.Multiple()) + { + _ = await Assert.That(Errors(compilation)).IsEmpty(); + _ = await Assert + .That(Gaps(diagnostics)) + .IsEqualTo( + ExpectAt( + RegexOptionsLine, + [ + "RegexOptions - IgnoreCase", + "RegexOptions + CultureInvariant", + "RegexOptions + Multiline", + "RegexOptions + Singleline", + "RegexOptions + ExplicitCapture", + "RegexOptions + IgnorePatternWhitespace", + "RegexOptions + RightToLeft", + ] + ) + ); + _ = await Assert.That(Trivial(diagnostics)).IsEqualTo(DiagnosticAssertions.NoDiagnostics); + } } /// @@ -524,8 +544,13 @@ public async Task Analyze_CultureValueInAConstantContext_ReportsNothing() var diagnostics = await RunAsync(compilation, [CreateManifest(AnchorMemberId)]).ConfigureAwait(false); - _ = await Assert.That(Errors(compilation)).IsEmpty(); - _ = await Assert.That(DiagnosticAssertions.Describe(diagnostics)).IsEqualTo(DiagnosticAssertions.NoDiagnostics); + using (Assert.Multiple()) + { + _ = await Assert.That(Errors(compilation)).IsEmpty(); + _ = await Assert + .That(DiagnosticAssertions.Describe(diagnostics)) + .IsEqualTo(DiagnosticAssertions.NoDiagnostics); + } } /// @@ -551,10 +576,15 @@ public async Task Analyze_MemberDenseWithCultureMutations_IsBoundedByTheMutantBu var four = await RunAsync(compilation, manifest, CreateBudget(4)).ConfigureAwait(false); var one = await RunAsync(compilation, manifest, CreateBudget(1)).ConfigureAwait(false); - _ = await Assert.That(Errors(compilation)).IsEmpty(); - _ = await Assert.That(Gaps(unlimited)).IsEqualTo(ExpectAt(DenseLine, [.. caseConversions, .. _ordinalMutants])); - _ = await Assert.That(Gaps(four)).IsEqualTo(ExpectAt(DenseLine, caseConversions)); - _ = await Assert.That(Gaps(one)).IsEqualTo(ExpectAt(DenseLine, [caseConversions[0]])); + using (Assert.Multiple()) + { + _ = await Assert.That(Errors(compilation)).IsEmpty(); + _ = await Assert + .That(Gaps(unlimited)) + .IsEqualTo(ExpectAt(DenseLine, [.. caseConversions, .. _ordinalMutants])); + _ = await Assert.That(Gaps(four)).IsEqualTo(ExpectAt(DenseLine, caseConversions)); + _ = await Assert.That(Gaps(one)).IsEqualTo(ExpectAt(DenseLine, [caseConversions[0]])); + } } /// @@ -572,9 +602,12 @@ public async Task Analyze_EveryFixture_CompilesAndReportsNoAnalyzerFailure(strin var diagnostics = await RunAsync(compilation, [CreateManifest(AnchorMemberId)]).ConfigureAwait(false); - _ = await Assert.That(string.Join("; ", Errors(compilation))).IsEqualTo(string.Empty); - _ = await Assert.That(AnalyzerRunner.OfId(diagnostics, AnalyzerRunner.AnalyzerFailureId)).IsEmpty(); - _ = await Assert.That(AnalyzerRunner.OfId(diagnostics, DiagnosticIds.InvalidTestSurfaceManifest)).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(string.Join("; ", Errors(compilation))).IsEqualTo(string.Empty); + _ = await Assert.That(AnalyzerRunner.OfId(diagnostics, AnalyzerRunner.AnalyzerFailureId)).IsEmpty(); + _ = await Assert.That(AnalyzerRunner.OfId(diagnostics, DiagnosticIds.InvalidTestSurfaceManifest)).IsEmpty(); + } } private static Task> RunAsync( diff --git a/tests/NetEvolve.FrameShift.Tests.Integration/Analyzers/MSTestSurfaceAnalyzerTests.cs b/tests/NetEvolve.FrameShift.Tests.Integration/Analyzers/MSTestSurfaceAnalyzerTests.cs index 1ec3dff..e3393fb 100644 --- a/tests/NetEvolve.FrameShift.Tests.Integration/Analyzers/MSTestSurfaceAnalyzerTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Integration/Analyzers/MSTestSurfaceAnalyzerTests.cs @@ -108,12 +108,15 @@ public async Task Fixtures_BothAssemblies_CompileWithoutErrors() var production = CreateProduction(); var test = CreateTest(production); - _ = await Assert - .That(DiagnosticAssertions.Describe(CompilationFactory.GetCompileErrors(production))) - .IsEqualTo(DiagnosticAssertions.NoDiagnostics); - _ = await Assert - .That(DiagnosticAssertions.Describe(CompilationFactory.GetCompileErrors(test))) - .IsEqualTo(DiagnosticAssertions.NoDiagnostics); + using (Assert.Multiple()) + { + _ = await Assert + .That(DiagnosticAssertions.Describe(CompilationFactory.GetCompileErrors(production))) + .IsEqualTo(DiagnosticAssertions.NoDiagnostics); + _ = await Assert + .That(DiagnosticAssertions.Describe(CompilationFactory.GetCompileErrors(test))) + .IsEqualTo(DiagnosticAssertions.NoDiagnostics); + } } /// @@ -144,10 +147,15 @@ public async Task Analyzer_FrameworkWithoutAnyTest_ReportsNothing() var diagnostics = await RunAllAsync(compilation, MalformedManifest).ConfigureAwait(false); - _ = await Assert.That(DiagnosticAssertions.Describe(diagnostics)).IsEqualTo(DiagnosticAssertions.NoDiagnostics); - _ = await Assert - .That(DiagnosticAssertions.Describe(CompilationFactory.GetCompileErrors(compilation))) - .IsEqualTo(DiagnosticAssertions.NoDiagnostics); + using (Assert.Multiple()) + { + _ = await Assert + .That(DiagnosticAssertions.Describe(diagnostics)) + .IsEqualTo(DiagnosticAssertions.NoDiagnostics); + _ = await Assert + .That(DiagnosticAssertions.Describe(CompilationFactory.GetCompileErrors(compilation))) + .IsEqualTo(DiagnosticAssertions.NoDiagnostics); + } } [Test] @@ -171,11 +179,14 @@ public async Task Analyzer_TestWithoutProductionReference_IsReportedOnceAtItsIde var diagnostics = await RunAsync(test, DiagnosticIds.TestWithoutProductionReference).ConfigureAwait(false); - _ = await Assert.That(diagnostics.Length).IsEqualTo(1); - _ = await Assert.That(diagnostics[0].Location.SourceSpan).IsEqualTo(identifier.Span); - _ = await Assert - .That(GetMessage(diagnostics[0]).Contains(LocalOnlyTestName, StringComparison.Ordinal)) - .IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(diagnostics.Length).IsEqualTo(1); + _ = await Assert.That(diagnostics[0].Location.SourceSpan).IsEqualTo(identifier.Span); + _ = await Assert + .That(GetMessage(diagnostics[0]).Contains(LocalOnlyTestName, StringComparison.Ordinal)) + .IsTrue(); + } } [Test] @@ -287,10 +298,15 @@ public async Task Analyzer_EveryManifestShape_NeverCrashes() reported.AddRange(DiagnosticAssertions.Ids(await RunAllAsync(test, shape).ConfigureAwait(false))); } - _ = await Assert.That(reported.Contains(AnalyzerRunner.AnalyzerFailureId, StringComparer.Ordinal)).IsFalse(); - _ = await Assert - .That(reported.Contains(DiagnosticIds.TestWithoutProductionReference, StringComparer.Ordinal)) - .IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert + .That(reported.Contains(AnalyzerRunner.AnalyzerFailureId, StringComparer.Ordinal)) + .IsFalse(); + _ = await Assert + .That(reported.Contains(DiagnosticIds.TestWithoutProductionReference, StringComparer.Ordinal)) + .IsTrue(); + } } [Test] diff --git a/tests/NetEvolve.FrameShift.Tests.Integration/Analyzers/MixedFrameworkTestSurfaceTests.cs b/tests/NetEvolve.FrameShift.Tests.Integration/Analyzers/MixedFrameworkTestSurfaceTests.cs index 83f0233..43bc418 100644 --- a/tests/NetEvolve.FrameShift.Tests.Integration/Analyzers/MixedFrameworkTestSurfaceTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Integration/Analyzers/MixedFrameworkTestSurfaceTests.cs @@ -388,11 +388,14 @@ public async Task EveryAnalyzer_TestsOfTwoFrameworksWithoutProductionReference_R var messages = diagnostics.Select(diagnostic => GetMessage(diagnostic)).ToImmutableArray(); - _ = await Assert.That(diagnostics.Length).IsEqualTo(2); - _ = await Assert.That(Count(messages, TUnitLocalOnlyTestName)).IsEqualTo(1); - _ = await Assert.That(Count(messages, NUnitLocalOnlyTestName)).IsEqualTo(1); - _ = await Assert.That(Count(messages, TUnitCoveringTestName)).IsEqualTo(0); - _ = await Assert.That(Count(messages, NUnitCoveringTestName)).IsEqualTo(0); + using (Assert.Multiple()) + { + _ = await Assert.That(diagnostics.Length).IsEqualTo(2); + _ = await Assert.That(Count(messages, TUnitLocalOnlyTestName)).IsEqualTo(1); + _ = await Assert.That(Count(messages, NUnitLocalOnlyTestName)).IsEqualTo(1); + _ = await Assert.That(Count(messages, TUnitCoveringTestName)).IsEqualTo(0); + _ = await Assert.That(Count(messages, NUnitCoveringTestName)).IsEqualTo(0); + } } /// @@ -574,8 +577,11 @@ public async Task EveryAnalyzer_ManifestCoveringOnlyOneFramework_IsReportedAsSta var diagnostics = await RunEveryAnalyzerOfIdAsync(test, DiagnosticIds.InvalidTestSurfaceManifest, manifest) .ConfigureAwait(false); - _ = await Assert.That(diagnostics.Length).IsEqualTo(1); - _ = await Assert.That(GetMessage(diagnostics[0]).Contains(StaleDetail, StringComparison.Ordinal)).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(diagnostics.Length).IsEqualTo(1); + _ = await Assert.That(GetMessage(diagnostics[0]).Contains(StaleDetail, StringComparison.Ordinal)).IsTrue(); + } } [Test] @@ -647,12 +653,15 @@ public async Task EveryAnalyzer_TestsOfBothXunitVersionsWithoutProductionReferen var messages = diagnostics.Select(diagnostic => GetMessage(diagnostic)).ToImmutableArray(); - _ = await Assert.That(diagnostics.Length).IsEqualTo(3); - _ = await Assert.That(Count(messages, XunitV2LocalOnlyTestName)).IsEqualTo(1); - _ = await Assert.That(Count(messages, XunitV3LocalOnlyTestName)).IsEqualTo(1); - _ = await Assert.That(Count(messages, BothVersionsLocalOnlyTestName)).IsEqualTo(1); - _ = await Assert.That(Count(messages, XunitV2CoveringTestName)).IsEqualTo(0); - _ = await Assert.That(Count(messages, XunitV3CoveringTestName)).IsEqualTo(0); + using (Assert.Multiple()) + { + _ = await Assert.That(diagnostics.Length).IsEqualTo(3); + _ = await Assert.That(Count(messages, XunitV2LocalOnlyTestName)).IsEqualTo(1); + _ = await Assert.That(Count(messages, XunitV3LocalOnlyTestName)).IsEqualTo(1); + _ = await Assert.That(Count(messages, BothVersionsLocalOnlyTestName)).IsEqualTo(1); + _ = await Assert.That(Count(messages, XunitV2CoveringTestName)).IsEqualTo(0); + _ = await Assert.That(Count(messages, XunitV3CoveringTestName)).IsEqualTo(0); + } } /// @@ -675,11 +684,18 @@ public async Task EveryShippedAnalyzer_TestRecognisedByBothXunitVersions_IsRepor var diagnostics = AnalyzerRunner.OfId(reported, DiagnosticIds.TestWithoutProductionReference); var messages = diagnostics.Select(diagnostic => GetMessage(diagnostic)).ToImmutableArray(); - _ = await Assert - .That(DiagnosticAssertions.Ids(reported).Contains(AnalyzerRunner.AnalyzerFailureId, StringComparer.Ordinal)) - .IsFalse(); - _ = await Assert.That(diagnostics.Length).IsEqualTo(3); - _ = await Assert.That(Count(messages, BothVersionsLocalOnlyTestName)).IsEqualTo(1); + using (Assert.Multiple()) + { + _ = await Assert + .That( + DiagnosticAssertions + .Ids(reported) + .Contains(AnalyzerRunner.AnalyzerFailureId, StringComparer.Ordinal) + ) + .IsFalse(); + _ = await Assert.That(diagnostics.Length).IsEqualTo(3); + _ = await Assert.That(Count(messages, BothVersionsLocalOnlyTestName)).IsEqualTo(1); + } } /// @@ -696,8 +712,11 @@ public async Task EveryAnalyzer_StaleManifestOnABothXunitVersionProject_ReportsI var diagnostics = await RunEveryAnalyzerOfIdAsync(test, DiagnosticIds.InvalidTestSurfaceManifest, manifest) .ConfigureAwait(false); - _ = await Assert.That(diagnostics.Length).IsEqualTo(1); - _ = await Assert.That(GetMessage(diagnostics[0]).Contains(StaleDetail, StringComparison.Ordinal)).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(diagnostics.Length).IsEqualTo(1); + _ = await Assert.That(GetMessage(diagnostics[0]).Contains(StaleDetail, StringComparison.Ordinal)).IsTrue(); + } } /// @@ -779,10 +798,15 @@ await RunEveryAnalyzerAsync(shape.Compilation, shape.Manifest).ConfigureAwait(fa ); } - _ = await Assert.That(reported.Contains(AnalyzerRunner.AnalyzerFailureId, StringComparer.Ordinal)).IsFalse(); - _ = await Assert - .That(reported.Contains(DiagnosticIds.InvalidTestSurfaceManifest, StringComparer.Ordinal)) - .IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert + .That(reported.Contains(AnalyzerRunner.AnalyzerFailureId, StringComparer.Ordinal)) + .IsFalse(); + _ = await Assert + .That(reported.Contains(DiagnosticIds.InvalidTestSurfaceManifest, StringComparer.Ordinal)) + .IsTrue(); + } } /// diff --git a/tests/NetEvolve.FrameShift.Tests.Integration/Analyzers/MutationCoverageAnalyzerTests.cs b/tests/NetEvolve.FrameShift.Tests.Integration/Analyzers/MutationCoverageAnalyzerTests.cs index 710e1f0..1770968 100644 --- a/tests/NetEvolve.FrameShift.Tests.Integration/Analyzers/MutationCoverageAnalyzerTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Integration/Analyzers/MutationCoverageAnalyzerTests.cs @@ -391,8 +391,13 @@ public async Task Analyze_WithoutAnyManifest_ReportsNothing() var diagnostics = await RunAsync(compilation).ConfigureAwait(false); - _ = await Assert.That(Errors(compilation)).IsEmpty(); - _ = await Assert.That(DiagnosticAssertions.Describe(diagnostics)).IsEqualTo(DiagnosticAssertions.NoDiagnostics); + using (Assert.Multiple()) + { + _ = await Assert.That(Errors(compilation)).IsEmpty(); + _ = await Assert + .That(DiagnosticAssertions.Describe(diagnostics)) + .IsEqualTo(DiagnosticAssertions.NoDiagnostics); + } } [Test] @@ -404,10 +409,13 @@ public async Task Analyze_ManifestHeaderIsMalformed_ReportsTheParseProblemOnce() var diagnostics = await RunAsync(compilation, [manifest]).ConfigureAwait(false); var problems = AnalyzerRunner.OfId(diagnostics, DiagnosticIds.InvalidTestSurfaceManifest); - _ = await Assert.That(problems).Count().IsEqualTo(1); - _ = await Assert.That(DiagnosticAssertions.Describe(problems)).Contains("Line 1"); - _ = await Assert.That(DiagnosticAssertions.Describe(problems)).Contains("not-a-manifest"); - _ = await Assert.That(AnalyzerRunner.OfId(diagnostics, DiagnosticIds.UnreachableMutationPoint)).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(problems).Count().IsEqualTo(1); + _ = await Assert.That(DiagnosticAssertions.Describe(problems)).Contains("Line 1"); + _ = await Assert.That(DiagnosticAssertions.Describe(problems)).Contains("not-a-manifest"); + _ = await Assert.That(AnalyzerRunner.OfId(diagnostics, DiagnosticIds.UnreachableMutationPoint)).IsEmpty(); + } } [Test] @@ -422,10 +430,13 @@ public async Task Analyze_ManifestWithoutReferencedMembers_ExplainsTheManifestIn var diagnostics = await RunAsync(compilation, [manifest]).ConfigureAwait(false); var problems = AnalyzerRunner.OfId(diagnostics, DiagnosticIds.InvalidTestSurfaceManifest); - _ = await Assert.That(problems).Count().IsEqualTo(1); - _ = await Assert.That(DiagnosticAssertions.Describe(problems)).Contains("empty or stale"); - _ = await Assert.That(AnalyzerRunner.OfId(diagnostics, DiagnosticIds.UnreachableMutationPoint)).IsEmpty(); - _ = await Assert.That(AnalyzerRunner.OfId(diagnostics, DiagnosticIds.TrivialMutant)).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(problems).Count().IsEqualTo(1); + _ = await Assert.That(DiagnosticAssertions.Describe(problems)).Contains("empty or stale"); + _ = await Assert.That(AnalyzerRunner.OfId(diagnostics, DiagnosticIds.UnreachableMutationPoint)).IsEmpty(); + _ = await Assert.That(AnalyzerRunner.OfId(diagnostics, DiagnosticIds.TrivialMutant)).IsEmpty(); + } } [Test] @@ -439,12 +450,15 @@ public async Task Analyze_ManifestCollectedFromTheTestCompilation_ReportsOnlyThe var gaps = AnalyzerRunner.OfId(diagnostics, DiagnosticIds.UnreachableMutationPoint); var lines = DiagnosticAssertions.Summarise(gaps).Select(summary => summary.Line); - _ = await Assert.That(manifestText).Contains(CoveredMemberId); - _ = await Assert.That(manifestText.Contains("Shrink", StringComparison.Ordinal)).IsFalse(); - _ = await Assert.That(AnalyzerRunner.OfId(diagnostics, DiagnosticIds.InvalidTestSurfaceManifest)).IsEmpty(); - _ = await Assert.That(lines.Distinct()).IsEquivalentTo(new[] { UncoveredMemberLine }); - _ = await Assert.That(lines.Where(line => line == CoveredMemberLine)).IsEmpty(); - _ = await Assert.That(DiagnosticAssertions.Describe(gaps)).Contains("Mutation '/ => +'"); + using (Assert.Multiple()) + { + _ = await Assert.That(manifestText).Contains(CoveredMemberId); + _ = await Assert.That(manifestText.Contains("Shrink", StringComparison.Ordinal)).IsFalse(); + _ = await Assert.That(AnalyzerRunner.OfId(diagnostics, DiagnosticIds.InvalidTestSurfaceManifest)).IsEmpty(); + _ = await Assert.That(lines.Distinct()).IsEquivalentTo(new[] { UncoveredMemberLine }); + _ = await Assert.That(lines.Where(line => line == CoveredMemberLine)).IsEmpty(); + _ = await Assert.That(DiagnosticAssertions.Describe(gaps)).Contains("Mutation '/ => +'"); + } } /// @@ -460,8 +474,11 @@ public async Task Analyze_ManifestNamesOnlyTheEntryMethod_TreatsTheCalledHelperA var diagnostics = await RunAsync(compilation, [CreateManifest(EntryMemberId)]).ConfigureAwait(false); - _ = await Assert.That(Errors(compilation)).IsEmpty(); - _ = await Assert.That(AnalyzerRunner.OfId(diagnostics, DiagnosticIds.InvalidTestSurfaceManifest)).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(Errors(compilation)).IsEmpty(); + _ = await Assert.That(AnalyzerRunner.OfId(diagnostics, DiagnosticIds.InvalidTestSurfaceManifest)).IsEmpty(); + } _ = await Verify(Snapshot(diagnostics)).ConfigureAwait(false); } @@ -476,13 +493,16 @@ public async Task Analyze_MutationCannotBeObserved_ReportsItAsTrivialInsteadOfAs AnalyzerRunner.OfId(diagnostics, DiagnosticIds.UnreachableMutationPoint) ); - _ = await Assert - .That(trivial.Select(summary => summary.Line).Distinct()) - .IsEquivalentTo(new[] { TrivialMutationLine }); - _ = await Assert - .That(gaps.Select(summary => summary.Line).Distinct()) - .IsEquivalentTo(new[] { TrivialFixtureGapLine }); - _ = await Assert.That(trivial.Select(summary => summary.Message)).Contains(DiscardedTrivialMessage); + using (Assert.Multiple()) + { + _ = await Assert + .That(trivial.Select(summary => summary.Line).Distinct()) + .IsEquivalentTo(new[] { TrivialMutationLine }); + _ = await Assert + .That(gaps.Select(summary => summary.Line).Distinct()) + .IsEquivalentTo(new[] { TrivialFixtureGapLine }); + _ = await Assert.That(trivial.Select(summary => summary.Message)).Contains(DiscardedTrivialMessage); + } } [Test] @@ -502,11 +522,14 @@ public async Task Analyze_TrivialMutantsAreNotReported_KeepsTheGapsUntouched() ) .ConfigureAwait(false); - _ = await Assert.That(AnalyzerRunner.OfId(reported, DiagnosticIds.TrivialMutant)).Count().IsEqualTo(5); - _ = await Assert.That(AnalyzerRunner.OfId(suppressed, DiagnosticIds.TrivialMutant)).IsEmpty(); - _ = await Assert - .That(Describe(suppressed, DiagnosticIds.UnreachableMutationPoint)) - .IsEqualTo(Describe(reported, DiagnosticIds.UnreachableMutationPoint)); + using (Assert.Multiple()) + { + _ = await Assert.That(AnalyzerRunner.OfId(reported, DiagnosticIds.TrivialMutant)).Count().IsEqualTo(5); + _ = await Assert.That(AnalyzerRunner.OfId(suppressed, DiagnosticIds.TrivialMutant)).IsEmpty(); + _ = await Assert + .That(Describe(suppressed, DiagnosticIds.UnreachableMutationPoint)) + .IsEqualTo(Describe(reported, DiagnosticIds.UnreachableMutationPoint)); + } } [Test] @@ -541,11 +564,14 @@ public async Task Analyze_MutantDoesNotCompile_IsOnlyReportedWithoutVerification AnalyzerRunner.OfId(unverified, DiagnosticIds.UnreachableMutationPoint) ); - _ = await Assert.That(Errors(compilation)).IsEmpty(); - _ = await Assert.That(AnalyzerRunner.OfId(verified, DiagnosticIds.InvalidTestSurfaceManifest)).IsEmpty(); - _ = await Assert.That(AnalyzerRunner.OfId(verified, DiagnosticIds.UnreachableMutationPoint)).IsEmpty(); - _ = await Assert.That(reported.Select(summary => summary.Line)).IsEquivalentTo(new[] { ElapsedMemberLine }); - _ = await Assert.That(DiagnosticAssertions.Describe(unverified)).Contains("Mutation '- => +'"); + using (Assert.Multiple()) + { + _ = await Assert.That(Errors(compilation)).IsEmpty(); + _ = await Assert.That(AnalyzerRunner.OfId(verified, DiagnosticIds.InvalidTestSurfaceManifest)).IsEmpty(); + _ = await Assert.That(AnalyzerRunner.OfId(verified, DiagnosticIds.UnreachableMutationPoint)).IsEmpty(); + _ = await Assert.That(reported.Select(summary => summary.Line)).IsEquivalentTo(new[] { ElapsedMemberLine }); + _ = await Assert.That(DiagnosticAssertions.Describe(unverified)).Contains("Mutation '- => +'"); + } } /// @@ -607,9 +633,12 @@ public async Task Analyze_CompilationUsesEveryLanguageFeature_ReportsWithoutCras var diagnostics = await RunAsync(compilation, [CreateManifest(DescribeMemberId)]).ConfigureAwait(false); - _ = await Assert.That(Errors(compilation)).IsEmpty(); - _ = await Assert.That(DiagnosticAssertions.Ids(diagnostics).Where(IsAnalyzerFailure)).IsEmpty(); - _ = await Assert.That(AnalyzerRunner.OfId(diagnostics, DiagnosticIds.InvalidTestSurfaceManifest)).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(Errors(compilation)).IsEmpty(); + _ = await Assert.That(DiagnosticAssertions.Ids(diagnostics).Where(IsAnalyzerFailure)).IsEmpty(); + _ = await Assert.That(AnalyzerRunner.OfId(diagnostics, DiagnosticIds.InvalidTestSurfaceManifest)).IsEmpty(); + } _ = await Verify(Snapshot(diagnostics)).ConfigureAwait(false); } @@ -627,16 +656,19 @@ public async Task Analyze_MemberIsReachedByOneSingleCaseTest_ReportsTheSingleTes var diagnostics = await RunAsync(compilation, [manifest]).ConfigureAwait(false); - _ = await Assert.That(Errors(compilation)).IsEmpty(); - _ = await Assert.That(DiagnosticAssertions.Ids(diagnostics).Where(IsAnalyzerFailure)).IsEmpty(); - _ = await Assert.That(AnalyzerRunner.OfId(diagnostics, DiagnosticIds.InvalidTestSurfaceManifest)).IsEmpty(); - _ = await Assert - .That(SingleTestCaseLines(diagnostics).Distinct()) - .IsEquivalentTo(new[] { AddMemberLine, NormalizeMemberLine }); - _ = await Assert.That(GapLines(diagnostics).Distinct()).IsEquivalentTo(new[] { MultiplyMemberLine }); - _ = await Assert - .That(SingleTestCaseMethods(diagnostics).Distinct(StringComparer.Ordinal)) - .IsEquivalentTo(new[] { FirstAddTestName }); + using (Assert.Multiple()) + { + _ = await Assert.That(Errors(compilation)).IsEmpty(); + _ = await Assert.That(DiagnosticAssertions.Ids(diagnostics).Where(IsAnalyzerFailure)).IsEmpty(); + _ = await Assert.That(AnalyzerRunner.OfId(diagnostics, DiagnosticIds.InvalidTestSurfaceManifest)).IsEmpty(); + _ = await Assert + .That(SingleTestCaseLines(diagnostics).Distinct()) + .IsEquivalentTo(new[] { AddMemberLine, NormalizeMemberLine }); + _ = await Assert.That(GapLines(diagnostics).Distinct()).IsEquivalentTo(new[] { MultiplyMemberLine }); + _ = await Assert + .That(SingleTestCaseMethods(diagnostics).Distinct(StringComparer.Ordinal)) + .IsEquivalentTo(new[] { FirstAddTestName }); + } } /// @@ -654,8 +686,11 @@ public async Task Analyze_MemberIsReachedByTwoSingleCaseTests_DoesNotReportTheSi var diagnostics = await RunAsync(compilation, [manifest]).ConfigureAwait(false); - _ = await Assert.That(SingleTestCaseDiagnostics(diagnostics)).IsEmpty(); - _ = await Assert.That(GapLines(diagnostics).Distinct()).IsEquivalentTo(new[] { MultiplyMemberLine }); + using (Assert.Multiple()) + { + _ = await Assert.That(SingleTestCaseDiagnostics(diagnostics)).IsEmpty(); + _ = await Assert.That(GapLines(diagnostics).Distinct()).IsEquivalentTo(new[] { MultiplyMemberLine }); + } } /// @@ -670,8 +705,11 @@ public async Task Analyze_MemberIsReachedByOneTestWithThreeCases_DoesNotReportTh var diagnostics = await RunAsync(compilation, [manifest]).ConfigureAwait(false); - _ = await Assert.That(SingleTestCaseDiagnostics(diagnostics)).IsEmpty(); - _ = await Assert.That(GapLines(diagnostics).Distinct()).IsEquivalentTo(new[] { MultiplyMemberLine }); + using (Assert.Multiple()) + { + _ = await Assert.That(SingleTestCaseDiagnostics(diagnostics)).IsEmpty(); + _ = await Assert.That(GapLines(diagnostics).Distinct()).IsEquivalentTo(new[] { MultiplyMemberLine }); + } } /// @@ -687,8 +725,11 @@ public async Task Analyze_MemberIsReachedByOneTestWithALowerBound_DoesNotReportT var diagnostics = await RunAsync(compilation, [manifest]).ConfigureAwait(false); - _ = await Assert.That(SingleTestCaseDiagnostics(diagnostics)).IsEmpty(); - _ = await Assert.That(GapLines(diagnostics).Distinct()).IsEquivalentTo(new[] { MultiplyMemberLine }); + using (Assert.Multiple()) + { + _ = await Assert.That(SingleTestCaseDiagnostics(diagnostics)).IsEmpty(); + _ = await Assert.That(GapLines(diagnostics).Distinct()).IsEquivalentTo(new[] { MultiplyMemberLine }); + } } /// @@ -707,8 +748,11 @@ public async Task Analyze_MemberIsReachedByASingleCaseTestAndALowerBound_DoesNot var diagnostics = await RunAsync(compilation, [manifest]).ConfigureAwait(false); - _ = await Assert.That(SingleTestCaseDiagnostics(diagnostics)).IsEmpty(); - _ = await Assert.That(GapLines(diagnostics).Distinct()).IsEquivalentTo(new[] { MultiplyMemberLine }); + using (Assert.Multiple()) + { + _ = await Assert.That(SingleTestCaseDiagnostics(diagnostics)).IsEmpty(); + _ = await Assert.That(GapLines(diagnostics).Distinct()).IsEquivalentTo(new[] { MultiplyMemberLine }); + } } /// @@ -725,10 +769,13 @@ public async Task Analyze_TwoManifestsEachNameOneSingleCaseTest_AggregatesThemTo var merged = await RunAsync(compilation, [first, second]).ConfigureAwait(false); - _ = await Assert - .That(SingleTestCaseLines(alone).Distinct()) - .IsEquivalentTo(new[] { AddMemberLine, NormalizeMemberLine }); - _ = await Assert.That(SingleTestCaseDiagnostics(merged)).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert + .That(SingleTestCaseLines(alone).Distinct()) + .IsEquivalentTo(new[] { AddMemberLine, NormalizeMemberLine }); + _ = await Assert.That(SingleTestCaseDiagnostics(merged)).IsEmpty(); + } } /// @@ -744,13 +791,16 @@ public async Task Analyze_TwoManifestsNameTheSameSingleCaseTest_StillCountsOneCa var diagnostics = await RunAsync(compilation, [first, second]).ConfigureAwait(false); - _ = await Assert.That(AnalyzerRunner.OfId(diagnostics, DiagnosticIds.InvalidTestSurfaceManifest)).IsEmpty(); - _ = await Assert - .That(SingleTestCaseLines(diagnostics).Distinct()) - .IsEquivalentTo(new[] { AddMemberLine, NormalizeMemberLine }); - _ = await Assert - .That(SingleTestCaseMethods(diagnostics).Distinct(StringComparer.Ordinal)) - .IsEquivalentTo(new[] { FirstAddTestName }); + using (Assert.Multiple()) + { + _ = await Assert.That(AnalyzerRunner.OfId(diagnostics, DiagnosticIds.InvalidTestSurfaceManifest)).IsEmpty(); + _ = await Assert + .That(SingleTestCaseLines(diagnostics).Distinct()) + .IsEquivalentTo(new[] { AddMemberLine, NormalizeMemberLine }); + _ = await Assert + .That(SingleTestCaseMethods(diagnostics).Distinct(StringComparer.Ordinal)) + .IsEquivalentTo(new[] { FirstAddTestName }); + } } /// @@ -767,11 +817,14 @@ public async Task Analyze_TrivialMutantIsReachedByOneSingleCaseTest_ReportsOnlyT var diagnostics = await RunAsync(compilation, [manifest]).ConfigureAwait(false); var trivial = DiagnosticAssertions.Summarise(AnalyzerRunner.OfId(diagnostics, DiagnosticIds.TrivialMutant)); - _ = await Assert - .That(trivial.Select(summary => summary.Line).Distinct()) - .IsEquivalentTo(new[] { TrivialMutationLine }); - _ = await Assert.That(SingleTestCaseDiagnostics(diagnostics)).IsEmpty(); - _ = await Assert.That(GapLines(diagnostics).Distinct()).IsEquivalentTo(new[] { TrivialFixtureGapLine }); + using (Assert.Multiple()) + { + _ = await Assert + .That(trivial.Select(summary => summary.Line).Distinct()) + .IsEquivalentTo(new[] { TrivialMutationLine }); + _ = await Assert.That(SingleTestCaseDiagnostics(diagnostics)).IsEmpty(); + _ = await Assert.That(GapLines(diagnostics).Distinct()).IsEquivalentTo(new[] { TrivialFixtureGapLine }); + } } /// @@ -796,9 +849,12 @@ public async Task Analyze_MutantBudgetIsOneAndOneTestCaseReaches_BoundsTheSingle ) .ConfigureAwait(false); - _ = await Assert.That(SingleTestCaseDiagnostics(unlimited)).Count().IsEqualTo(CombineMutantCount); - _ = await Assert.That(SingleTestCaseDiagnostics(limited)).Count().IsEqualTo(1); - _ = await Assert.That(SingleTestCaseLines(limited)).IsEquivalentTo(new[] { CombineMemberLine }); + using (Assert.Multiple()) + { + _ = await Assert.That(SingleTestCaseDiagnostics(unlimited)).Count().IsEqualTo(CombineMutantCount); + _ = await Assert.That(SingleTestCaseDiagnostics(limited)).Count().IsEqualTo(1); + _ = await Assert.That(SingleTestCaseLines(limited)).IsEquivalentTo(new[] { CombineMemberLine }); + } } [Test] @@ -824,12 +880,15 @@ public async Task Analyze_ManifestContentIsNotAvailable_ReportsTheUnreadableFile var diagnostics = await RunAsync(compilation, [InMemoryAdditionalText.WithoutContent()]).ConfigureAwait(false); var problems = AnalyzerRunner.OfId(diagnostics, DiagnosticIds.InvalidTestSurfaceManifest); - _ = await Assert.That(problems).Count().IsEqualTo(1); - _ = await Assert - .That(DiagnosticAssertions.Describe(problems)) - .Contains("the content of the additional file is not available to the analyzer"); - _ = await Assert.That(AnalyzerRunner.OfId(diagnostics, DiagnosticIds.UnreachableMutationPoint)).IsEmpty(); - _ = await Assert.That(AnalyzerRunner.OfId(diagnostics, DiagnosticIds.TrivialMutant)).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(problems).Count().IsEqualTo(1); + _ = await Assert + .That(DiagnosticAssertions.Describe(problems)) + .Contains("the content of the additional file is not available to the analyzer"); + _ = await Assert.That(AnalyzerRunner.OfId(diagnostics, DiagnosticIds.UnreachableMutationPoint)).IsEmpty(); + _ = await Assert.That(AnalyzerRunner.OfId(diagnostics, DiagnosticIds.TrivialMutant)).IsEmpty(); + } } /// @@ -844,11 +903,14 @@ public async Task Analyze_RecordedMembersResolveToNothing_ExplainsTheForeignMani var diagnostics = await RunAsync(compilation, [CreateManifest(GhostMemberId)]).ConfigureAwait(false); var problems = AnalyzerRunner.OfId(diagnostics, DiagnosticIds.InvalidTestSurfaceManifest); - _ = await Assert.That(problems).Count().IsEqualTo(1); - _ = await Assert - .That(DiagnosticAssertions.Describe(problems)) - .Contains("belongs to a different project or is stale"); - _ = await Assert.That(AnalyzerRunner.OfId(diagnostics, DiagnosticIds.UnreachableMutationPoint)).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(problems).Count().IsEqualTo(1); + _ = await Assert + .That(DiagnosticAssertions.Describe(problems)) + .Contains("belongs to a different project or is stale"); + _ = await Assert.That(AnalyzerRunner.OfId(diagnostics, DiagnosticIds.UnreachableMutationPoint)).IsEmpty(); + } } /// @@ -865,11 +927,14 @@ public async Task Analyze_OneManifestIsMalformedAndOneIsUsable_ReportsTheBrokenF var diagnostics = await RunAsync(compilation, [broken, usable]).ConfigureAwait(false); var problems = AnalyzerRunner.OfId(diagnostics, DiagnosticIds.InvalidTestSurfaceManifest); - _ = await Assert.That(problems).Count().IsEqualTo(1); - _ = await Assert.That(DiagnosticAssertions.Describe(problems)).Contains(BrokenManifestPath); - _ = await Assert - .That(GapLines(diagnostics).Distinct()) - .IsEquivalentTo(new[] { BetaMemberLine, GammaMemberLine }); + using (Assert.Multiple()) + { + _ = await Assert.That(problems).Count().IsEqualTo(1); + _ = await Assert.That(DiagnosticAssertions.Describe(problems)).Contains(BrokenManifestPath); + _ = await Assert + .That(GapLines(diagnostics).Distinct()) + .IsEquivalentTo(new[] { BetaMemberLine, GammaMemberLine }); + } } /// diff --git a/tests/NetEvolve.FrameShift.Tests.Integration/Analyzers/NUnitTestSurfaceAnalyzerTests.cs b/tests/NetEvolve.FrameShift.Tests.Integration/Analyzers/NUnitTestSurfaceAnalyzerTests.cs index cd044d6..665b6a5 100644 --- a/tests/NetEvolve.FrameShift.Tests.Integration/Analyzers/NUnitTestSurfaceAnalyzerTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Integration/Analyzers/NUnitTestSurfaceAnalyzerTests.cs @@ -190,8 +190,11 @@ public async Task Fixtures_BothAssemblies_CompileWithoutErrors() var production = CreateProduction(); var test = CreateTest(production); - _ = await Assert.That(Describe(production)).IsEqualTo(DiagnosticAssertions.NoDiagnostics); - _ = await Assert.That(Describe(test)).IsEqualTo(DiagnosticAssertions.NoDiagnostics); + using (Assert.Multiple()) + { + _ = await Assert.That(Describe(production)).IsEqualTo(DiagnosticAssertions.NoDiagnostics); + _ = await Assert.That(Describe(test)).IsEqualTo(DiagnosticAssertions.NoDiagnostics); + } } /// @@ -234,11 +237,14 @@ public async Task Analyzer_TestWithoutProductionReference_IsReportedOnceAtItsIde var diagnostics = await RunAsync(test, DiagnosticIds.TestWithoutProductionReference).ConfigureAwait(false); - _ = await Assert.That(diagnostics).Count().IsEqualTo(1); - _ = await Assert.That(diagnostics[0].Location.SourceSpan).IsEqualTo(identifier.Span); - _ = await Assert - .That(GetMessage(diagnostics[0]).Contains(LocalOnlyTestName, StringComparison.Ordinal)) - .IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(diagnostics).Count().IsEqualTo(1); + _ = await Assert.That(diagnostics[0].Location.SourceSpan).IsEqualTo(identifier.Span); + _ = await Assert + .That(GetMessage(diagnostics[0]).Contains(LocalOnlyTestName, StringComparison.Ordinal)) + .IsTrue(); + } } [Test] @@ -364,10 +370,15 @@ public async Task Analyzer_EveryManifestShape_NeverCrashes() reported.AddRange(DiagnosticAssertions.Ids(await RunAllAsync(test, shape).ConfigureAwait(false))); } - _ = await Assert.That(reported.Contains(AnalyzerRunner.AnalyzerFailureId, StringComparer.Ordinal)).IsFalse(); - _ = await Assert - .That(reported.Contains(DiagnosticIds.TestWithoutProductionReference, StringComparer.Ordinal)) - .IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert + .That(reported.Contains(AnalyzerRunner.AnalyzerFailureId, StringComparer.Ordinal)) + .IsFalse(); + _ = await Assert + .That(reported.Contains(DiagnosticIds.TestWithoutProductionReference, StringComparer.Ordinal)) + .IsTrue(); + } } [Test] diff --git a/tests/NetEvolve.FrameShift.Tests.Integration/Analyzers/TUnitTestSurfaceAnalyzerTests.cs b/tests/NetEvolve.FrameShift.Tests.Integration/Analyzers/TUnitTestSurfaceAnalyzerTests.cs index e3077cf..05e1e39 100644 --- a/tests/NetEvolve.FrameShift.Tests.Integration/Analyzers/TUnitTestSurfaceAnalyzerTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Integration/Analyzers/TUnitTestSurfaceAnalyzerTests.cs @@ -321,12 +321,15 @@ public async Task Fixtures_BothAssemblies_CompileWithoutErrors() var production = CreateProduction(); var test = CreateTest(production); - _ = await Assert - .That(DiagnosticAssertions.Describe(CompilationFactory.GetCompileErrors(production))) - .IsEqualTo(DiagnosticAssertions.NoDiagnostics); - _ = await Assert - .That(DiagnosticAssertions.Describe(CompilationFactory.GetCompileErrors(test))) - .IsEqualTo(DiagnosticAssertions.NoDiagnostics); + using (Assert.Multiple()) + { + _ = await Assert + .That(DiagnosticAssertions.Describe(CompilationFactory.GetCompileErrors(production))) + .IsEqualTo(DiagnosticAssertions.NoDiagnostics); + _ = await Assert + .That(DiagnosticAssertions.Describe(CompilationFactory.GetCompileErrors(test))) + .IsEqualTo(DiagnosticAssertions.NoDiagnostics); + } } /// @@ -362,11 +365,14 @@ public async Task Analyzer_TestWithoutProductionReference_IsReportedOnceAtItsIde var diagnostics = await RunAsync(test, DiagnosticIds.TestWithoutProductionReference).ConfigureAwait(false); - _ = await Assert.That(diagnostics).Count().IsEqualTo(1); - _ = await Assert.That(diagnostics[0].Location.SourceSpan).IsEqualTo(identifier.Span); - _ = await Assert - .That(GetMessage(diagnostics[0]).Contains(LocalOnlyTestName, StringComparison.Ordinal)) - .IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(diagnostics).Count().IsEqualTo(1); + _ = await Assert.That(diagnostics[0].Location.SourceSpan).IsEqualTo(identifier.Span); + _ = await Assert + .That(GetMessage(diagnostics[0]).Contains(LocalOnlyTestName, StringComparison.Ordinal)) + .IsTrue(); + } } [Test] @@ -418,14 +424,17 @@ public async Task Analyzer_PartialTestWithoutProductionReference_IsReportedOnceA var diagnostics = await RunAsync(test, DiagnosticIds.TestWithoutProductionReference).ConfigureAwait(false); - _ = await Assert - .That(DiagnosticAssertions.Describe(CompilationFactory.GetCompileErrors(test))) - .IsEqualTo(DiagnosticAssertions.NoDiagnostics); - _ = await Assert.That(diagnostics).Count().IsEqualTo(1); - _ = await Assert.That(diagnostics[0].Location.SourceSpan).IsEqualTo(identifier.Span); - _ = await Assert - .That(GetMessage(diagnostics[0]).Contains(PartialLocalOnlyTestName, StringComparison.Ordinal)) - .IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert + .That(DiagnosticAssertions.Describe(CompilationFactory.GetCompileErrors(test))) + .IsEqualTo(DiagnosticAssertions.NoDiagnostics); + _ = await Assert.That(diagnostics).Count().IsEqualTo(1); + _ = await Assert.That(diagnostics[0].Location.SourceSpan).IsEqualTo(identifier.Span); + _ = await Assert + .That(GetMessage(diagnostics[0]).Contains(PartialLocalOnlyTestName, StringComparison.Ordinal)) + .IsTrue(); + } } [Test] @@ -455,11 +464,14 @@ public async Task Analyzer_ExoticallyShapedTestsWithoutProductionReference_Repor var messages = diagnostics.Select(diagnostic => GetMessage(diagnostic)).ToImmutableArray(); var mentions = _exoticTestNames.Select(name => CountMentions(messages, name)); - _ = await Assert.That(diagnostics.Length).IsEqualTo(_exoticTestNames.Length); - _ = await Assert.That(Describe(mentions)).IsEqualTo("1, 1, 1, 1"); - _ = await Assert - .That(Describe(diagnostics.Select(diagnostic => diagnostic.Location.SourceSpan))) - .IsEqualTo(Describe(expected)); + using (Assert.Multiple()) + { + _ = await Assert.That(diagnostics.Length).IsEqualTo(_exoticTestNames.Length); + _ = await Assert.That(Describe(mentions)).IsEqualTo("1, 1, 1, 1"); + _ = await Assert + .That(Describe(diagnostics.Select(diagnostic => diagnostic.Location.SourceSpan))) + .IsEqualTo(Describe(expected)); + } } /// @@ -482,9 +494,12 @@ public async Task Discovery_ExoticallyShapedTests_YieldAMethodDeclarationAndADec string.IsNullOrEmpty(DocumentationCommentId.CreateDeclarationId(method.OriginalDefinition)) ); - _ = await Assert.That(methods.Length).IsEqualTo(_exoticTestNames.Length); - _ = await Assert.That(Describe(withoutDeclaration.Select(method => method.Name))).IsEqualTo(string.Empty); - _ = await Assert.That(Describe(withoutDeclarationId.Select(method => method.Name))).IsEqualTo(string.Empty); + using (Assert.Multiple()) + { + _ = await Assert.That(methods.Length).IsEqualTo(_exoticTestNames.Length); + _ = await Assert.That(Describe(withoutDeclaration.Select(method => method.Name))).IsEqualTo(string.Empty); + _ = await Assert.That(Describe(withoutDeclarationId.Select(method => method.Name))).IsEqualTo(string.Empty); + } } private static bool HasMethodDeclaration(IMethodSymbol method) => @@ -560,8 +575,13 @@ public async Task Analyzer_ManifestDifferingOnlyInFormatting_ReportsNoManifestPr var diagnostics = await RunAsync(test, DiagnosticIds.InvalidTestSurfaceManifest, reformatted) .ConfigureAwait(false); - _ = await Assert.That(reformatted).IsNotEqualTo(manifest); - _ = await Assert.That(DiagnosticAssertions.Describe(diagnostics)).IsEqualTo(DiagnosticAssertions.NoDiagnostics); + using (Assert.Multiple()) + { + _ = await Assert.That(reformatted).IsNotEqualTo(manifest); + _ = await Assert + .That(DiagnosticAssertions.Describe(diagnostics)) + .IsEqualTo(DiagnosticAssertions.NoDiagnostics); + } } [Test] @@ -649,10 +669,15 @@ public async Task Analyzer_EveryManifestShape_NeverCrashes() reported.AddRange(DiagnosticAssertions.Ids(await RunAllAsync(test, shape).ConfigureAwait(false))); } - _ = await Assert.That(reported.Contains(AnalyzerRunner.AnalyzerFailureId, StringComparer.Ordinal)).IsFalse(); - _ = await Assert - .That(reported.Contains(DiagnosticIds.TestWithoutProductionReference, StringComparer.Ordinal)) - .IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert + .That(reported.Contains(AnalyzerRunner.AnalyzerFailureId, StringComparer.Ordinal)) + .IsFalse(); + _ = await Assert + .That(reported.Contains(DiagnosticIds.TestWithoutProductionReference, StringComparer.Ordinal)) + .IsTrue(); + } } private static IEnumerable GetManifestShapes(string manifest) => @@ -751,12 +776,15 @@ public async Task Analyzer_ProbeIsNotRegistered_LeadsTheManifestComparisonItself ) .ConfigureAwait(false); - _ = await Assert - .That(DiagnosticAssertions.Describe(CompilationFactory.GetCompileErrors(compilation))) - .IsEqualTo(DiagnosticAssertions.NoDiagnostics); - _ = await Assert - .That(DiagnosticAssertions.Describe(diagnostics)) - .IsEqualTo(DescribeManifestProblem(MalformedHeaderDetail)); + using (Assert.Multiple()) + { + _ = await Assert + .That(DiagnosticAssertions.Describe(CompilationFactory.GetCompileErrors(compilation))) + .IsEqualTo(DiagnosticAssertions.NoDiagnostics); + _ = await Assert + .That(DiagnosticAssertions.Describe(diagnostics)) + .IsEqualTo(DescribeManifestProblem(MalformedHeaderDetail)); + } } /// @@ -772,8 +800,11 @@ public async Task Analyzer_ProbeIsNotRegistered_StillReportsItsTestsWithoutProdu .RunAsync(new UnregisteredFrameworkAnalyzer(), compilation, DiagnosticIds.TestWithoutProductionReference) .ConfigureAwait(false); - _ = await Assert.That(diagnostics).Count().IsEqualTo(1); - _ = await Assert.That(GetMessage(diagnostics[0]).Contains("LocalOnly", StringComparison.Ordinal)).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(diagnostics).Count().IsEqualTo(1); + _ = await Assert.That(GetMessage(diagnostics[0]).Contains("LocalOnly", StringComparison.Ordinal)).IsTrue(); + } } private static Task> RunWithFilesAsync( diff --git a/tests/NetEvolve.FrameShift.Tests.Integration/Analyzers/TestMarkerRecognitionTests.cs b/tests/NetEvolve.FrameShift.Tests.Integration/Analyzers/TestMarkerRecognitionTests.cs index f5876fc..5700b2b 100644 --- a/tests/NetEvolve.FrameShift.Tests.Integration/Analyzers/TestMarkerRecognitionTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Integration/Analyzers/TestMarkerRecognitionTests.cs @@ -841,9 +841,12 @@ public async Task RoundTrip_TUnitTestMarkedWithDynamicTestBuilder_ReportsNoGapFo .ConfigureAwait(false); var problems = DescribeManifestProblems(cycle.Diagnostics); - _ = await Assert.That(DescribeRecordedMembers(cycle.Manifest)).IsEqualTo(ExercisedMember); - _ = await Assert.That(DescribeGaps(cycle.Diagnostics)).IsEqualTo(UntouchedMember); - _ = await Assert.That(problems).IsEqualTo(DiagnosticAssertions.NoDiagnostics); + using (Assert.Multiple()) + { + _ = await Assert.That(DescribeRecordedMembers(cycle.Manifest)).IsEqualTo(ExercisedMember); + _ = await Assert.That(DescribeGaps(cycle.Diagnostics)).IsEqualTo(UntouchedMember); + _ = await Assert.That(problems).IsEqualTo(DiagnosticAssertions.NoDiagnostics); + } } /// @@ -876,8 +879,11 @@ public async Task RoundTrip_EveryMarkerOfAFramework_ReportsNoGapForTheMethodItsT .ConfigureAwait(false); var problems = DescribeManifestProblems(cycle.Diagnostics); - _ = await Assert.That(DescribeGaps(cycle.Diagnostics)).IsEqualTo(NothingExercised); - _ = await Assert.That(problems).IsEqualTo(DiagnosticAssertions.NoDiagnostics); + using (Assert.Multiple()) + { + _ = await Assert.That(DescribeGaps(cycle.Diagnostics)).IsEqualTo(NothingExercised); + _ = await Assert.That(problems).IsEqualTo(DiagnosticAssertions.NoDiagnostics); + } } /// @@ -935,8 +941,11 @@ public async Task RoundTrip_MethodCarryingOnlyADataSource_StillReportsItsProduct .ConfigureAwait(false); var problems = DescribeManifestProblems(cycle.Diagnostics); - _ = await Assert.That(DescribeGaps(cycle.Diagnostics)).IsEqualTo(UntouchedMember); - _ = await Assert.That(problems).IsEqualTo(DiagnosticAssertions.NoDiagnostics); + using (Assert.Multiple()) + { + _ = await Assert.That(DescribeGaps(cycle.Diagnostics)).IsEqualTo(UntouchedMember); + _ = await Assert.That(problems).IsEqualTo(DiagnosticAssertions.NoDiagnostics); + } } /// diff --git a/tests/NetEvolve.FrameShift.Tests.Integration/Analyzers/XunitV2TestSurfaceAnalyzerTests.cs b/tests/NetEvolve.FrameShift.Tests.Integration/Analyzers/XunitV2TestSurfaceAnalyzerTests.cs index 459a771..ee42745 100644 --- a/tests/NetEvolve.FrameShift.Tests.Integration/Analyzers/XunitV2TestSurfaceAnalyzerTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Integration/Analyzers/XunitV2TestSurfaceAnalyzerTests.cs @@ -182,8 +182,11 @@ public async Task Fixtures_BothAssemblies_CompileWithoutErrors() var production = CreateProduction(); var test = CreateTest(production); - _ = await Assert.That(Describe(production)).IsEqualTo(DiagnosticAssertions.NoDiagnostics); - _ = await Assert.That(Describe(test)).IsEqualTo(DiagnosticAssertions.NoDiagnostics); + using (Assert.Multiple()) + { + _ = await Assert.That(Describe(production)).IsEqualTo(DiagnosticAssertions.NoDiagnostics); + _ = await Assert.That(Describe(test)).IsEqualTo(DiagnosticAssertions.NoDiagnostics); + } } /// @@ -219,11 +222,14 @@ public async Task Analyzer_TestWithoutProductionReference_IsReportedOnceAtItsIde var diagnostics = await RunAsync(test, DiagnosticIds.TestWithoutProductionReference).ConfigureAwait(false); - _ = await Assert.That(diagnostics).Count().IsEqualTo(1); - _ = await Assert.That(diagnostics[0].Location.SourceSpan).IsEqualTo(identifier.Span); - _ = await Assert - .That(GetMessage(diagnostics[0]).Contains(LocalOnlyTestName, StringComparison.Ordinal)) - .IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(diagnostics).Count().IsEqualTo(1); + _ = await Assert.That(diagnostics[0].Location.SourceSpan).IsEqualTo(identifier.Span); + _ = await Assert + .That(GetMessage(diagnostics[0]).Contains(LocalOnlyTestName, StringComparison.Ordinal)) + .IsTrue(); + } } [Test] @@ -362,13 +368,16 @@ public async Task Analyzer_ProjectOnTheOtherXunitVersion_StaysSilentWhileTheOthe ) .ConfigureAwait(false); - _ = await Assert - .That(DiagnosticAssertions.Describe(ownDiagnostics)) - .IsEqualTo(DiagnosticAssertions.NoDiagnostics); - _ = await Assert.That(otherDiagnostics).Count().IsEqualTo(1); - _ = await Assert - .That(GetMessage(otherDiagnostics[0]).Contains(LocalOnlyTestName, StringComparison.Ordinal)) - .IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert + .That(DiagnosticAssertions.Describe(ownDiagnostics)) + .IsEqualTo(DiagnosticAssertions.NoDiagnostics); + _ = await Assert.That(otherDiagnostics).Count().IsEqualTo(1); + _ = await Assert + .That(GetMessage(otherDiagnostics[0]).Contains(LocalOnlyTestName, StringComparison.Ordinal)) + .IsTrue(); + } } #endif @@ -387,10 +396,15 @@ public async Task Analyzer_EveryManifestShape_NeverCrashes() reported.AddRange(DiagnosticAssertions.Ids(await RunAllAsync(test, shape).ConfigureAwait(false))); } - _ = await Assert.That(reported.Contains(AnalyzerRunner.AnalyzerFailureId, StringComparer.Ordinal)).IsFalse(); - _ = await Assert - .That(reported.Contains(DiagnosticIds.TestWithoutProductionReference, StringComparer.Ordinal)) - .IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert + .That(reported.Contains(AnalyzerRunner.AnalyzerFailureId, StringComparer.Ordinal)) + .IsFalse(); + _ = await Assert + .That(reported.Contains(DiagnosticIds.TestWithoutProductionReference, StringComparer.Ordinal)) + .IsTrue(); + } } [Test] diff --git a/tests/NetEvolve.FrameShift.Tests.Integration/Analyzers/XunitV3TestSurfaceAnalyzerTests.cs b/tests/NetEvolve.FrameShift.Tests.Integration/Analyzers/XunitV3TestSurfaceAnalyzerTests.cs index b1a138e..82cc32d 100644 --- a/tests/NetEvolve.FrameShift.Tests.Integration/Analyzers/XunitV3TestSurfaceAnalyzerTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Integration/Analyzers/XunitV3TestSurfaceAnalyzerTests.cs @@ -185,8 +185,11 @@ public async Task Fixtures_BothAssemblies_CompileWithoutErrors() var production = CreateProduction(); var test = CreateTest(production); - _ = await Assert.That(Describe(production)).IsEqualTo(DiagnosticAssertions.NoDiagnostics); - _ = await Assert.That(Describe(test)).IsEqualTo(DiagnosticAssertions.NoDiagnostics); + using (Assert.Multiple()) + { + _ = await Assert.That(Describe(production)).IsEqualTo(DiagnosticAssertions.NoDiagnostics); + _ = await Assert.That(Describe(test)).IsEqualTo(DiagnosticAssertions.NoDiagnostics); + } } /// @@ -222,11 +225,14 @@ public async Task Analyzer_TestWithoutProductionReference_IsReportedOnceAtItsIde var diagnostics = await RunAsync(test, DiagnosticIds.TestWithoutProductionReference).ConfigureAwait(false); - _ = await Assert.That(diagnostics).Count().IsEqualTo(1); - _ = await Assert.That(diagnostics[0].Location.SourceSpan).IsEqualTo(identifier.Span); - _ = await Assert - .That(GetMessage(diagnostics[0]).Contains(LocalOnlyTestName, StringComparison.Ordinal)) - .IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(diagnostics).Count().IsEqualTo(1); + _ = await Assert.That(diagnostics[0].Location.SourceSpan).IsEqualTo(identifier.Span); + _ = await Assert + .That(GetMessage(diagnostics[0]).Contains(LocalOnlyTestName, StringComparison.Ordinal)) + .IsTrue(); + } } [Test] @@ -360,13 +366,16 @@ public async Task Analyzer_ProjectOnTheOtherXunitVersion_StaysSilentWhileTheOthe ) .ConfigureAwait(false); - _ = await Assert - .That(DiagnosticAssertions.Describe(ownDiagnostics)) - .IsEqualTo(DiagnosticAssertions.NoDiagnostics); - _ = await Assert.That(otherDiagnostics).Count().IsEqualTo(1); - _ = await Assert - .That(GetMessage(otherDiagnostics[0]).Contains(LocalOnlyTestName, StringComparison.Ordinal)) - .IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert + .That(DiagnosticAssertions.Describe(ownDiagnostics)) + .IsEqualTo(DiagnosticAssertions.NoDiagnostics); + _ = await Assert.That(otherDiagnostics).Count().IsEqualTo(1); + _ = await Assert + .That(GetMessage(otherDiagnostics[0]).Contains(LocalOnlyTestName, StringComparison.Ordinal)) + .IsTrue(); + } } /// @@ -384,10 +393,15 @@ public async Task Analyzer_EveryManifestShape_NeverCrashes() reported.AddRange(DiagnosticAssertions.Ids(await RunAllAsync(test, shape).ConfigureAwait(false))); } - _ = await Assert.That(reported.Contains(AnalyzerRunner.AnalyzerFailureId, StringComparer.Ordinal)).IsFalse(); - _ = await Assert - .That(reported.Contains(DiagnosticIds.TestWithoutProductionReference, StringComparer.Ordinal)) - .IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert + .That(reported.Contains(AnalyzerRunner.AnalyzerFailureId, StringComparer.Ordinal)) + .IsFalse(); + _ = await Assert + .That(reported.Contains(DiagnosticIds.TestWithoutProductionReference, StringComparer.Ordinal)) + .IsTrue(); + } } [Test] diff --git a/tests/NetEvolve.FrameShift.Tests.Integration/Generation/TestSurfaceManifestGeneratorTests.cs b/tests/NetEvolve.FrameShift.Tests.Integration/Generation/TestSurfaceManifestGeneratorTests.cs index f2aacfb..c5facac 100644 --- a/tests/NetEvolve.FrameShift.Tests.Integration/Generation/TestSurfaceManifestGeneratorTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Integration/Generation/TestSurfaceManifestGeneratorTests.cs @@ -288,12 +288,15 @@ public async Task Generate_ProductionCompilationWithoutAnyTestFramework_Generate { var output = Run(CreateProduction()); - _ = await Assert.That(output.HintNames).IsEqualTo(string.Empty); - _ = await Assert.That(output.Sources.Length).IsEqualTo(0); + using (Assert.Multiple()) + { + _ = await Assert.That(output.HintNames).IsEqualTo(string.Empty); + _ = await Assert.That(output.Sources.Length).IsEqualTo(0); - var diagnostics = DiagnosticAssertions.Describe(output.Diagnostics); + var diagnostics = DiagnosticAssertions.Describe(output.Diagnostics); - _ = await Assert.That(diagnostics).IsEqualTo(DiagnosticAssertions.NoDiagnostics); + _ = await Assert.That(diagnostics).IsEqualTo(DiagnosticAssertions.NoDiagnostics); + } } /// @@ -304,9 +307,12 @@ public async Task Generate_TUnitCompilation_GeneratesExactlyOneSourceWithTheAgre { var output = Run(CreateTest(TestFramework.TUnit, TUnitSource, CreateProduction())); - _ = await Assert.That(output.Sources.Length).IsEqualTo(1); - _ = await Assert.That(output.HintNames).IsEqualTo("TestSurfaceManifest.g.cs"); - _ = await Assert.That(TestSurfaceManifestGenerator.HintName).IsEqualTo("TestSurfaceManifest.g.cs"); + using (Assert.Multiple()) + { + _ = await Assert.That(output.Sources.Length).IsEqualTo(1); + _ = await Assert.That(output.HintNames).IsEqualTo("TestSurfaceManifest.g.cs"); + _ = await Assert.That(TestSurfaceManifestGenerator.HintName).IsEqualTo("TestSurfaceManifest.g.cs"); + } } /// @@ -319,12 +325,15 @@ public async Task Generate_TUnitCompilation_WrapsTheManifestInOneBlockCommentAnd var text = Generate(CreateTest(TestFramework.TUnit, TUnitSource, CreateProduction())); var lines = Lines(text); - _ = await Assert.That(lines[0]).IsEqualTo(CommentStart); - _ = await Assert.That(lines[^1]).IsEqualTo(CommentEnd); - _ = await Assert.That(lines[1]).IsEqualTo(Header); - _ = await Assert.That(Occurrences(text, CommentStart)).IsEqualTo(1); - _ = await Assert.That(Occurrences(text, CommentEnd)).IsEqualTo(1); - _ = await Assert.That(text.EndsWith(CommentEnd + LineFeed, StringComparison.Ordinal)).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(lines[0]).IsEqualTo(CommentStart); + _ = await Assert.That(lines[^1]).IsEqualTo(CommentEnd); + _ = await Assert.That(lines[1]).IsEqualTo(Header); + _ = await Assert.That(Occurrences(text, CommentStart)).IsEqualTo(1); + _ = await Assert.That(Occurrences(text, CommentEnd)).IsEqualTo(1); + _ = await Assert.That(text.EndsWith(CommentEnd + LineFeed, StringComparison.Ordinal)).IsTrue(); + } } /// @@ -394,8 +403,11 @@ public async Task Generate_FrameShiftDisabled_GeneratesNoSourceAtAll() var disabled = Run(test, options); var enabled = Run(test); - _ = await Assert.That(disabled.Sources.Length).IsEqualTo(0); - _ = await Assert.That(enabled.Sources.Length).IsEqualTo(1); + using (Assert.Multiple()) + { + _ = await Assert.That(disabled.Sources.Length).IsEqualTo(0); + _ = await Assert.That(enabled.Sources.Length).IsEqualTo(1); + } } /// @@ -410,11 +422,16 @@ public async Task Generate_TestCompilationWithoutAnyTest_GeneratesTheHeaderWitho var text = Generate(test); var (success, error, manifest) = Read(text); - _ = await Assert.That(string.Join("|", Lines(text))).IsEqualTo(CommentStart + "|" + Header + "|" + CommentEnd); - _ = await Assert.That(success).IsTrue(); - _ = await Assert.That(error).IsEqualTo(string.Empty); - _ = await Assert.That(manifest.IsEmpty).IsTrue(); - _ = await Assert.That(Canonical(manifest)).IsEqualTo(Header + LineFeed); + using (Assert.Multiple()) + { + _ = await Assert + .That(string.Join("|", Lines(text))) + .IsEqualTo(CommentStart + "|" + Header + "|" + CommentEnd); + _ = await Assert.That(success).IsTrue(); + _ = await Assert.That(error).IsEqualTo(string.Empty); + _ = await Assert.That(manifest.IsEmpty).IsTrue(); + _ = await Assert.That(Canonical(manifest)).IsEqualTo(Header + LineFeed); + } } /// @@ -431,9 +448,12 @@ public async Task Generate_SameCompilationTwice_ProducesByteIdenticalOutput() var second = Generate(test); var third = Generate(CreateTest(TestFramework.TUnit, TwoTestsSource, CreateProduction())); - _ = await Assert.That(second).IsEqualTo(first); - _ = await Assert.That(third).IsEqualTo(first); - _ = await Assert.That(first.Length).IsGreaterThan(Header.Length); + using (Assert.Multiple()) + { + _ = await Assert.That(second).IsEqualTo(first); + _ = await Assert.That(third).IsEqualTo(first); + _ = await Assert.That(first.Length).IsGreaterThan(Header.Length); + } } /// @@ -462,10 +482,13 @@ public async Task Generate_ManifestEntries_AreGroupedIntoBlocksAndSortedOrdinall var expectedEntries = testIds.SelectMany(id => BlockOf(manifest, id)); - _ = await Assert.That(manifest.TestMethodIds.Count).IsEqualTo(2); - _ = await Assert.That(manifest.ReferencedMemberIds.Count).IsGreaterThan(2); - _ = await Assert.That(markers).IsEqualTo(expectedMarkers); - _ = await Assert.That(string.Join("|", entries)).IsEqualTo(string.Join("|", expectedEntries)); + using (Assert.Multiple()) + { + _ = await Assert.That(manifest.TestMethodIds.Count).IsEqualTo(2); + _ = await Assert.That(manifest.ReferencedMemberIds.Count).IsGreaterThan(2); + _ = await Assert.That(markers).IsEqualTo(expectedMarkers); + _ = await Assert.That(string.Join("|", entries)).IsEqualTo(string.Join("|", expectedEntries)); + } } /// @@ -481,12 +504,15 @@ public async Task Generate_AwkwardMemberNames_ProducesIdsThatResolveBackToSymbol var ids = manifest.TestMethodIds.Union(manifest.ReferencedMemberIds); var unresolved = ids.Where(id => !Resolves(id, test)).OrderBy(id => id, StringComparer.Ordinal); - _ = await Assert.That(string.Join("|", unresolved)).IsEqualTo(string.Empty); - _ = await Assert.That(Contains(ids, "M:Fixture.Box`1.op_Addition")).IsTrue(); - _ = await Assert.That(Contains(ids, "M:Fixture.Box`1.Convert``1")).IsTrue(); - _ = await Assert.That(Contains(ids, "P:Fixture.Box`1.Item(System.Int32)")).IsTrue(); - _ = await Assert.That(Contains(ids, "P:Fixture.IShape.Corners")).IsTrue(); - _ = await Assert.That(Contains(ids, "M:Fixture.Box`1.Nested.Depth")).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(string.Join("|", unresolved)).IsEqualTo(string.Empty); + _ = await Assert.That(Contains(ids, "M:Fixture.Box`1.op_Addition")).IsTrue(); + _ = await Assert.That(Contains(ids, "M:Fixture.Box`1.Convert``1")).IsTrue(); + _ = await Assert.That(Contains(ids, "P:Fixture.Box`1.Item(System.Int32)")).IsTrue(); + _ = await Assert.That(Contains(ids, "P:Fixture.IShape.Corners")).IsTrue(); + _ = await Assert.That(Contains(ids, "M:Fixture.Box`1.Nested.Depth")).IsTrue(); + } } /// @@ -524,9 +550,12 @@ public async Task Generate_AwkwardMemberNames_EmitsNoLineThatClosesTheBlockComme var inner = Lines(text).Skip(1).SkipLast(1); var offenders = inner.Where(line => line.Contains(CommentEnd, StringComparison.Ordinal)); - _ = await Assert.That(string.Join("|", offenders)).IsEqualTo(string.Empty); - _ = await Assert.That(Occurrences(text, CommentEnd)).IsEqualTo(1); - _ = await Assert.That(Describe(output.Compilation)).IsEqualTo(DiagnosticAssertions.NoDiagnostics); + using (Assert.Multiple()) + { + _ = await Assert.That(string.Join("|", offenders)).IsEqualTo(string.Empty); + _ = await Assert.That(Occurrences(text, CommentEnd)).IsEqualTo(1); + _ = await Assert.That(Describe(output.Compilation)).IsEqualTo(DiagnosticAssertions.NoDiagnostics); + } } /// diff --git a/tests/NetEvolve.FrameShift.Tests.Integration/MutationAnalysisRoundTripTests.cs b/tests/NetEvolve.FrameShift.Tests.Integration/MutationAnalysisRoundTripTests.cs index 9993601..45f63af 100644 --- a/tests/NetEvolve.FrameShift.Tests.Integration/MutationAnalysisRoundTripTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Integration/MutationAnalysisRoundTripTests.cs @@ -313,10 +313,13 @@ public async Task RoundTrip_TestCoveringOneMethod_ReportsTheGapOnlyInTheUncovere var cycle = await RunCycleAsync(AddCoveredSource).ConfigureAwait(false); var lines = GapLines(cycle.Diagnostics); - _ = await Assert.That(DescribeGaps(cycle.Diagnostics)).IsEqualTo(Gap(SubtractLine)); - _ = await Assert.That(lines.Contains(SubtractLine)).IsTrue(); - _ = await Assert.That(lines.Contains(AddLine)).IsFalse(); - _ = await Assert.That(lines.Contains(TwiceLine)).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(DescribeGaps(cycle.Diagnostics)).IsEqualTo(Gap(SubtractLine)); + _ = await Assert.That(lines.Contains(SubtractLine)).IsTrue(); + _ = await Assert.That(lines.Contains(AddLine)).IsFalse(); + _ = await Assert.That(lines.Contains(TwiceLine)).IsFalse(); + } _ = await Verify(DescribeCycle(cycle)).ConfigureAwait(false); } @@ -341,10 +344,13 @@ public async Task RoundTrip_TestAddedForTheReportedGap_MakesTheGapDisappear() var removed = GapEntries(before.Diagnostics).Except(GapEntries(after.Diagnostics), StringComparer.Ordinal); var added = GapEntries(after.Diagnostics).Except(GapEntries(before.Diagnostics), StringComparer.Ordinal); - _ = await Assert.That(string.Join("|", removed)).IsEqualTo(Gap(SubtractLine)); - _ = await Assert.That(string.Join("|", added)).IsEqualTo(string.Empty); - _ = await Assert.That(OnlyGaps(after.Diagnostics).IsEmpty).IsTrue(); - _ = await Assert.That(DescribeGaps(after.Diagnostics)).IsEqualTo(string.Empty); + using (Assert.Multiple()) + { + _ = await Assert.That(string.Join("|", removed)).IsEqualTo(Gap(SubtractLine)); + _ = await Assert.That(string.Join("|", added)).IsEqualTo(string.Empty); + _ = await Assert.That(OnlyGaps(after.Diagnostics).IsEmpty).IsTrue(); + _ = await Assert.That(DescribeGaps(after.Diagnostics)).IsEqualTo(string.Empty); + } _ = await Verify(DescribeTransition(before, after)).ConfigureAwait(false); } @@ -360,8 +366,11 @@ public async Task RoundTrip_TestDeletedForACoveredMethod_ReportsNewGaps() var before = await RunCycleAsync(BothCoveredSource).ConfigureAwait(false); var after = await RunCycleAsync(SubtractCoveredSource).ConfigureAwait(false); - _ = await Assert.That(DescribeGaps(before.Diagnostics)).IsEqualTo(string.Empty); - _ = await Assert.That(DescribeGaps(after.Diagnostics)).IsEqualTo(Gap(AddLine) + "|" + Gap(TwiceLine)); + using (Assert.Multiple()) + { + _ = await Assert.That(DescribeGaps(before.Diagnostics)).IsEqualTo(string.Empty); + _ = await Assert.That(DescribeGaps(after.Diagnostics)).IsEqualTo(Gap(AddLine) + "|" + Gap(TwiceLine)); + } _ = await Verify(DescribeCycle(after)).ConfigureAwait(false); } @@ -382,10 +391,13 @@ public async Task RoundTrip_TestTouchingNoMutableMember_ReportsAGapAtEveryMutati var cycle = await RunCycleAsync(ConstructionOnlySource).ConfigureAwait(false); var expected = Gap(AddLine) + "|" + Gap(SubtractLine) + "|" + Gap(TwiceLine); - _ = await Assert.That(DescribeGaps(cycle.Diagnostics)).IsEqualTo(expected); - _ = await Assert - .That(string.Join("|", DiagnosticAssertions.Ids(cycle.Diagnostics).Distinct(StringComparer.Ordinal))) - .IsEqualTo(DiagnosticIds.UnreachableMutationPoint); + using (Assert.Multiple()) + { + _ = await Assert.That(DescribeGaps(cycle.Diagnostics)).IsEqualTo(expected); + _ = await Assert + .That(string.Join("|", DiagnosticAssertions.Ids(cycle.Diagnostics).Distinct(StringComparer.Ordinal))) + .IsEqualTo(DiagnosticIds.UnreachableMutationPoint); + } _ = await Verify(DescribeCycle(cycle)).ConfigureAwait(false); } @@ -408,18 +420,21 @@ public async Task RoundTrip_ProductionWithoutAnyTest_NamesTheUnusableManifestIns { var cycle = await RunCycleAsync(WithoutAnyTestSource).ConfigureAwait(false); - _ = await Assert - .That(string.Join("|", DiagnosticAssertions.Ids(cycle.Diagnostics))) - .IsEqualTo(DiagnosticIds.InvalidTestSurfaceManifest); - _ = await Assert.That(DescribeGaps(cycle.Diagnostics)).IsEqualTo(string.Empty); - - var message = Message(cycle.Diagnostics[0]); - var namesTheEmptyManifest = message.Contains( - "does not record a single referenced production member", - StringComparison.Ordinal - ); - - _ = await Assert.That(namesTheEmptyManifest).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert + .That(string.Join("|", DiagnosticAssertions.Ids(cycle.Diagnostics))) + .IsEqualTo(DiagnosticIds.InvalidTestSurfaceManifest); + _ = await Assert.That(DescribeGaps(cycle.Diagnostics)).IsEqualTo(string.Empty); + + var message = Message(cycle.Diagnostics[0]); + var namesTheEmptyManifest = message.Contains( + "does not record a single referenced production member", + StringComparison.Ordinal + ); + + _ = await Assert.That(namesTheEmptyManifest).IsTrue(); + } _ = await Verify(DescribeCycle(cycle)).ConfigureAwait(false); } @@ -447,8 +462,13 @@ [new InMemoryAdditionalText(manifest)] var hasCanonicalHeader = manifest.StartsWith("frameshift-test-surface/1\n", StringComparison.Ordinal); - _ = await Assert.That(hasCanonicalHeader).IsTrue(); - _ = await Assert.That(DiagnosticAssertions.Describe(diagnostics)).IsEqualTo(DiagnosticAssertions.NoDiagnostics); + using (Assert.Multiple()) + { + _ = await Assert.That(hasCanonicalHeader).IsTrue(); + _ = await Assert + .That(DiagnosticAssertions.Describe(diagnostics)) + .IsEqualTo(DiagnosticAssertions.NoDiagnostics); + } } /// @@ -469,13 +489,16 @@ public async Task RoundTrip_MemberReachedByOneExactTestCase_ReportsTheSingleTest { var cycle = await RunCycleAsync(AddCoveredSource).ConfigureAwait(false); - _ = await Assert - .That(DescribeSingleCases(cycle.Diagnostics)) - .IsEqualTo(SingleCase(AddLine) + "|" + SingleCase(TwiceLine)); - _ = await Assert.That(DescribeGaps(cycle.Diagnostics)).IsEqualTo(Gap(SubtractLine)); - _ = await Assert - .That(SingleCaseTestNames(cycle.Diagnostics)) - .IsEqualTo("Tests.CalculatorTests.Add_ReturnsTheSum"); + using (Assert.Multiple()) + { + _ = await Assert + .That(DescribeSingleCases(cycle.Diagnostics)) + .IsEqualTo(SingleCase(AddLine) + "|" + SingleCase(TwiceLine)); + _ = await Assert.That(DescribeGaps(cycle.Diagnostics)).IsEqualTo(Gap(SubtractLine)); + _ = await Assert + .That(SingleCaseTestNames(cycle.Diagnostics)) + .IsEqualTo("Tests.CalculatorTests.Add_ReturnsTheSum"); + } } /// @@ -495,11 +518,14 @@ public async Task RoundTrip_MemberReachedByTwoTests_ReportsTheHintOnlyWhereOneTe { var cycle = await RunCycleAsync(SharedHelperSource).ConfigureAwait(false); - _ = await Assert.That(DescribeSingleCases(cycle.Diagnostics)).IsEqualTo(SingleCase(AddLine)); - _ = await Assert.That(DescribeGaps(cycle.Diagnostics)).IsEqualTo(Gap(SubtractLine)); - _ = await Assert - .That(SingleCaseTestNames(cycle.Diagnostics)) - .IsEqualTo("Tests.CalculatorTests.Add_ReturnsTheSum"); + using (Assert.Multiple()) + { + _ = await Assert.That(DescribeSingleCases(cycle.Diagnostics)).IsEqualTo(SingleCase(AddLine)); + _ = await Assert.That(DescribeGaps(cycle.Diagnostics)).IsEqualTo(Gap(SubtractLine)); + _ = await Assert + .That(SingleCaseTestNames(cycle.Diagnostics)) + .IsEqualTo("Tests.CalculatorTests.Add_ReturnsTheSum"); + } } /// @@ -512,9 +538,12 @@ public async Task RoundTrip_MemberReachedByThreeExactTestCases_ReportsNoSingleTe { var cycle = await RunCycleAsync(ThreeCaseSource).ConfigureAwait(false); - _ = await Assert.That(cycle.Manifest.Contains(" 3\n", StringComparison.Ordinal)).IsTrue(); - _ = await Assert.That(DescribeSingleCases(cycle.Diagnostics)).IsEqualTo(string.Empty); - _ = await Assert.That(DescribeGaps(cycle.Diagnostics)).IsEqualTo(Gap(SubtractLine)); + using (Assert.Multiple()) + { + _ = await Assert.That(cycle.Manifest.Contains(" 3\n", StringComparison.Ordinal)).IsTrue(); + _ = await Assert.That(DescribeSingleCases(cycle.Diagnostics)).IsEqualTo(string.Empty); + _ = await Assert.That(DescribeGaps(cycle.Diagnostics)).IsEqualTo(Gap(SubtractLine)); + } } /// @@ -528,9 +557,12 @@ public async Task RoundTrip_MemberReachedByALowerBoundTestCase_ReportsNoSingleTe { var cycle = await RunCycleAsync(DataSourceSource).ConfigureAwait(false); - _ = await Assert.That(cycle.Manifest.Contains(" 1+\n", StringComparison.Ordinal)).IsTrue(); - _ = await Assert.That(DescribeSingleCases(cycle.Diagnostics)).IsEqualTo(string.Empty); - _ = await Assert.That(DescribeGaps(cycle.Diagnostics)).IsEqualTo(Gap(SubtractLine)); + using (Assert.Multiple()) + { + _ = await Assert.That(cycle.Manifest.Contains(" 1+\n", StringComparison.Ordinal)).IsTrue(); + _ = await Assert.That(DescribeSingleCases(cycle.Diagnostics)).IsEqualTo(string.Empty); + _ = await Assert.That(DescribeGaps(cycle.Diagnostics)).IsEqualTo(Gap(SubtractLine)); + } } private static IEnumerable GetTestSources() => diff --git a/tests/NetEvolve.FrameShift.Tests.Unit/Configuration/FrameShiftOptionsTests.cs b/tests/NetEvolve.FrameShift.Tests.Unit/Configuration/FrameShiftOptionsTests.cs index 6cb3c0e..bae9bbf 100644 --- a/tests/NetEvolve.FrameShift.Tests.Unit/Configuration/FrameShiftOptionsTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Unit/Configuration/FrameShiftOptionsTests.cs @@ -174,12 +174,15 @@ public async Task Read_MaxMutantsPerMember_UsesTheInvariantCulture() var invariantSign = Read(FrameShiftOptionKeys.MaxMutantsPerMember, "-5"); var cultureSign = Read(FrameShiftOptionKeys.MaxMutantsPerMember, minusSign + "5"); - _ = await Assert - .That(invariantSign.MaxMutantsPerMember) - .IsEqualTo(FrameShiftOptions.MinimumMaxMutantsPerMember); - _ = await Assert - .That(cultureSign.MaxMutantsPerMember) - .IsEqualTo(FrameShiftOptions.DefaultMaxMutantsPerMember); + using (Assert.Multiple()) + { + _ = await Assert + .That(invariantSign.MaxMutantsPerMember) + .IsEqualTo(FrameShiftOptions.MinimumMaxMutantsPerMember); + _ = await Assert + .That(cultureSign.MaxMutantsPerMember) + .IsEqualTo(FrameShiftOptions.DefaultMaxMutantsPerMember); + } } finally { @@ -211,11 +214,14 @@ public async Task Read_EveryOptionConfigured_ReadsEachOneIndependently() ) ); - _ = await Assert.That(options.IsEnabled).IsTrue(); - _ = await Assert.That(options.VerifyMutantCompilation).IsFalse(); - _ = await Assert.That(options.MaxMutantsPerMember).IsEqualTo(9); - _ = await Assert.That(options.ReportTrivialMutants).IsFalse(); - _ = await Assert.That(options.EnableRegexPatternMutations).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(options.IsEnabled).IsTrue(); + _ = await Assert.That(options.VerifyMutantCompilation).IsFalse(); + _ = await Assert.That(options.MaxMutantsPerMember).IsEqualTo(9); + _ = await Assert.That(options.ReportTrivialMutants).IsFalse(); + _ = await Assert.That(options.EnableRegexPatternMutations).IsFalse(); + } } [Test] diff --git a/tests/NetEvolve.FrameShift.Tests.Unit/Equivalence/EquivalenceClassifierBranchTests.cs b/tests/NetEvolve.FrameShift.Tests.Unit/Equivalence/EquivalenceClassifierBranchTests.cs index 154c777..eccdbdc 100644 --- a/tests/NetEvolve.FrameShift.Tests.Unit/Equivalence/EquivalenceClassifierBranchTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Unit/Equivalence/EquivalenceClassifierBranchTests.cs @@ -551,14 +551,20 @@ public async Task Classify_MutationInWellKnownProperty_IsTrivialWellKnownMember( private static async Task AssertTrivialAsync(EquivalenceVerdict verdict, string expectedReason) { - _ = await Assert.That(verdict.IsTrivial).IsTrue(); - _ = await Assert.That(verdict.Reason).IsEqualTo(expectedReason); + using (Assert.Multiple()) + { + _ = await Assert.That(verdict.IsTrivial).IsTrue(); + _ = await Assert.That(verdict.Reason).IsEqualTo(expectedReason); + } } private static async Task AssertNotTrivialAsync(EquivalenceVerdict verdict) { - _ = await Assert.That(verdict.Reason).IsNull(); - _ = await Assert.That(verdict.IsTrivial).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(verdict.Reason).IsNull(); + _ = await Assert.That(verdict.IsTrivial).IsFalse(); + } } private static EquivalenceVerdict Classify(SyntaxNode original, SyntaxNode replacement, SemanticModel model) => diff --git a/tests/NetEvolve.FrameShift.Tests.Unit/Equivalence/EquivalenceClassifierFoldingOperatorTests.cs b/tests/NetEvolve.FrameShift.Tests.Unit/Equivalence/EquivalenceClassifierFoldingOperatorTests.cs index 1b9dd47..3ab2228 100644 --- a/tests/NetEvolve.FrameShift.Tests.Unit/Equivalence/EquivalenceClassifierFoldingOperatorTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Unit/Equivalence/EquivalenceClassifierFoldingOperatorTests.cs @@ -302,13 +302,19 @@ private static async Task AssertVerdictAsync(EquivalenceVerdict verdict, bool ex { if (expectedTrivial) { - _ = await Assert.That(verdict.IsTrivial).IsTrue(); - _ = await Assert.That(verdict.Reason).IsEqualTo(ConstantFoldingReason); + using (Assert.Multiple()) + { + _ = await Assert.That(verdict.IsTrivial).IsTrue(); + _ = await Assert.That(verdict.Reason).IsEqualTo(ConstantFoldingReason); + } return; } - _ = await Assert.That(verdict.Reason).IsNull(); - _ = await Assert.That(verdict.IsTrivial).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(verdict.Reason).IsNull(); + _ = await Assert.That(verdict.IsTrivial).IsFalse(); + } } /// diff --git a/tests/NetEvolve.FrameShift.Tests.Unit/Equivalence/EquivalenceClassifierFoldingTests.cs b/tests/NetEvolve.FrameShift.Tests.Unit/Equivalence/EquivalenceClassifierFoldingTests.cs index 2deb469..1cd81f1 100644 --- a/tests/NetEvolve.FrameShift.Tests.Unit/Equivalence/EquivalenceClassifierFoldingTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Unit/Equivalence/EquivalenceClassifierFoldingTests.cs @@ -486,14 +486,20 @@ public async Task Classify_ReplacementUsesAnOperatorTheFoldCannotEvaluate_IsNotT private static async Task AssertTrivialFoldAsync(EquivalenceVerdict verdict) { - _ = await Assert.That(verdict.IsTrivial).IsTrue(); - _ = await Assert.That(verdict.Reason).IsEqualTo(ConstantFoldingReason); + using (Assert.Multiple()) + { + _ = await Assert.That(verdict.IsTrivial).IsTrue(); + _ = await Assert.That(verdict.Reason).IsEqualTo(ConstantFoldingReason); + } } private static async Task AssertNotTrivialAsync(EquivalenceVerdict verdict) { - _ = await Assert.That(verdict.Reason).IsNull(); - _ = await Assert.That(verdict.IsTrivial).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(verdict.Reason).IsNull(); + _ = await Assert.That(verdict.IsTrivial).IsFalse(); + } } /// diff --git a/tests/NetEvolve.FrameShift.Tests.Unit/Equivalence/EquivalenceClassifierTests.cs b/tests/NetEvolve.FrameShift.Tests.Unit/Equivalence/EquivalenceClassifierTests.cs index 1126cf7..187bb18 100644 --- a/tests/NetEvolve.FrameShift.Tests.Unit/Equivalence/EquivalenceClassifierTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Unit/Equivalence/EquivalenceClassifierTests.cs @@ -298,14 +298,20 @@ public async Task Classify_NodeBelongsToAnotherTree_IsNotTrivial() private static async Task AssertTrivialAsync(EquivalenceVerdict verdict, string expectedReason) { - _ = await Assert.That(verdict.IsTrivial).IsTrue(); - _ = await Assert.That(verdict.Reason).IsEqualTo(expectedReason); + using (Assert.Multiple()) + { + _ = await Assert.That(verdict.IsTrivial).IsTrue(); + _ = await Assert.That(verdict.Reason).IsEqualTo(expectedReason); + } } private static async Task AssertNotTrivialAsync(EquivalenceVerdict verdict) { - _ = await Assert.That(verdict.Reason).IsNull(); - _ = await Assert.That(verdict.IsTrivial).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(verdict.Reason).IsNull(); + _ = await Assert.That(verdict.IsTrivial).IsFalse(); + } } /// diff --git a/tests/NetEvolve.FrameShift.Tests.Unit/Equivalence/EquivalenceVerdictTests.cs b/tests/NetEvolve.FrameShift.Tests.Unit/Equivalence/EquivalenceVerdictTests.cs index 3f490fa..a8630f3 100644 --- a/tests/NetEvolve.FrameShift.Tests.Unit/Equivalence/EquivalenceVerdictTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Unit/Equivalence/EquivalenceVerdictTests.cs @@ -35,8 +35,11 @@ public async Task Trivial_ReasonIsGiven_CarriesTheReason() { var verdict = EquivalenceVerdict.Trivial(Reason); - _ = await Assert.That(verdict.IsTrivial).IsTrue(); - _ = await Assert.That(verdict.Reason).IsEqualTo(Reason); + using (Assert.Multiple()) + { + _ = await Assert.That(verdict.IsTrivial).IsTrue(); + _ = await Assert.That(verdict.Reason).IsEqualTo(Reason); + } } [Test] @@ -44,8 +47,11 @@ public async Task Trivial_ReasonIsASingleCharacter_IsAccepted() { var verdict = EquivalenceVerdict.Trivial("x"); - _ = await Assert.That(verdict.IsTrivial).IsTrue(); - _ = await Assert.That(verdict.Reason).IsEqualTo("x"); + using (Assert.Multiple()) + { + _ = await Assert.That(verdict.IsTrivial).IsTrue(); + _ = await Assert.That(verdict.Reason).IsEqualTo("x"); + } } [Test] @@ -61,8 +67,11 @@ public async Task NotTrivial_Always_HasNoReason() { var verdict = EquivalenceVerdict.NotTrivial; - _ = await Assert.That(verdict.IsTrivial).IsFalse(); - _ = await Assert.That(verdict.Reason).IsNull(); + using (Assert.Multiple()) + { + _ = await Assert.That(verdict.IsTrivial).IsFalse(); + _ = await Assert.That(verdict.Reason).IsNull(); + } } [Test] @@ -84,7 +93,10 @@ public async Task Trivial_CalledTwice_CreatesIndependentVerdicts() var first = EquivalenceVerdict.Trivial(Reason); var second = EquivalenceVerdict.Trivial(Reason); - _ = await Assert.That(ReferenceEquals(first, second)).IsFalse(); - _ = await Assert.That(second.Reason).IsEqualTo(first.Reason); + using (Assert.Multiple()) + { + _ = await Assert.That(ReferenceEquals(first, second)).IsFalse(); + _ = await Assert.That(second.Reason).IsEqualTo(first.Reason); + } } } diff --git a/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/MutantCompilerTests.cs b/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/MutantCompilerTests.cs index 3a6ea07..9a4542a 100644 --- a/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/MutantCompilerTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/MutantCompilerTests.cs @@ -155,8 +155,11 @@ public async Task Verify_MutationKeepsTheCodeValid_ReturnsViable() var viability = compiler.Verify(CreateViableMutation(tree), tree, CancellationToken.None); - _ = await Assert.That(Describe(compilation)).IsEqualTo(DiagnosticAssertions.NoDiagnostics); - _ = await Assert.That(viability).IsEqualTo(MutantViability.Viable); + using (Assert.Multiple()) + { + _ = await Assert.That(Describe(compilation)).IsEqualTo(DiagnosticAssertions.NoDiagnostics); + _ = await Assert.That(viability).IsEqualTo(MutantViability.Viable); + } } [Test] @@ -167,8 +170,11 @@ public async Task Verify_ReplacementIsTypeIncorrect_ReturnsDoesNotCompile() var viability = compiler.Verify(CreateBrokenMutation(tree), tree, CancellationToken.None); - _ = await Assert.That(Describe(compilation)).IsEqualTo(DiagnosticAssertions.NoDiagnostics); - _ = await Assert.That(viability).IsEqualTo(MutantViability.DoesNotCompile); + using (Assert.Multiple()) + { + _ = await Assert.That(Describe(compilation)).IsEqualTo(DiagnosticAssertions.NoDiagnostics); + _ = await Assert.That(viability).IsEqualTo(MutantViability.DoesNotCompile); + } } [Test] @@ -192,8 +198,11 @@ public async Task Verify_CalledRepeatedly_ReturnsTheSameVerdictForViableMutants( var verdicts = Repeat(() => compiler.Verify(mutation, tree, CancellationToken.None), repetitions: 5); - _ = await Assert.That(verdicts.Distinct()).Count().IsEqualTo(1); - _ = await Assert.That(verdicts[0]).IsEqualTo(MutantViability.Viable); + using (Assert.Multiple()) + { + _ = await Assert.That(verdicts.Distinct()).Count().IsEqualTo(1); + _ = await Assert.That(verdicts[0]).IsEqualTo(MutantViability.Viable); + } } [Test] @@ -205,8 +214,11 @@ public async Task Verify_CalledRepeatedly_ReturnsTheSameVerdictForBrokenMutants( var verdicts = Repeat(() => compiler.Verify(mutation, tree, CancellationToken.None), repetitions: 5); - _ = await Assert.That(verdicts.Distinct()).Count().IsEqualTo(1); - _ = await Assert.That(verdicts[0]).IsEqualTo(MutantViability.DoesNotCompile); + using (Assert.Multiple()) + { + _ = await Assert.That(verdicts.Distinct()).Count().IsEqualTo(1); + _ = await Assert.That(verdicts[0]).IsEqualTo(MutantViability.DoesNotCompile); + } } [Test] @@ -220,10 +232,13 @@ public async Task Verify_AfterVerification_LeavesTheOriginalCompilationUnchanged _ = compiler.Verify(CreateViableMutation(tree), tree, CancellationToken.None); _ = compiler.Verify(CreateBrokenMutation(tree), tree, CancellationToken.None); - _ = await Assert.That(Describe(compilation)).IsEqualTo(DiagnosticAssertions.NoDiagnostics); - _ = await Assert.That(compilation.SyntaxTrees.Length).IsEqualTo(treesBefore.Length); - _ = await Assert.That(ReferenceEquals(compilation.SyntaxTrees[0], tree)).IsTrue(); - _ = await Assert.That(tree.ToString()).IsEqualTo(textBefore); + using (Assert.Multiple()) + { + _ = await Assert.That(Describe(compilation)).IsEqualTo(DiagnosticAssertions.NoDiagnostics); + _ = await Assert.That(compilation.SyntaxTrees.Length).IsEqualTo(treesBefore.Length); + _ = await Assert.That(ReferenceEquals(compilation.SyntaxTrees[0], tree)).IsTrue(); + _ = await Assert.That(tree.ToString()).IsEqualTo(textBefore); + } } [Test] @@ -267,10 +282,13 @@ public async Task Verify_ConcurrentlyForDistinctMutations_ReturnsViableForEveryO } ); - _ = await Assert.That(mutations.Length).IsEqualTo(3); - _ = await Assert.That(results).Count().IsEqualTo(32 * mutations.Length); - _ = await Assert.That(results.Distinct()).Count().IsEqualTo(1); - _ = await Assert.That(results.First()).IsEqualTo(MutantViability.Viable); + using (Assert.Multiple()) + { + _ = await Assert.That(mutations.Length).IsEqualTo(3); + _ = await Assert.That(results).Count().IsEqualTo(32 * mutations.Length); + _ = await Assert.That(results.Distinct()).Count().IsEqualTo(1); + _ = await Assert.That(results.First()).IsEqualTo(MutantViability.Viable); + } } [Test] @@ -291,10 +309,15 @@ public async Task Verify_ConcurrentlyForTheSameMutations_ReturnsConsistentVerdic } ); - _ = await Assert.That(VerdictsOf(results, ViableOperatorId)).IsEquivalentTo(new[] { MutantViability.Viable }); - _ = await Assert - .That(VerdictsOf(results, BrokenOperatorId)) - .IsEquivalentTo(new[] { MutantViability.DoesNotCompile }); + using (Assert.Multiple()) + { + _ = await Assert + .That(VerdictsOf(results, ViableOperatorId)) + .IsEquivalentTo(new[] { MutantViability.Viable }); + _ = await Assert + .That(VerdictsOf(results, BrokenOperatorId)) + .IsEquivalentTo(new[] { MutantViability.DoesNotCompile }); + } } [Test] @@ -346,8 +369,11 @@ public async Task Verify_OriginalTreeIsNotPartOfTheCompilation_ReturnsDoesNotCom var viability = compiler.Verify(CreateViableMutation(foreignTree), foreignTree, CancellationToken.None); - _ = await Assert.That(compilation.SyntaxTrees.Contains(foreignTree)).IsFalse(); - _ = await Assert.That(viability).IsEqualTo(MutantViability.DoesNotCompile); + using (Assert.Multiple()) + { + _ = await Assert.That(compilation.SyntaxTrees.Contains(foreignTree)).IsFalse(); + _ = await Assert.That(viability).IsEqualTo(MutantViability.DoesNotCompile); + } } [Test] @@ -367,8 +393,11 @@ public async Task Verify_MutantDoesNotEvenParse_ReturnsDoesNotCompile() var viability = compiler.Verify(mutation, tree, CancellationToken.None); - _ = await Assert.That(syntaxErrors.Length).IsGreaterThan(0); - _ = await Assert.That(viability).IsEqualTo(MutantViability.DoesNotCompile); + using (Assert.Multiple()) + { + _ = await Assert.That(syntaxErrors.Length).IsGreaterThan(0); + _ = await Assert.That(viability).IsEqualTo(MutantViability.DoesNotCompile); + } } /// @@ -392,8 +421,11 @@ public async Task Verify_MutantOnlyProducesWarnings_ReturnsViable() var mutation = CreateSubtractionMutation(tree, ViableOperatorId); var viability = compiler.Verify(mutation, tree, CancellationToken.None); - _ = await Assert.That(warningIds).Contains("CS0618"); - _ = await Assert.That(viability).IsEqualTo(MutantViability.Viable); + using (Assert.Multiple()) + { + _ = await Assert.That(warningIds).Contains("CS0618"); + _ = await Assert.That(viability).IsEqualTo(MutantViability.Viable); + } } /// @@ -411,9 +443,12 @@ public async Task Verify_AnotherOperatorAtTheSameLocation_IsVerifiedOnItsOwn() var first = compiler.Verify(viable, tree, CancellationToken.None); var second = compiler.Verify(broken, tree, CancellationToken.None); - _ = await Assert.That(broken.Location.SourceSpan).IsEqualTo(viable.Location.SourceSpan); - _ = await Assert.That(first).IsEqualTo(MutantViability.Viable); - _ = await Assert.That(second).IsEqualTo(MutantViability.DoesNotCompile); + using (Assert.Multiple()) + { + _ = await Assert.That(broken.Location.SourceSpan).IsEqualTo(viable.Location.SourceSpan); + _ = await Assert.That(first).IsEqualTo(MutantViability.Viable); + _ = await Assert.That(second).IsEqualTo(MutantViability.DoesNotCompile); + } } /// @@ -431,9 +466,12 @@ public async Task Verify_TheSameOperatorAtAnotherLocation_IsVerifiedOnItsOwn() var first = compiler.Verify(viable, tree, CancellationToken.None); var second = compiler.Verify(broken, tree, CancellationToken.None); - _ = await Assert.That(broken.Location.SourceSpan).IsNotEqualTo(viable.Location.SourceSpan); - _ = await Assert.That(first).IsEqualTo(MutantViability.Viable); - _ = await Assert.That(second).IsEqualTo(MutantViability.DoesNotCompile); + using (Assert.Multiple()) + { + _ = await Assert.That(broken.Location.SourceSpan).IsNotEqualTo(viable.Location.SourceSpan); + _ = await Assert.That(first).IsEqualTo(MutantViability.Viable); + _ = await Assert.That(second).IsEqualTo(MutantViability.DoesNotCompile); + } } /// @@ -453,10 +491,13 @@ public async Task Verify_TheSameOperatorAndSpanInAnotherFile_IsVerifiedOnItsOwn( var first = compiler.Verify(viable, treeA, CancellationToken.None); var second = compiler.Verify(broken, treeB, CancellationToken.None); - _ = await Assert.That(treeB.FilePath).IsNotEqualTo(treeA.FilePath); - _ = await Assert.That(broken.Location.SourceSpan).IsEqualTo(viable.Location.SourceSpan); - _ = await Assert.That(first).IsEqualTo(MutantViability.Viable); - _ = await Assert.That(second).IsEqualTo(MutantViability.DoesNotCompile); + using (Assert.Multiple()) + { + _ = await Assert.That(treeB.FilePath).IsNotEqualTo(treeA.FilePath); + _ = await Assert.That(broken.Location.SourceSpan).IsEqualTo(viable.Location.SourceSpan); + _ = await Assert.That(first).IsEqualTo(MutantViability.Viable); + _ = await Assert.That(second).IsEqualTo(MutantViability.DoesNotCompile); + } } /// @@ -474,9 +515,12 @@ public async Task Verify_MutatedTreeStillCarriesASyntaxError_ReturnsDoesNotCompi var viability = compiler.Verify(mutation, tree, CancellationToken.None); - _ = await Assert.That(HasError(mutation.Replacement.GetDiagnostics())).IsFalse(); - _ = await Assert.That(HasError(tree.GetDiagnostics())).IsTrue(); - _ = await Assert.That(viability).IsEqualTo(MutantViability.DoesNotCompile); + using (Assert.Multiple()) + { + _ = await Assert.That(HasError(mutation.Replacement.GetDiagnostics())).IsFalse(); + _ = await Assert.That(HasError(tree.GetDiagnostics())).IsTrue(); + _ = await Assert.That(viability).IsEqualTo(MutantViability.DoesNotCompile); + } } /// @@ -500,18 +544,21 @@ public async Task Verify_TheSameLocationUnderTwoOperators_KeepsBothVerdicts() compiler.Verify(broken, tree, CancellationToken.None), }; - _ = await Assert.That(broken.Location.SourceSpan).IsEqualTo(viable.Location.SourceSpan); - _ = await Assert - .That(verdicts) - .IsEquivalentTo( - new[] - { - MutantViability.Viable, - MutantViability.DoesNotCompile, - MutantViability.Viable, - MutantViability.DoesNotCompile, - } - ); + using (Assert.Multiple()) + { + _ = await Assert.That(broken.Location.SourceSpan).IsEqualTo(viable.Location.SourceSpan); + _ = await Assert + .That(verdicts) + .IsEquivalentTo( + new[] + { + MutantViability.Viable, + MutantViability.DoesNotCompile, + MutantViability.Viable, + MutantViability.DoesNotCompile, + } + ); + } } [Test] @@ -520,11 +567,14 @@ public async Task MutantKey_TwoKeysDescribingTheSameMutant_AreEqualAndShareTheir var left = CreateKey(ViableOperatorId, TwinPathA, CreateSpan()); var right = CreateKey(ViableOperatorId, TwinPathA, CreateSpan()); - _ = await Assert.That(TypedEquals(left, right)).IsTrue(); - _ = await Assert.That(left.Equals(right)).IsTrue(); - _ = await Assert.That(OperatorEquals(left, right)).IsTrue(); - _ = await Assert.That(OperatorNotEquals(left, right)).IsFalse(); - _ = await Assert.That(left.GetHashCode()).IsEqualTo(right.GetHashCode()); + using (Assert.Multiple()) + { + _ = await Assert.That(TypedEquals(left, right)).IsTrue(); + _ = await Assert.That(left.Equals(right)).IsTrue(); + _ = await Assert.That(OperatorEquals(left, right)).IsTrue(); + _ = await Assert.That(OperatorNotEquals(left, right)).IsFalse(); + _ = await Assert.That(left.GetHashCode()).IsEqualTo(right.GetHashCode()); + } } /// @@ -550,10 +600,13 @@ int length var key = CreateKey(ViableOperatorId, TwinPathA, CreateSpan()); var other = CreateKey(operatorId, filePath, new TextSpan(start, length)); - _ = await Assert.That(TypedEquals(key, other)).IsFalse(); - _ = await Assert.That(key.Equals(other)).IsFalse(); - _ = await Assert.That(OperatorEquals(key, other)).IsFalse(); - _ = await Assert.That(OperatorNotEquals(key, other)).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(TypedEquals(key, other)).IsFalse(); + _ = await Assert.That(key.Equals(other)).IsFalse(); + _ = await Assert.That(OperatorEquals(key, other)).IsFalse(); + _ = await Assert.That(OperatorNotEquals(key, other)).IsTrue(); + } } [Test] @@ -561,9 +614,12 @@ public async Task MutantKey_EqualsWithNullOrAForeignType_IsFalse() { var key = CreateKey(ViableOperatorId, TwinPathA, CreateSpan()); - _ = await Assert.That(ObjectEquals(key, null)).IsFalse(); - _ = await Assert.That(ObjectEquals(key, TwinPathA)).IsFalse(); - _ = await Assert.That(ObjectEquals(key, CreateSpan())).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(ObjectEquals(key, null)).IsFalse(); + _ = await Assert.That(ObjectEquals(key, TwinPathA)).IsFalse(); + _ = await Assert.That(ObjectEquals(key, CreateSpan())).IsFalse(); + } } [Test] @@ -588,9 +644,12 @@ public async Task MutantKey_FilePathIsNull_IsTheKeyOfTheEmptyFilePath() var withEmptyPath = CreateKey(ViableOperatorId, string.Empty, CreateSpan()); var withPath = CreateKey(ViableOperatorId, TwinPathA, CreateSpan()); - _ = await Assert.That(TypedEquals(withoutPath, withEmptyPath)).IsTrue(); - _ = await Assert.That(withoutPath.GetHashCode()).IsEqualTo(withEmptyPath.GetHashCode()); - _ = await Assert.That(TypedEquals(withoutPath, withPath)).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(TypedEquals(withoutPath, withEmptyPath)).IsTrue(); + _ = await Assert.That(withoutPath.GetHashCode()).IsEqualTo(withEmptyPath.GetHashCode()); + _ = await Assert.That(TypedEquals(withoutPath, withPath)).IsFalse(); + } } private static TextSpan CreateSpan() => new TextSpan(KeySpanStart, KeySpanLength); diff --git a/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/MutantGeneratorTests.cs b/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/MutantGeneratorTests.cs index 956a8ba..2281632 100644 --- a/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/MutantGeneratorTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/MutantGeneratorTests.cs @@ -264,10 +264,13 @@ public async Task CreateMutations_MixedSource_YieldsMutationsOfSeveralOperators( { var prefixes = Prefixes(Generate(MixedSource)); - _ = await Assert.That(prefixes).Contains("numeric-literal"); - _ = await Assert.That(prefixes).Contains("conditional-expression"); - _ = await Assert.That(prefixes).Contains("null-coalescing"); - _ = await Assert.That(prefixes).Contains("string-literal"); + using (Assert.Multiple()) + { + _ = await Assert.That(prefixes).Contains("numeric-literal"); + _ = await Assert.That(prefixes).Contains("conditional-expression"); + _ = await Assert.That(prefixes).Contains("null-coalescing"); + _ = await Assert.That(prefixes).Contains("string-literal"); + } } [Test] @@ -283,10 +286,13 @@ public async Task CreateMutations_MixedSource_YieldsWellFormedMutations() .Where(mutation => !span.Contains(mutation.Location.SourceSpan)) .Select(mutation => mutation.OperatorId); - _ = await Assert.That(mutations.Length).IsGreaterThan(4); - _ = await Assert.That(malformed).IsEmpty(); - _ = await Assert.That(unnamed).IsEmpty(); - _ = await Assert.That(outside).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(mutations.Length).IsGreaterThan(4); + _ = await Assert.That(malformed).IsEmpty(); + _ = await Assert.That(unnamed).IsEmpty(); + _ = await Assert.That(outside).IsEmpty(); + } } [Test] @@ -358,8 +364,11 @@ public async Task CreateMutations_CommentHeaderWithoutTheMarker_YieldsTheSameMut var withBanner = Snippets(BannerCommentSource); var withoutBanner = Snippets(MixedSource); - _ = await Assert.That(withoutBanner.Length).IsGreaterThan(0); - _ = await Assert.That(withBanner).IsEquivalentTo(withoutBanner); + using (Assert.Multiple()) + { + _ = await Assert.That(withoutBanner.Length).IsGreaterThan(0); + _ = await Assert.That(withBanner).IsEquivalentTo(withoutBanner); + } } /// @@ -373,8 +382,11 @@ public async Task CreateMutations_ExcludingAttributeOnTheAssembly_YieldsTheSameM var withAttribute = Snippets(AssemblyAttributeSource); var withoutAttribute = Snippets(IncludedSource); - _ = await Assert.That(withoutAttribute.Length).IsGreaterThan(0); - _ = await Assert.That(withAttribute).IsEquivalentTo(withoutAttribute); + using (Assert.Multiple()) + { + _ = await Assert.That(withoutAttribute.Length).IsGreaterThan(0); + _ = await Assert.That(withAttribute).IsEquivalentTo(withoutAttribute); + } } /// @@ -449,8 +461,11 @@ public async Task CreateMutations_ExcludedType_DropsEveryMemberOfThatType() var excluded = Generate(ExcludedTypeSource); var included = Generate(IncludedSource); - _ = await Assert.That(included.Length).IsGreaterThan(0); - _ = await Assert.That(excluded).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(included.Length).IsGreaterThan(0); + _ = await Assert.That(excluded).IsEmpty(); + } } /// @@ -463,10 +478,13 @@ public async Task CreateMutations_ExcludedAccessor_DropsOnlyThatAccessor() var excluded = Snippets(ExcludedAccessorSource); var included = Snippets(IncludedAccessorSource); - _ = await Assert.That(included).Contains("_field + 1"); - _ = await Assert.That(included).Contains("value + 2"); - _ = await Assert.That(excluded).Contains("value + 2"); - _ = await Assert.That(excluded.Contains("_field + 1", StringComparer.Ordinal)).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(included).Contains("_field + 1"); + _ = await Assert.That(included).Contains("value + 2"); + _ = await Assert.That(excluded).Contains("value + 2"); + _ = await Assert.That(excluded.Contains("_field + 1", StringComparer.Ordinal)).IsFalse(); + } } [Test] @@ -475,8 +493,11 @@ public async Task CreateMutations_ExcludedLocalFunction_DropsOnlyThatLocalFuncti var excluded = Snippets(ExcludedLocalFunctionSource); var included = Snippets(IncludedLocalFunctionSource); - _ = await Assert.That(included).Contains("inner + 1"); - _ = await Assert.That(excluded.Contains("inner + 1", StringComparer.Ordinal)).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(included).Contains("inner + 1"); + _ = await Assert.That(excluded.Contains("inner + 1", StringComparer.Ordinal)).IsFalse(); + } } [Test] @@ -524,8 +545,11 @@ public async Task CreateMutations_CancelledAfterTheSequenceWasCreated_ThrowsBefo } }); - _ = await Assert.That(exception).IsNotNull(); - _ = await Assert.That(taken).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(exception).IsNotNull(); + _ = await Assert.That(taken).IsEmpty(); + } } [Test] diff --git a/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/MutationOperatorGuardTests.cs b/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/MutationOperatorGuardTests.cs index bfdbe56..5fd2fcf 100644 --- a/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/MutationOperatorGuardTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/MutationOperatorGuardTests.cs @@ -48,8 +48,11 @@ public async Task RegisteredOperatorIds_DataSource_CoversTheWholeRegistry() { var ids = RegisteredOperatorIds().Select(factory => factory()).ToArray(); - _ = await Assert.That(ids).IsEquivalentTo(MutationOperatorRegistry.All.Select(item => item.Id).ToArray()); - _ = await Assert.That(ids.Length).IsEqualTo(MutationOperatorRegistry.All.Length); + using (Assert.Multiple()) + { + _ = await Assert.That(ids).IsEquivalentTo(MutationOperatorRegistry.All.Select(item => item.Id).ToArray()); + _ = await Assert.That(ids.Length).IsEqualTo(MutationOperatorRegistry.All.Length); + } } [Test] @@ -91,9 +94,12 @@ public async Task CreateMutations_UnsupportedSyntaxKind_ReturnsEmpty(string oper var mutations = mutationOperator.CreateMutations(node, semanticModel, CancellationToken.None).ToArray(); - _ = await Assert.That(node.Kind()).IsEqualTo(UnsupportedKind); - _ = await Assert.That(mutationOperator.SupportedSyntaxKinds.Contains(UnsupportedKind)).IsFalse(); - _ = await Assert.That(mutations).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(node.Kind()).IsEqualTo(UnsupportedKind); + _ = await Assert.That(mutationOperator.SupportedSyntaxKinds.Contains(UnsupportedKind)).IsFalse(); + _ = await Assert.That(mutations).IsEmpty(); + } } [Test] @@ -102,8 +108,11 @@ public async Task SupportedSyntaxKinds_EveryOperator_IsNeitherDefaultNorEmpty(st { var mutationOperator = Find(operatorId); - _ = await Assert.That(mutationOperator.SupportedSyntaxKinds.IsDefaultOrEmpty).IsFalse(); - _ = await Assert.That(mutationOperator.Id).IsEqualTo(operatorId); + using (Assert.Multiple()) + { + _ = await Assert.That(mutationOperator.SupportedSyntaxKinds.IsDefaultOrEmpty).IsFalse(); + _ = await Assert.That(mutationOperator.Id).IsEqualTo(operatorId); + } } [Test] @@ -123,9 +132,12 @@ public async Task Constructor_IdIsEmpty_ThrowsArgumentException() _ = new ProbeMutator(string.Empty, MutationKind.ArithmeticOperator, [SyntaxKind.AddExpression]) ); - _ = await Assert.That(exception.GetType()).IsEqualTo(typeof(ArgumentException)); - _ = await Assert.That(exception.ParamName).IsEqualTo("id"); - _ = await Assert.That(exception.Message).Contains("The operator id must not be empty."); + using (Assert.Multiple()) + { + _ = await Assert.That(exception.GetType()).IsEqualTo(typeof(ArgumentException)); + _ = await Assert.That(exception.ParamName).IsEqualTo("id"); + _ = await Assert.That(exception.Message).Contains("The operator id must not be empty."); + } } [Test] @@ -135,9 +147,12 @@ public async Task Constructor_SupportedSyntaxKindsIsDefault_ThrowsArgumentExcept _ = new ProbeMutator(ProbeId, MutationKind.ArithmeticOperator, default) ); - _ = await Assert.That(exception.GetType()).IsEqualTo(typeof(ArgumentException)); - _ = await Assert.That(exception.ParamName).IsEqualTo("supportedSyntaxKinds"); - _ = await Assert.That(exception.Message).Contains("At least one supported syntax kind must be specified."); + using (Assert.Multiple()) + { + _ = await Assert.That(exception.GetType()).IsEqualTo(typeof(ArgumentException)); + _ = await Assert.That(exception.ParamName).IsEqualTo("supportedSyntaxKinds"); + _ = await Assert.That(exception.Message).Contains("At least one supported syntax kind must be specified."); + } } [Test] @@ -147,8 +162,11 @@ public async Task Constructor_SupportedSyntaxKindsIsEmpty_ThrowsArgumentExceptio _ = new ProbeMutator(ProbeId, MutationKind.ArithmeticOperator, ImmutableArray.Empty) ); - _ = await Assert.That(exception.GetType()).IsEqualTo(typeof(ArgumentException)); - _ = await Assert.That(exception.ParamName).IsEqualTo("supportedSyntaxKinds"); + using (Assert.Multiple()) + { + _ = await Assert.That(exception.GetType()).IsEqualTo(typeof(ArgumentException)); + _ = await Assert.That(exception.ParamName).IsEqualTo("supportedSyntaxKinds"); + } } [Test] @@ -156,9 +174,12 @@ public async Task Constructor_ValidArguments_ExposesIdKindAndSupportedKinds() { var mutator = new ProbeMutator(ProbeId, MutationKind.StringLiteral, [SyntaxKind.AddExpression]); - _ = await Assert.That(mutator.Id).IsEqualTo(ProbeId); - _ = await Assert.That(mutator.Kind).IsEqualTo(MutationKind.StringLiteral); - _ = await Assert.That(mutator.SupportedSyntaxKinds).IsEquivalentTo(new[] { SyntaxKind.AddExpression }); + using (Assert.Multiple()) + { + _ = await Assert.That(mutator.Id).IsEqualTo(ProbeId); + _ = await Assert.That(mutator.Kind).IsEqualTo(MutationKind.StringLiteral); + _ = await Assert.That(mutator.SupportedSyntaxKinds).IsEquivalentTo(new[] { SyntaxKind.AddExpression }); + } } [Test] @@ -170,9 +191,12 @@ public async Task CreateMutations_SupportedSyntaxKind_DelegatesToTheCore() var mutations = mutator.CreateMutations(node, semanticModel, CancellationToken.None).ToArray(); - _ = await Assert.That(mutator.CoreInvocations).IsEqualTo(1); - _ = await Assert.That(mutations.Length).IsEqualTo(1); - _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("probe.identity"); + using (Assert.Multiple()) + { + _ = await Assert.That(mutator.CoreInvocations).IsEqualTo(1); + _ = await Assert.That(mutations.Length).IsEqualTo(1); + _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("probe.identity"); + } } [Test] @@ -184,8 +208,11 @@ public async Task CreateMutations_UnsupportedSyntaxKind_NeverReachesTheCore() var mutations = mutator.CreateMutations(node, semanticModel, CancellationToken.None).ToArray(); - _ = await Assert.That(mutations).IsEmpty(); - _ = await Assert.That(mutator.CoreInvocations).IsEqualTo(0); + using (Assert.Multiple()) + { + _ = await Assert.That(mutations).IsEmpty(); + _ = await Assert.That(mutator.CoreInvocations).IsEqualTo(0); + } } [Test] @@ -209,11 +236,14 @@ public async Task CreateMutation_ValidArguments_ComposesTheOperatorIdFromIdAndSu var mutation = mutator.Create(node, node.Left, "add-to-left", "a + b => a"); - _ = await Assert.That(mutation.OperatorId).IsEqualTo("probe.add-to-left"); - _ = await Assert.That(mutation.DisplayName).IsEqualTo("a + b => a"); - _ = await Assert.That(mutation.Kind).IsEqualTo(MutationKind.StringLiteral); - _ = await Assert.That(mutation.Original.ToString()).IsEqualTo(node.ToString()); - _ = await Assert.That(mutation.Replacement.ToString()).IsEqualTo(node.Left.ToString()); + using (Assert.Multiple()) + { + _ = await Assert.That(mutation.OperatorId).IsEqualTo("probe.add-to-left"); + _ = await Assert.That(mutation.DisplayName).IsEqualTo("a + b => a"); + _ = await Assert.That(mutation.Kind).IsEqualTo(MutationKind.StringLiteral); + _ = await Assert.That(mutation.Original.ToString()).IsEqualTo(node.ToString()); + _ = await Assert.That(mutation.Replacement.ToString()).IsEqualTo(node.Left.ToString()); + } } private static IMutationOperator Find(string operatorId) => diff --git a/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/MutationOperatorRegistryTests.cs b/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/MutationOperatorRegistryTests.cs index 9f6ab98..200fe8d 100644 --- a/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/MutationOperatorRegistryTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/MutationOperatorRegistryTests.cs @@ -53,9 +53,12 @@ public async Task All_Registry_ContainsExactlyTheRegisteredOperators() { var actual = MutationOperatorRegistry.All.Select(mutationOperator => mutationOperator.Id); - _ = await Assert.That(_expectedOperatorIds.Length).IsEqualTo(ExpectedOperatorCount); - _ = await Assert.That(MutationOperatorRegistry.All.Length).IsEqualTo(ExpectedOperatorCount); - _ = await Assert.That(Join(Sort(actual))).IsEqualTo(Join(_expectedOperatorIds)); + using (Assert.Multiple()) + { + _ = await Assert.That(_expectedOperatorIds.Length).IsEqualTo(ExpectedOperatorCount); + _ = await Assert.That(MutationOperatorRegistry.All.Length).IsEqualTo(ExpectedOperatorCount); + _ = await Assert.That(Join(Sort(actual))).IsEqualTo(Join(_expectedOperatorIds)); + } } [Test] @@ -112,10 +115,13 @@ public async Task ForSyntaxKind_UnsupportedSyntaxKind_ReturnsEmpty() { var operators = MutationOperatorRegistry.ForSyntaxKind(SyntaxKind.ClassDeclaration); - _ = await Assert.That(operators.Length).IsEqualTo(0); - _ = await Assert - .That(MutationOperatorRegistry.SupportedSyntaxKinds.Contains(SyntaxKind.ClassDeclaration)) - .IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(operators.Length).IsEqualTo(0); + _ = await Assert + .That(MutationOperatorRegistry.SupportedSyntaxKinds.Contains(SyntaxKind.ClassDeclaration)) + .IsFalse(); + } } [Test] @@ -124,12 +130,15 @@ public async Task ForSyntaxKind_SupportedSyntaxKind_ReturnsTheOwningOperators() var booleanOperators = MutationOperatorRegistry.ForSyntaxKind(SyntaxKind.TrueLiteralExpression); var conditionalOperators = MutationOperatorRegistry.ForSyntaxKind(SyntaxKind.ConditionalExpression); - _ = await Assert - .That(Join(Sort(booleanOperators.Select(item => item.Id)))) - .IsEqualTo("boolean-literal, nullable-boolean-literal"); - _ = await Assert - .That(Join(Sort(conditionalOperators.Select(item => item.Id)))) - .IsEqualTo("conditional-expression, negation"); + using (Assert.Multiple()) + { + _ = await Assert + .That(Join(Sort(booleanOperators.Select(item => item.Id)))) + .IsEqualTo("boolean-literal, nullable-boolean-literal"); + _ = await Assert + .That(Join(Sort(conditionalOperators.Select(item => item.Id)))) + .IsEqualTo("conditional-expression, negation"); + } } /// @@ -144,17 +153,20 @@ public async Task ForSyntaxKind_SharedSyntaxKind_ReturnsEveryClaimingOperator() var invocationOperators = MutationOperatorRegistry.ForSyntaxKind(SyntaxKind.InvocationExpression); var stringLiteralOperators = MutationOperatorRegistry.ForSyntaxKind(SyntaxKind.StringLiteralExpression); - _ = await Assert - .That(Join(Sort(memberAccessOperators.Select(item => item.Id)))) - .IsEqualTo( - "culture.culture-info, culture.regex-options, culture.string-comparer, culture.string-comparison" - ); - _ = await Assert - .That(Join(Sort(invocationOperators.Select(item => item.Id)))) - .IsEqualTo("culture.case-conversion, culture.format-provider"); - _ = await Assert - .That(Join(Sort(stringLiteralOperators.Select(item => item.Id)))) - .IsEqualTo("regex.alternation, regex.anchor, regex.group, regex.quantifier, string-literal"); + using (Assert.Multiple()) + { + _ = await Assert + .That(Join(Sort(memberAccessOperators.Select(item => item.Id)))) + .IsEqualTo( + "culture.culture-info, culture.regex-options, culture.string-comparer, culture.string-comparison" + ); + _ = await Assert + .That(Join(Sort(invocationOperators.Select(item => item.Id)))) + .IsEqualTo("culture.case-conversion, culture.format-provider"); + _ = await Assert + .That(Join(Sort(stringLiteralOperators.Select(item => item.Id)))) + .IsEqualTo("regex.alternation, regex.anchor, regex.group, regex.quantifier, string-literal"); + } } [Test] @@ -162,15 +174,18 @@ public async Task SupportedSyntaxKinds_SharedSyntaxKind_IsListedExactlyOnce() { var kinds = MutationOperatorRegistry.SupportedSyntaxKinds; - _ = await Assert.That(kinds.Count(kind => kind == SyntaxKind.SimpleMemberAccessExpression)).IsEqualTo(1); - _ = await Assert.That(kinds.Count(kind => kind == SyntaxKind.InvocationExpression)).IsEqualTo(1); - _ = await Assert.That(kinds.Count(kind => kind == SyntaxKind.StringLiteralExpression)).IsEqualTo(1); - _ = await Assert - .That(MutationOperatorRegistry.ForSyntaxKind(SyntaxKind.SimpleMemberAccessExpression).Length) - .IsGreaterThan(1); - _ = await Assert - .That(MutationOperatorRegistry.ForSyntaxKind(SyntaxKind.StringLiteralExpression).Length) - .IsGreaterThan(1); + using (Assert.Multiple()) + { + _ = await Assert.That(kinds.Count(kind => kind == SyntaxKind.SimpleMemberAccessExpression)).IsEqualTo(1); + _ = await Assert.That(kinds.Count(kind => kind == SyntaxKind.InvocationExpression)).IsEqualTo(1); + _ = await Assert.That(kinds.Count(kind => kind == SyntaxKind.StringLiteralExpression)).IsEqualTo(1); + _ = await Assert + .That(MutationOperatorRegistry.ForSyntaxKind(SyntaxKind.SimpleMemberAccessExpression).Length) + .IsGreaterThan(1); + _ = await Assert + .That(MutationOperatorRegistry.ForSyntaxKind(SyntaxKind.StringLiteralExpression).Length) + .IsGreaterThan(1); + } } [Test] @@ -191,8 +206,11 @@ public async Task SupportedSyntaxKinds_Registry_ContainsNoDuplicate() { var kinds = MutationOperatorRegistry.SupportedSyntaxKinds; - _ = await Assert.That(kinds.Distinct().Count()).IsEqualTo(kinds.Length); - _ = await Assert.That(kinds.Length).IsGreaterThan(0); + using (Assert.Multiple()) + { + _ = await Assert.That(kinds.Distinct().Count()).IsEqualTo(kinds.Length); + _ = await Assert.That(kinds.Length).IsGreaterThan(0); + } } private static bool IsMismatch(SyntaxKind kind) diff --git a/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/MutationTests.cs b/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/MutationTests.cs index 9e3dae2..0312b31 100644 --- a/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/MutationTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/MutationTests.cs @@ -104,8 +104,11 @@ public async Task Constructor_WithoutLocation_UsesTheLocationOfTheOriginalNode() var mutation = CreateMutation(original, replacement); - _ = await Assert.That(mutation.Location.SourceTree).IsEqualTo(tree); - _ = await Assert.That(mutation.Location.SourceSpan).IsEqualTo(original.Span); + using (Assert.Multiple()) + { + _ = await Assert.That(mutation.Location.SourceTree).IsEqualTo(tree); + _ = await Assert.That(mutation.Location.SourceSpan).IsEqualTo(original.Span); + } } [Test] @@ -133,11 +136,14 @@ public async Task Constructor_ValidArguments_KeepsEveryValue() var mutation = CreateMutation(original, replacement); - _ = await Assert.That(mutation.Kind).IsEqualTo(MutationKind.BooleanLiteral); - _ = await Assert.That(mutation.OperatorId).IsEqualTo("boolean-literal.true-to-false"); - _ = await Assert.That(mutation.DisplayName).IsEqualTo("true => false"); - _ = await Assert.That(mutation.Original.ToString()).IsEqualTo("true"); - _ = await Assert.That(mutation.Replacement.ToString()).IsEqualTo("false"); + using (Assert.Multiple()) + { + _ = await Assert.That(mutation.Kind).IsEqualTo(MutationKind.BooleanLiteral); + _ = await Assert.That(mutation.OperatorId).IsEqualTo("boolean-literal.true-to-false"); + _ = await Assert.That(mutation.DisplayName).IsEqualTo("true => false"); + _ = await Assert.That(mutation.Original.ToString()).IsEqualTo("true"); + _ = await Assert.That(mutation.Replacement.ToString()).IsEqualTo("false"); + } } [Test] @@ -147,8 +153,11 @@ public async Task ToString_Always_ReturnsTheDisplayName() var mutation = CreateMutation(original, replacement); - _ = await Assert.That(mutation.ToString()).IsEqualTo(mutation.DisplayName); - _ = await Assert.That(mutation.ToString()).IsEqualTo("true => false"); + using (Assert.Multiple()) + { + _ = await Assert.That(mutation.ToString()).IsEqualTo(mutation.DisplayName); + _ = await Assert.That(mutation.ToString()).IsEqualTo("true => false"); + } } [Test] @@ -159,8 +168,11 @@ public async Task ApplyTo_OwningTree_ReplacesOnlyTheMutatedNode() var mutated = mutation.ApplyTo(tree); - _ = await Assert.That(mutated.ToString()).IsEqualTo(MutatedSource); - _ = await Assert.That(tree.ToString()).IsEqualTo(Source); + using (Assert.Multiple()) + { + _ = await Assert.That(mutated.ToString()).IsEqualTo(MutatedSource); + _ = await Assert.That(tree.ToString()).IsEqualTo(Source); + } } [Test] @@ -171,9 +183,12 @@ public async Task ApplyTo_OwningTree_KeepsFilePathAndParseOptions() var mutated = mutation.ApplyTo(tree); - _ = await Assert.That(mutated.FilePath).IsEqualTo(CompilationFactory.DefaultFilePath); - _ = await Assert.That(mutated.Options).IsEqualTo(tree.Options); - _ = await Assert.That(ReferenceEquals(mutated, tree)).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(mutated.FilePath).IsEqualTo(CompilationFactory.DefaultFilePath); + _ = await Assert.That(mutated.Options).IsEqualTo(tree.Options); + _ = await Assert.That(ReferenceEquals(mutated, tree)).IsFalse(); + } } [Test] diff --git a/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/ArithmeticAssignmentMutatorTests.cs b/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/ArithmeticAssignmentMutatorTests.cs index ecb170e..246631e 100644 --- a/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/ArithmeticAssignmentMutatorTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/ArithmeticAssignmentMutatorTests.cs @@ -480,20 +480,23 @@ public async Task Metadata_Operator_ExposesIdKindAndSupportedKinds() { var mutator = new ArithmeticAssignmentMutator(); - _ = await Assert.That(mutator.Id).IsEqualTo("arithmetic-assignment"); - _ = await Assert.That(mutator.Kind).IsEqualTo(MutationKind.ArithmeticAssignment); - _ = await Assert - .That(mutator.SupportedSyntaxKinds) - .IsEquivalentTo( - new[] - { - SyntaxKind.AddAssignmentExpression, - SyntaxKind.SubtractAssignmentExpression, - SyntaxKind.MultiplyAssignmentExpression, - SyntaxKind.DivideAssignmentExpression, - SyntaxKind.ModuloAssignmentExpression, - } - ); + using (Assert.Multiple()) + { + _ = await Assert.That(mutator.Id).IsEqualTo("arithmetic-assignment"); + _ = await Assert.That(mutator.Kind).IsEqualTo(MutationKind.ArithmeticAssignment); + _ = await Assert + .That(mutator.SupportedSyntaxKinds) + .IsEquivalentTo( + new[] + { + SyntaxKind.AddAssignmentExpression, + SyntaxKind.SubtractAssignmentExpression, + SyntaxKind.MultiplyAssignmentExpression, + SyntaxKind.DivideAssignmentExpression, + SyntaxKind.ModuloAssignmentExpression, + } + ); + } } [Test] @@ -521,15 +524,18 @@ string targetNames var targets = SplitValues(targetNames); var result = Mutate(AssignmentFixture(symbol)); - _ = await Assert - .That(Sorted(result.Mutations.Select(mutation => mutation.OperatorId))) - .IsEquivalentTo(Sorted(targets.Select(target => $"arithmetic-assignment.{originalName}-to-{target}"))); - _ = await Assert - .That(Sorted(result.Mutations.Select(mutation => mutation.DisplayName))) - .IsEquivalentTo(Sorted(targets.Select(target => $"{symbol} => {SymbolOf(target)}"))); - _ = await Assert - .That(result.Mutations.Select(mutation => mutation.Kind).Distinct()) - .IsEquivalentTo(new[] { MutationKind.ArithmeticAssignment }); + using (Assert.Multiple()) + { + _ = await Assert + .That(Sorted(result.Mutations.Select(mutation => mutation.OperatorId))) + .IsEquivalentTo(Sorted(targets.Select(target => $"arithmetic-assignment.{originalName}-to-{target}"))); + _ = await Assert + .That(Sorted(result.Mutations.Select(mutation => mutation.DisplayName))) + .IsEquivalentTo(Sorted(targets.Select(target => $"{symbol} => {SymbolOf(target)}"))); + _ = await Assert + .That(result.Mutations.Select(mutation => mutation.Kind).Distinct()) + .IsEquivalentTo(new[] { MutationKind.ArithmeticAssignment }); + } } [Test] @@ -543,9 +549,12 @@ public async Task SupportedSyntaxKinds_EveryKind_IsHandledByCreateMutations(stri var mutator = new ArithmeticAssignmentMutator(); var result = Mutate(AssignmentFixture(symbol)); - _ = await Assert.That(result.Node.Kind()).IsEqualTo(kind); - _ = await Assert.That(mutator.SupportedSyntaxKinds).Contains(kind); - _ = await Assert.That(result.Mutations).Count().IsEqualTo(4); + using (Assert.Multiple()) + { + _ = await Assert.That(result.Node.Kind()).IsEqualTo(kind); + _ = await Assert.That(mutator.SupportedSyntaxKinds).Contains(kind); + _ = await Assert.That(result.Mutations).Count().IsEqualTo(4); + } } [Test] @@ -568,8 +577,11 @@ public async Task CreateMutations_MutatedNodeIsTheOriginal_ReplacesOnlyTheOperat var result = Mutate(AssignmentFixture("+=")); var mutation = Single(result.Mutations, "arithmetic-assignment.add-assign-to-modulo-assign"); - _ = await Assert.That(mutation.Original).IsEqualTo(result.Node); - _ = await Assert.That(mutation.Replacement.ToString()).IsEqualTo("total %= value"); + using (Assert.Multiple()) + { + _ = await Assert.That(mutation.Original).IsEqualTo(result.Node); + _ = await Assert.That(mutation.Replacement.ToString()).IsEqualTo("total %= value"); + } } [Test] @@ -580,12 +592,15 @@ public async Task ApplyTo_AddAssignToDivideAssign_RewritesOperatorAndKeepsTrivia var mutated = mutation.ApplyTo(result.Tree).ToString(); - _ = await Assert - .That(mutated) - .IsEqualTo(TriviaSource.Replace("+= /* after */", "/= /* after */", StringComparison.Ordinal)); - _ = await Assert.That(mutated).Contains("// Accumulates a value."); - _ = await Assert.That(mutated).Contains("/* leading */"); - _ = await Assert.That(mutated).Contains("total /* inner */ /= /* after */ value; // tail"); + using (Assert.Multiple()) + { + _ = await Assert + .That(mutated) + .IsEqualTo(TriviaSource.Replace("+= /* after */", "/= /* after */", StringComparison.Ordinal)); + _ = await Assert.That(mutated).Contains("// Accumulates a value."); + _ = await Assert.That(mutated).Contains("/* leading */"); + _ = await Assert.That(mutated).Contains("total /* inner */ /= /* after */ value; // tail"); + } } [Test] @@ -593,8 +608,11 @@ public async Task CreateMutations_StringAppendOfLiteral_ReturnsEmpty() { var result = Mutate(StringAppendLiteralSource); - _ = await Assert.That(result.Node.Kind()).IsEqualTo(SyntaxKind.AddAssignmentExpression); - _ = await Assert.That(result.Mutations).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(result.Node.Kind()).IsEqualTo(SyntaxKind.AddAssignmentExpression); + _ = await Assert.That(result.Mutations).IsEmpty(); + } } [Test] @@ -619,14 +637,17 @@ public async Task CreateMutations_EventSubscription_ReturnsEmpty() var assignment = SyntaxNodeLocator.FindMarked(tree); var bound = semanticModel.GetSymbolInfo(assignment).Symbol; - _ = await Assert.That(result.Node.Kind()).IsEqualTo(SyntaxKind.AddAssignmentExpression); - _ = await Assert.That(bound).IsNotNull(); - _ = await Assert.That(bound is IEventSymbol).IsFalse(); - _ = await Assert.That((bound as IMethodSymbol)?.MethodKind).IsEqualTo(MethodKind.EventAdd); - _ = await Assert - .That(semanticModel.GetTypeInfo(assignment.Left).ConvertedType?.TypeKind) - .IsEqualTo(TypeKind.Delegate); - _ = await Assert.That(result.Mutations).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(result.Node.Kind()).IsEqualTo(SyntaxKind.AddAssignmentExpression); + _ = await Assert.That(bound).IsNotNull(); + _ = await Assert.That(bound is IEventSymbol).IsFalse(); + _ = await Assert.That((bound as IMethodSymbol)?.MethodKind).IsEqualTo(MethodKind.EventAdd); + _ = await Assert + .That(semanticModel.GetTypeInfo(assignment.Left).ConvertedType?.TypeKind) + .IsEqualTo(TypeKind.Delegate); + _ = await Assert.That(result.Mutations).IsEmpty(); + } } [Test] @@ -652,12 +673,15 @@ public async Task CreateMutations_UserDefinedOperatorWithCounterpart_ProducesOnl string[] expectedDisplayNames = ["+= => *="]; var result = Mutate(AddAndMultiplyOperatorSource); - _ = await Assert - .That(Sorted(result.Mutations.Select(mutation => mutation.OperatorId))) - .IsEquivalentTo(expectedIds); - _ = await Assert - .That(Sorted(result.Mutations.Select(mutation => mutation.DisplayName))) - .IsEquivalentTo(expectedDisplayNames); + using (Assert.Multiple()) + { + _ = await Assert + .That(Sorted(result.Mutations.Select(mutation => mutation.OperatorId))) + .IsEquivalentTo(expectedIds); + _ = await Assert + .That(Sorted(result.Mutations.Select(mutation => mutation.DisplayName))) + .IsEquivalentTo(expectedDisplayNames); + } } [Test] @@ -684,12 +708,15 @@ public async Task CreateMutations_UserDefinedOperatorOnAGenericType_ProducesOnly string[] expectedDisplayNames = ["+= => %="]; var result = Mutate(GenericOperatorSource); - _ = await Assert - .That(Sorted(result.Mutations.Select(mutation => mutation.OperatorId))) - .IsEquivalentTo(expectedIds); - _ = await Assert - .That(Sorted(result.Mutations.Select(mutation => mutation.DisplayName))) - .IsEquivalentTo(expectedDisplayNames); + using (Assert.Multiple()) + { + _ = await Assert + .That(Sorted(result.Mutations.Select(mutation => mutation.OperatorId))) + .IsEquivalentTo(expectedIds); + _ = await Assert + .That(Sorted(result.Mutations.Select(mutation => mutation.DisplayName))) + .IsEquivalentTo(expectedDisplayNames); + } } /// @@ -720,11 +747,14 @@ public async Task CreateMutations_OperatorReachedThroughAnImplicitConversion_Use var assignment = SyntaxNodeLocator.FindMarked(tree); var bound = semanticModel.GetSymbolInfo(assignment).Symbol as IMethodSymbol; - _ = await Assert.That(bound?.ContainingType.Name).IsEqualTo("Money"); - _ = await Assert.That(semanticModel.GetTypeInfo(assignment.Right).Type?.Name).IsEqualTo("Cents"); - _ = await Assert - .That(Sorted(result.Mutations.Select(mutation => mutation.OperatorId))) - .IsEquivalentTo(expectedIds); + using (Assert.Multiple()) + { + _ = await Assert.That(bound?.ContainingType.Name).IsEqualTo("Money"); + _ = await Assert.That(semanticModel.GetTypeInfo(assignment.Right).Type?.Name).IsEqualTo("Cents"); + _ = await Assert + .That(Sorted(result.Mutations.Select(mutation => mutation.OperatorId))) + .IsEquivalentTo(expectedIds); + } } /// @@ -742,10 +772,13 @@ public async Task CreateMutations_AssignmentTarget_ProducesEveryCounterpart(stri { var result = Mutate(TargetFixture(target)); - _ = await Assert.That(result.Node.Kind()).IsEqualTo(SyntaxKind.AddAssignmentExpression); - _ = await Assert - .That(Sorted(result.Mutations.Select(mutation => mutation.OperatorId))) - .IsEquivalentTo(AllCounterparts("add-assign")); + using (Assert.Multiple()) + { + _ = await Assert.That(result.Node.Kind()).IsEqualTo(SyntaxKind.AddAssignmentExpression); + _ = await Assert + .That(Sorted(result.Mutations.Select(mutation => mutation.OperatorId))) + .IsEquivalentTo(AllCounterparts("add-assign")); + } } /// @@ -820,11 +853,14 @@ public async Task CreateMutations_DynamicTarget_ProducesEveryCounterpart() var assignment = SyntaxNodeLocator.FindMarked(tree); var bound = semanticModel.GetSymbolInfo(assignment).Symbol as IMethodSymbol; - _ = await Assert.That(bound?.MethodKind).IsEqualTo(MethodKind.BuiltinOperator); - _ = await Assert.That(bound?.ToDisplayString()).IsEqualTo("dynamic.operator +(dynamic, dynamic)"); - _ = await Assert - .That(Sorted(result.Mutations.Select(mutation => mutation.OperatorId))) - .IsEquivalentTo(AllCounterparts("add-assign")); + using (Assert.Multiple()) + { + _ = await Assert.That(bound?.MethodKind).IsEqualTo(MethodKind.BuiltinOperator); + _ = await Assert.That(bound?.ToDisplayString()).IsEqualTo("dynamic.operator +(dynamic, dynamic)"); + _ = await Assert + .That(Sorted(result.Mutations.Select(mutation => mutation.OperatorId))) + .IsEquivalentTo(AllCounterparts("add-assign")); + } } /// @@ -855,10 +891,13 @@ public async Task CreateMutations_CheckedUserDefinedOperator_ProducesTheDeclared var assignment = SyntaxNodeLocator.FindMarked(tree); var bound = semanticModel.GetSymbolInfo(assignment).Symbol as IMethodSymbol; - _ = await Assert.That(bound?.MetadataName).IsEqualTo("op_CheckedAddition"); - _ = await Assert - .That(Sorted(result.Mutations.Select(mutation => mutation.OperatorId))) - .IsEquivalentTo(expectedIds); + using (Assert.Multiple()) + { + _ = await Assert.That(bound?.MetadataName).IsEqualTo("op_CheckedAddition"); + _ = await Assert + .That(Sorted(result.Mutations.Select(mutation => mutation.OperatorId))) + .IsEquivalentTo(expectedIds); + } } /// @@ -895,8 +934,11 @@ public async Task CreateMutations_OperatorOfAConstraintInterface_ReturnsEmpty() var assignment = SyntaxNodeLocator.FindMarked(tree); var bound = semanticModel.GetSymbolInfo(assignment).Symbol as IMethodSymbol; - _ = await Assert.That(bound?.MethodKind).IsEqualTo(MethodKind.UserDefinedOperator); - _ = await Assert.That(result.Mutations).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(bound?.MethodKind).IsEqualTo(MethodKind.UserDefinedOperator); + _ = await Assert.That(result.Mutations).IsEmpty(); + } } #endif @@ -905,9 +947,12 @@ public async Task CreateMutations_PointerTarget_ReturnsEmpty() { var result = MutateWithoutFixtureCheck(PointerTargetSource); - _ = await Assert.That(result.ErrorIds).IsEquivalentTo(_pointerErrorIds); - _ = await Assert.That(result.LeftType?.TypeKind).IsEqualTo(TypeKind.Pointer); - _ = await Assert.That(result.Mutations).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(result.ErrorIds).IsEquivalentTo(_pointerErrorIds); + _ = await Assert.That(result.LeftType?.TypeKind).IsEqualTo(TypeKind.Pointer); + _ = await Assert.That(result.Mutations).IsEmpty(); + } } [Test] @@ -915,9 +960,12 @@ public async Task CreateMutations_ErrorTypeTarget_ReturnsEmpty() { var result = MutateWithoutFixtureCheck(ErrorTypeTargetSource); - _ = await Assert.That(result.ErrorIds).IsEquivalentTo(_errorTypeErrorIds); - _ = await Assert.That(result.LeftType?.TypeKind).IsEqualTo(TypeKind.Error); - _ = await Assert.That(result.Mutations).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(result.ErrorIds).IsEquivalentTo(_errorTypeErrorIds); + _ = await Assert.That(result.LeftType?.TypeKind).IsEqualTo(TypeKind.Error); + _ = await Assert.That(result.Mutations).IsEmpty(); + } } [Test] @@ -953,9 +1001,14 @@ public async Task Mapper_SyntaxKindIsNoCompoundAssignment_ThrowsArgumentOutOfRan { var exception = InvokeMapper(mapperName, SyntaxKind.AndAssignmentExpression); - _ = await Assert.That(exception.ParamName).IsEqualTo("expressionKind"); - _ = await Assert.That(exception.ActualValue).IsEqualTo(SyntaxKind.AndAssignmentExpression); - _ = await Assert.That(exception.Message).Contains("The syntax kind is not a compound arithmetic assignment."); + using (Assert.Multiple()) + { + _ = await Assert.That(exception.ParamName).IsEqualTo("expressionKind"); + _ = await Assert.That(exception.ActualValue).IsEqualTo(SyntaxKind.AndAssignmentExpression); + _ = await Assert + .That(exception.Message) + .Contains("The syntax kind is not a compound arithmetic assignment."); + } } /// @@ -973,10 +1026,13 @@ public async Task HasCounterpart_OperandCountDiffers_ReturnsFalse() var unaryMinus = money.GetMembers("op_UnaryNegation").OfType().Single(); var binaryMinus = money.GetMembers("op_Subtraction").OfType().Single(); - _ = await Assert.That(CompilationFactory.GetCompileErrors(compilation)).IsEmpty(); - _ = await Assert.That(unaryMinus.Parameters.Length).IsEqualTo(1); - _ = await Assert.That(InvokeHasCounterpart(unaryMinus, "op_Subtraction")).IsFalse(); - _ = await Assert.That(InvokeHasCounterpart(binaryMinus, "op_Addition")).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(CompilationFactory.GetCompileErrors(compilation)).IsEmpty(); + _ = await Assert.That(unaryMinus.Parameters.Length).IsEqualTo(1); + _ = await Assert.That(InvokeHasCounterpart(unaryMinus, "op_Subtraction")).IsFalse(); + _ = await Assert.That(InvokeHasCounterpart(binaryMinus, "op_Addition")).IsTrue(); + } } private static string AssignmentFixture(string symbol) => diff --git a/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/ArithmeticOperatorMutatorTests.cs b/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/ArithmeticOperatorMutatorTests.cs index 61e3fed..ac40c8c 100644 --- a/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/ArithmeticOperatorMutatorTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/ArithmeticOperatorMutatorTests.cs @@ -360,20 +360,23 @@ public async Task Metadata_Operator_ExposesIdKindAndSupportedKinds() { var mutator = new ArithmeticOperatorMutator(); - _ = await Assert.That(mutator.Id).IsEqualTo("arithmetic"); - _ = await Assert.That(mutator.Kind).IsEqualTo(MutationKind.ArithmeticOperator); - _ = await Assert - .That(mutator.SupportedSyntaxKinds) - .IsEquivalentTo( - new[] - { - SyntaxKind.AddExpression, - SyntaxKind.SubtractExpression, - SyntaxKind.MultiplyExpression, - SyntaxKind.DivideExpression, - SyntaxKind.ModuloExpression, - } - ); + using (Assert.Multiple()) + { + _ = await Assert.That(mutator.Id).IsEqualTo("arithmetic"); + _ = await Assert.That(mutator.Kind).IsEqualTo(MutationKind.ArithmeticOperator); + _ = await Assert + .That(mutator.SupportedSyntaxKinds) + .IsEquivalentTo( + new[] + { + SyntaxKind.AddExpression, + SyntaxKind.SubtractExpression, + SyntaxKind.MultiplyExpression, + SyntaxKind.DivideExpression, + SyntaxKind.ModuloExpression, + } + ); + } } [Test] @@ -401,15 +404,18 @@ string targetNames var targets = SplitValues(targetNames); var result = Mutate(BinaryFixture(symbol)); - _ = await Assert - .That(Sorted(result.Mutations.Select(mutation => mutation.OperatorId))) - .IsEquivalentTo(Sorted(targets.Select(target => $"arithmetic.{originalName}-to-{target}"))); - _ = await Assert - .That(Sorted(result.Mutations.Select(mutation => mutation.DisplayName))) - .IsEquivalentTo(Sorted(targets.Select(target => $"{symbol} => {SymbolOf(target)}"))); - _ = await Assert - .That(result.Mutations.Select(mutation => mutation.Kind).Distinct()) - .IsEquivalentTo(new[] { MutationKind.ArithmeticOperator }); + using (Assert.Multiple()) + { + _ = await Assert + .That(Sorted(result.Mutations.Select(mutation => mutation.OperatorId))) + .IsEquivalentTo(Sorted(targets.Select(target => $"arithmetic.{originalName}-to-{target}"))); + _ = await Assert + .That(Sorted(result.Mutations.Select(mutation => mutation.DisplayName))) + .IsEquivalentTo(Sorted(targets.Select(target => $"{symbol} => {SymbolOf(target)}"))); + _ = await Assert + .That(result.Mutations.Select(mutation => mutation.Kind).Distinct()) + .IsEquivalentTo(new[] { MutationKind.ArithmeticOperator }); + } } [Test] @@ -423,9 +429,12 @@ public async Task SupportedSyntaxKinds_EveryKind_IsHandledByCreateMutations(stri var mutator = new ArithmeticOperatorMutator(); var result = Mutate(BinaryFixture(symbol)); - _ = await Assert.That(result.Node.Kind()).IsEqualTo(kind); - _ = await Assert.That(mutator.SupportedSyntaxKinds).Contains(kind); - _ = await Assert.That(result.Mutations).Count().IsEqualTo(4); + using (Assert.Multiple()) + { + _ = await Assert.That(result.Node.Kind()).IsEqualTo(kind); + _ = await Assert.That(mutator.SupportedSyntaxKinds).Contains(kind); + _ = await Assert.That(result.Mutations).Count().IsEqualTo(4); + } } [Test] @@ -446,9 +455,12 @@ public async Task CreateMutations_MutatedNodeIsTheOriginal_KeepsLocation() var result = Mutate(BinaryFixture("+")); var mutation = Single(result.Mutations, "arithmetic.add-to-subtract"); - _ = await Assert.That(mutation.Original).IsEqualTo(result.Node); - _ = await Assert.That(mutation.Replacement.ToString()).IsEqualTo("left - right"); - _ = await Assert.That(mutation.Location).IsEqualTo(result.Node.GetLocation()); + using (Assert.Multiple()) + { + _ = await Assert.That(mutation.Original).IsEqualTo(result.Node); + _ = await Assert.That(mutation.Replacement.ToString()).IsEqualTo("left - right"); + _ = await Assert.That(mutation.Location).IsEqualTo(result.Node.GetLocation()); + } } [Test] @@ -459,12 +471,15 @@ public async Task ApplyTo_AddToMultiply_RewritesOperatorAndKeepsTrivia() var mutated = mutation.ApplyTo(result.Tree).ToString(); - _ = await Assert - .That(mutated) - .IsEqualTo(TriviaSource.Replace("+ /* after */", "* /* after */", StringComparison.Ordinal)); - _ = await Assert.That(mutated).Contains("// Combines two numbers."); - _ = await Assert.That(mutated).Contains("/* leading */"); - _ = await Assert.That(mutated).Contains("left /* inner */ * /* after */ right; // tail"); + using (Assert.Multiple()) + { + _ = await Assert + .That(mutated) + .IsEqualTo(TriviaSource.Replace("+ /* after */", "* /* after */", StringComparison.Ordinal)); + _ = await Assert.That(mutated).Contains("// Combines two numbers."); + _ = await Assert.That(mutated).Contains("/* leading */"); + _ = await Assert.That(mutated).Contains("left /* inner */ * /* after */ right; // tail"); + } } [Test] @@ -480,8 +495,11 @@ public async Task CreateMutations_StringOperands_ReturnsEmpty() { var result = Mutate(StringOperandSource); - _ = await Assert.That(result.Node.Kind()).IsEqualTo(SyntaxKind.AddExpression); - _ = await Assert.That(result.Mutations).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(result.Node.Kind()).IsEqualTo(SyntaxKind.AddExpression); + _ = await Assert.That(result.Mutations).IsEmpty(); + } } [Test] @@ -489,8 +507,11 @@ public async Task CreateMutations_DelegateOperands_ReturnsEmpty() { var result = Mutate(DelegateOperandSource); - _ = await Assert.That(result.Node.Kind()).IsEqualTo(SyntaxKind.AddExpression); - _ = await Assert.That(result.Mutations).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(result.Node.Kind()).IsEqualTo(SyntaxKind.AddExpression); + _ = await Assert.That(result.Mutations).IsEmpty(); + } } [Test] @@ -508,12 +529,15 @@ public async Task CreateMutations_UserDefinedOperatorWithCounterpart_ProducesOnl string[] expectedDisplayNames = ["+ => -"]; var result = Mutate(AddAndSubtractOperatorSource); - _ = await Assert - .That(Sorted(result.Mutations.Select(mutation => mutation.OperatorId))) - .IsEquivalentTo(expectedIds); - _ = await Assert - .That(Sorted(result.Mutations.Select(mutation => mutation.DisplayName))) - .IsEquivalentTo(expectedDisplayNames); + using (Assert.Multiple()) + { + _ = await Assert + .That(Sorted(result.Mutations.Select(mutation => mutation.OperatorId))) + .IsEquivalentTo(expectedIds); + _ = await Assert + .That(Sorted(result.Mutations.Select(mutation => mutation.DisplayName))) + .IsEquivalentTo(expectedDisplayNames); + } } [Test] @@ -540,12 +564,15 @@ public async Task CreateMutations_UserDefinedOperatorOnAGenericType_ProducesOnly string[] expectedDisplayNames = ["+ => *"]; var result = Mutate(GenericOperatorSource); - _ = await Assert - .That(Sorted(result.Mutations.Select(mutation => mutation.OperatorId))) - .IsEquivalentTo(expectedIds); - _ = await Assert - .That(Sorted(result.Mutations.Select(mutation => mutation.DisplayName))) - .IsEquivalentTo(expectedDisplayNames); + using (Assert.Multiple()) + { + _ = await Assert + .That(Sorted(result.Mutations.Select(mutation => mutation.OperatorId))) + .IsEquivalentTo(expectedIds); + _ = await Assert + .That(Sorted(result.Mutations.Select(mutation => mutation.DisplayName))) + .IsEquivalentTo(expectedDisplayNames); + } } /// @@ -577,11 +604,14 @@ public async Task CreateMutations_OperatorReachedThroughAnImplicitConversion_Use var binary = SyntaxNodeLocator.FindMarked(tree); var bound = semanticModel.GetSymbolInfo(binary).Symbol as IMethodSymbol; - _ = await Assert.That(bound?.ContainingType.Name).IsEqualTo("Money"); - _ = await Assert.That(semanticModel.GetTypeInfo(binary.Right).Type?.Name).IsEqualTo("Cents"); - _ = await Assert - .That(Sorted(result.Mutations.Select(mutation => mutation.OperatorId))) - .IsEquivalentTo(expectedIds); + using (Assert.Multiple()) + { + _ = await Assert.That(bound?.ContainingType.Name).IsEqualTo("Money"); + _ = await Assert.That(semanticModel.GetTypeInfo(binary.Right).Type?.Name).IsEqualTo("Cents"); + _ = await Assert + .That(Sorted(result.Mutations.Select(mutation => mutation.OperatorId))) + .IsEquivalentTo(expectedIds); + } } /// @@ -600,8 +630,11 @@ public async Task CreateMutations_StringOnOneSideOnly_ReturnsEmpty(string expres { var result = Mutate(ConcatFixture(expression)); - _ = await Assert.That(result.Node.Kind()).IsEqualTo(SyntaxKind.AddExpression); - _ = await Assert.That(result.Mutations).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(result.Node.Kind()).IsEqualTo(SyntaxKind.AddExpression); + _ = await Assert.That(result.Mutations).IsEmpty(); + } } /// @@ -617,11 +650,14 @@ public async Task CreateMutations_OperandsConvertedToStringImplicitly_ReturnsEmp var binary = SyntaxNodeLocator.FindMarked(tree); var bound = semanticModel.GetSymbolInfo(binary).Symbol as IMethodSymbol; - _ = await Assert.That(bound?.ContainingType.SpecialType).IsEqualTo(SpecialType.System_String); - _ = await Assert - .That(semanticModel.GetTypeInfo(binary.Left).ConvertedType?.SpecialType) - .IsEqualTo(SpecialType.System_String); - _ = await Assert.That(result.Mutations).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(bound?.ContainingType.SpecialType).IsEqualTo(SpecialType.System_String); + _ = await Assert + .That(semanticModel.GetTypeInfo(binary.Left).ConvertedType?.SpecialType) + .IsEqualTo(SpecialType.System_String); + _ = await Assert.That(result.Mutations).IsEmpty(); + } } [Test] @@ -675,11 +711,14 @@ public async Task CreateMutations_DynamicOperands_ProducesEveryCounterpart() var binary = SyntaxNodeLocator.FindMarked(tree); var bound = semanticModel.GetSymbolInfo(binary).Symbol as IMethodSymbol; - _ = await Assert.That(bound?.MethodKind).IsEqualTo(MethodKind.BuiltinOperator); - _ = await Assert.That(bound?.ToDisplayString()).IsEqualTo("dynamic.operator +(dynamic, dynamic)"); - _ = await Assert - .That(Sorted(result.Mutations.Select(mutation => mutation.OperatorId))) - .IsEquivalentTo(AllCounterparts("add")); + using (Assert.Multiple()) + { + _ = await Assert.That(bound?.MethodKind).IsEqualTo(MethodKind.BuiltinOperator); + _ = await Assert.That(bound?.ToDisplayString()).IsEqualTo("dynamic.operator +(dynamic, dynamic)"); + _ = await Assert + .That(Sorted(result.Mutations.Select(mutation => mutation.OperatorId))) + .IsEquivalentTo(AllCounterparts("add")); + } } /// @@ -711,10 +750,13 @@ public async Task CreateMutations_CheckedUserDefinedOperator_ProducesTheDeclared var binary = SyntaxNodeLocator.FindMarked(tree); var bound = semanticModel.GetSymbolInfo(binary).Symbol as IMethodSymbol; - _ = await Assert.That(bound?.MetadataName).IsEqualTo("op_CheckedAddition"); - _ = await Assert - .That(Sorted(result.Mutations.Select(mutation => mutation.OperatorId))) - .IsEquivalentTo(expectedIds); + using (Assert.Multiple()) + { + _ = await Assert.That(bound?.MetadataName).IsEqualTo("op_CheckedAddition"); + _ = await Assert + .That(Sorted(result.Mutations.Select(mutation => mutation.OperatorId))) + .IsEquivalentTo(expectedIds); + } } /// @@ -751,8 +793,11 @@ public async Task CreateMutations_OperatorOfAConstraintInterface_ReturnsEmpty() var binary = SyntaxNodeLocator.FindMarked(tree); var bound = semanticModel.GetSymbolInfo(binary).Symbol as IMethodSymbol; - _ = await Assert.That(bound?.MethodKind).IsEqualTo(MethodKind.UserDefinedOperator); - _ = await Assert.That(result.Mutations).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(bound?.MethodKind).IsEqualTo(MethodKind.UserDefinedOperator); + _ = await Assert.That(result.Mutations).IsEmpty(); + } } #endif @@ -765,9 +810,12 @@ public async Task CreateMutations_PointerOperands_ReturnsEmpty() { var result = MutateWithoutFixtureCheck(PointerOperandSource); - _ = await Assert.That(result.ErrorIds).IsEquivalentTo(_pointerErrorIds); - _ = await Assert.That(result.LeftType?.TypeKind).IsEqualTo(TypeKind.Pointer); - _ = await Assert.That(result.Mutations).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(result.ErrorIds).IsEquivalentTo(_pointerErrorIds); + _ = await Assert.That(result.LeftType?.TypeKind).IsEqualTo(TypeKind.Pointer); + _ = await Assert.That(result.Mutations).IsEmpty(); + } } /// @@ -779,9 +827,12 @@ public async Task CreateMutations_ErrorTypeOperands_ReturnsEmpty() { var result = MutateWithoutFixtureCheck(ErrorTypeOperandSource); - _ = await Assert.That(result.ErrorIds).IsEquivalentTo(_errorTypeErrorIds); - _ = await Assert.That(result.LeftType?.TypeKind).IsEqualTo(TypeKind.Error); - _ = await Assert.That(result.Mutations).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(result.ErrorIds).IsEquivalentTo(_errorTypeErrorIds); + _ = await Assert.That(result.LeftType?.TypeKind).IsEqualTo(TypeKind.Error); + _ = await Assert.That(result.Mutations).IsEmpty(); + } } [Test] @@ -817,9 +868,12 @@ public async Task Mapper_SyntaxKindIsNotArithmetic_ThrowsArgumentOutOfRangeExcep { var exception = InvokeMapper(mapperName, SyntaxKind.BitwiseAndExpression); - _ = await Assert.That(exception.ParamName).IsEqualTo("expressionKind"); - _ = await Assert.That(exception.ActualValue).IsEqualTo(SyntaxKind.BitwiseAndExpression); - _ = await Assert.That(exception.Message).Contains("The syntax kind is not a binary arithmetic expression."); + using (Assert.Multiple()) + { + _ = await Assert.That(exception.ParamName).IsEqualTo("expressionKind"); + _ = await Assert.That(exception.ActualValue).IsEqualTo(SyntaxKind.BitwiseAndExpression); + _ = await Assert.That(exception.Message).Contains("The syntax kind is not a binary arithmetic expression."); + } } /// @@ -837,10 +891,13 @@ public async Task HasCounterpart_OperandCountDiffers_ReturnsFalse() var unaryMinus = money.GetMembers("op_UnaryNegation").OfType().Single(); var binaryMinus = money.GetMembers("op_Subtraction").OfType().Single(); - _ = await Assert.That(CompilationFactory.GetCompileErrors(compilation)).IsEmpty(); - _ = await Assert.That(unaryMinus.Parameters.Length).IsEqualTo(1); - _ = await Assert.That(InvokeHasCounterpart(unaryMinus, "op_Subtraction")).IsFalse(); - _ = await Assert.That(InvokeHasCounterpart(binaryMinus, "op_Addition")).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(CompilationFactory.GetCompileErrors(compilation)).IsEmpty(); + _ = await Assert.That(unaryMinus.Parameters.Length).IsEqualTo(1); + _ = await Assert.That(InvokeHasCounterpart(unaryMinus, "op_Subtraction")).IsFalse(); + _ = await Assert.That(InvokeHasCounterpart(binaryMinus, "op_Addition")).IsTrue(); + } } private static string BinaryFixture(string symbol) => diff --git a/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/BitwiseOperatorMutatorTests.cs b/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/BitwiseOperatorMutatorTests.cs index 3b28d89..4164ac7 100644 --- a/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/BitwiseOperatorMutatorTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/BitwiseOperatorMutatorTests.cs @@ -157,20 +157,23 @@ public async Task Metadata_Operator_ExposesIdKindAndSupportedKinds() { var mutator = new BitwiseOperatorMutator(); - _ = await Assert.That(mutator.Id).IsEqualTo("bitwise"); - _ = await Assert.That(mutator.Kind).IsEqualTo(MutationKind.BitwiseOperator); - _ = await Assert - .That(mutator.SupportedSyntaxKinds) - .IsEquivalentTo( - new[] - { - SyntaxKind.BitwiseAndExpression, - SyntaxKind.BitwiseOrExpression, - SyntaxKind.ExclusiveOrExpression, - SyntaxKind.LeftShiftExpression, - SyntaxKind.RightShiftExpression, - } - ); + using (Assert.Multiple()) + { + _ = await Assert.That(mutator.Id).IsEqualTo("bitwise"); + _ = await Assert.That(mutator.Kind).IsEqualTo(MutationKind.BitwiseOperator); + _ = await Assert + .That(mutator.SupportedSyntaxKinds) + .IsEquivalentTo( + new[] + { + SyntaxKind.BitwiseAndExpression, + SyntaxKind.BitwiseOrExpression, + SyntaxKind.ExclusiveOrExpression, + SyntaxKind.LeftShiftExpression, + SyntaxKind.RightShiftExpression, + } + ); + } } [Test] @@ -196,15 +199,18 @@ string expectedDisplayNames var result = Mutate(Fixture($"left {symbol} right")); - _ = await Assert - .That(Sorted(result.Mutations.Select(mutation => mutation.OperatorId))) - .IsEquivalentTo(Sorted(SplitValues(expectedIds))); - _ = await Assert - .That(Sorted(result.Mutations.Select(mutation => mutation.DisplayName))) - .IsEquivalentTo(Sorted(SplitValues(expectedDisplayNames))); - _ = await Assert - .That(result.Mutations.Select(mutation => mutation.Kind).Distinct()) - .IsEquivalentTo(new[] { MutationKind.BitwiseOperator }); + using (Assert.Multiple()) + { + _ = await Assert + .That(Sorted(result.Mutations.Select(mutation => mutation.OperatorId))) + .IsEquivalentTo(Sorted(SplitValues(expectedIds))); + _ = await Assert + .That(Sorted(result.Mutations.Select(mutation => mutation.DisplayName))) + .IsEquivalentTo(Sorted(SplitValues(expectedDisplayNames))); + _ = await Assert + .That(result.Mutations.Select(mutation => mutation.Kind).Distinct()) + .IsEquivalentTo(new[] { MutationKind.BitwiseOperator }); + } } [Test] @@ -219,13 +225,16 @@ string expectedReplacement { var result = Mutate(Fixture($"left {symbol} right")); - _ = await Assert - .That(Sorted(result.Mutations.Select(mutation => mutation.OperatorId))) - .IsEquivalentTo(new[] { expectedId }); - _ = await Assert.That(result.Mutations[0].DisplayName).IsEqualTo(expectedDisplayName); - _ = await Assert.That(result.Mutations[0].Replacement.ToString()).IsEqualTo(expectedReplacement); - _ = await Assert.That(result.Mutations[0].Kind.ToString()).IsEqualTo("ShiftOperator"); - _ = await Assert.That(result.Mutations[0].Original).IsEqualTo(result.Node); + using (Assert.Multiple()) + { + _ = await Assert + .That(Sorted(result.Mutations.Select(mutation => mutation.OperatorId))) + .IsEquivalentTo(new[] { expectedId }); + _ = await Assert.That(result.Mutations[0].DisplayName).IsEqualTo(expectedDisplayName); + _ = await Assert.That(result.Mutations[0].Replacement.ToString()).IsEqualTo(expectedReplacement); + _ = await Assert.That(result.Mutations[0].Kind.ToString()).IsEqualTo("ShiftOperator"); + _ = await Assert.That(result.Mutations[0].Original).IsEqualTo(result.Node); + } } [Test] @@ -243,9 +252,12 @@ int expectedCount var mutator = new BitwiseOperatorMutator(); var result = Mutate(Fixture(expression)); - _ = await Assert.That(result.Node.Kind()).IsEqualTo(kind); - _ = await Assert.That(mutator.SupportedSyntaxKinds).Contains(kind); - _ = await Assert.That(result.Mutations).Count().IsEqualTo(expectedCount); + using (Assert.Multiple()) + { + _ = await Assert.That(result.Node.Kind()).IsEqualTo(kind); + _ = await Assert.That(mutator.SupportedSyntaxKinds).Contains(kind); + _ = await Assert.That(result.Mutations).Count().IsEqualTo(expectedCount); + } } [Test] @@ -307,12 +319,15 @@ public async Task ApplyTo_AndToXor_RewritesOperatorAndKeepsTrivia() var mutated = mutation.ApplyTo(result.Tree).ToString(); - _ = await Assert - .That(mutated) - .IsEqualTo(TriviaSource.Replace("& /* after */", "^ /* after */", StringComparison.Ordinal)); - _ = await Assert.That(mutated).Contains("// Masks two values."); - _ = await Assert.That(mutated).Contains("/* leading */"); - _ = await Assert.That(mutated).Contains("left /* inner */ ^ /* after */ right; // tail"); + using (Assert.Multiple()) + { + _ = await Assert + .That(mutated) + .IsEqualTo(TriviaSource.Replace("& /* after */", "^ /* after */", StringComparison.Ordinal)); + _ = await Assert.That(mutated).Contains("// Masks two values."); + _ = await Assert.That(mutated).Contains("/* leading */"); + _ = await Assert.That(mutated).Contains("left /* inner */ ^ /* after */ right; // tail"); + } } [Test] @@ -362,9 +377,12 @@ public async Task CreateMutations_EnumOperandOfAShift_ReturnsEmpty() var (mutations, _, node, model) = MutateAllowingErrors(EnumShiftSource); var binary = (BinaryExpressionSyntax)node; - _ = await Assert.That(node.Kind()).IsEqualTo(SyntaxKind.LeftShiftExpression); - _ = await Assert.That(model.GetTypeInfo(binary.Left).ConvertedType?.TypeKind).IsEqualTo(TypeKind.Enum); - _ = await Assert.That(mutations).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(node.Kind()).IsEqualTo(SyntaxKind.LeftShiftExpression); + _ = await Assert.That(model.GetTypeInfo(binary.Left).ConvertedType?.TypeKind).IsEqualTo(TypeKind.Enum); + _ = await Assert.That(mutations).IsEmpty(); + } } /// @@ -378,9 +396,12 @@ public async Task CreateMutations_TypelessOperand_ReturnsEmpty() var (mutations, _, node, model) = MutateAllowingErrors(MethodGroupOperandSource); var binary = (BinaryExpressionSyntax)node; - _ = await Assert.That(node.Kind()).IsEqualTo(SyntaxKind.BitwiseAndExpression); - _ = await Assert.That(model.GetTypeInfo(binary.Left).ConvertedType).IsNull(); - _ = await Assert.That(mutations).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(node.Kind()).IsEqualTo(SyntaxKind.BitwiseAndExpression); + _ = await Assert.That(model.GetTypeInfo(binary.Left).ConvertedType).IsNull(); + _ = await Assert.That(mutations).IsEmpty(); + } } /// @@ -413,9 +434,12 @@ string expectedReplacement { var result = Mutate(Fixture(expression)); - _ = await Assert.That(result.Mutations).Count().IsEqualTo(1); - _ = await Assert.That(result.Mutations[0].Replacement.ToString()).IsEqualTo(expectedReplacement); - _ = await Assert.That(result.Mutations[0].Kind.ToString()).IsEqualTo("ShiftOperator"); + using (Assert.Multiple()) + { + _ = await Assert.That(result.Mutations).Count().IsEqualTo(1); + _ = await Assert.That(result.Mutations[0].Replacement.ToString()).IsEqualTo(expectedReplacement); + _ = await Assert.That(result.Mutations[0].Kind.ToString()).IsEqualTo("ShiftOperator"); + } } [Test] @@ -424,10 +448,13 @@ public async Task CreateMutations_NullableIntegralShiftOperand_SwapsTheDirection string[] expectedIds = ["bitwise.left-shift-to-right-shift"]; var result = Mutate(Fixture("nullableLeft << right")); - _ = await Assert - .That(Sorted(result.Mutations.Select(mutation => mutation.OperatorId))) - .IsEquivalentTo(expectedIds); - _ = await Assert.That(result.Mutations[0].Replacement.ToString()).IsEqualTo("nullableLeft >> right"); + using (Assert.Multiple()) + { + _ = await Assert + .That(Sorted(result.Mutations.Select(mutation => mutation.OperatorId))) + .IsEquivalentTo(expectedIds); + _ = await Assert.That(result.Mutations[0].Replacement.ToString()).IsEqualTo("nullableLeft >> right"); + } } /// @@ -440,9 +467,12 @@ public async Task CreateMutations_BooleanShiftCount_ReturnsEmpty() var (mutations, _, node, model) = MutateAllowingErrors(BooleanShiftCountSource); var binary = (BinaryExpressionSyntax)node; - _ = await Assert.That(node.Kind()).IsEqualTo(SyntaxKind.LeftShiftExpression); - _ = await Assert.That(model.GetTypeInfo(binary.Right).ConvertedType?.ToDisplayString()).IsEqualTo("bool"); - _ = await Assert.That(mutations).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(node.Kind()).IsEqualTo(SyntaxKind.LeftShiftExpression); + _ = await Assert.That(model.GetTypeInfo(binary.Right).ConvertedType?.ToDisplayString()).IsEqualTo("bool"); + _ = await Assert.That(mutations).IsEmpty(); + } } /// @@ -454,9 +484,12 @@ public async Task CreateMutations_EnumShiftCount_ReturnsEmpty() var (mutations, _, node, model) = MutateAllowingErrors(EnumShiftCountSource); var binary = (BinaryExpressionSyntax)node; - _ = await Assert.That(model.GetTypeInfo(binary.Left).ConvertedType?.ToDisplayString()).IsEqualTo("int"); - _ = await Assert.That(model.GetTypeInfo(binary.Right).ConvertedType?.TypeKind).IsEqualTo(TypeKind.Enum); - _ = await Assert.That(mutations).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(model.GetTypeInfo(binary.Left).ConvertedType?.ToDisplayString()).IsEqualTo("int"); + _ = await Assert.That(model.GetTypeInfo(binary.Right).ConvertedType?.TypeKind).IsEqualTo(TypeKind.Enum); + _ = await Assert.That(mutations).IsEmpty(); + } } /// @@ -469,9 +502,12 @@ public async Task CreateMutations_IntegralLeftAndBooleanRightOperand_ReturnsEmpt var (mutations, _, node, model) = MutateAllowingErrors(MixedIntegralAndBooleanSource); var binary = (BinaryExpressionSyntax)node; - _ = await Assert.That(model.GetTypeInfo(binary.Left).ConvertedType?.ToDisplayString()).IsEqualTo("int"); - _ = await Assert.That(model.GetTypeInfo(binary.Right).ConvertedType?.ToDisplayString()).IsEqualTo("bool"); - _ = await Assert.That(mutations).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(model.GetTypeInfo(binary.Left).ConvertedType?.ToDisplayString()).IsEqualTo("int"); + _ = await Assert.That(model.GetTypeInfo(binary.Right).ConvertedType?.ToDisplayString()).IsEqualTo("bool"); + _ = await Assert.That(mutations).IsEmpty(); + } } /// @@ -483,8 +519,11 @@ public async Task CreateMutations_UserDefinedBitwiseOperatorWithoutCounterparts_ { var result = Mutate(AndOnlyUserDefinedSource); - _ = await Assert.That(result.Node.Kind()).IsEqualTo(SyntaxKind.BitwiseAndExpression); - _ = await Assert.That(result.Mutations).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(result.Node.Kind()).IsEqualTo(SyntaxKind.BitwiseAndExpression); + _ = await Assert.That(result.Mutations).IsEmpty(); + } } [Test] diff --git a/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/BooleanLiteralMutatorTests.cs b/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/BooleanLiteralMutatorTests.cs index 7873c17..fbd8f72 100644 --- a/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/BooleanLiteralMutatorTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/BooleanLiteralMutatorTests.cs @@ -76,11 +76,14 @@ public async Task Metadata_Operator_DescribesBooleanLiteralFamily() var mutator = new BooleanLiteralMutator(); SyntaxKind[] supported = [.. mutator.SupportedSyntaxKinds]; - _ = await Assert.That(mutator.Id).IsEqualTo("boolean-literal"); - _ = await Assert.That(mutator.Kind).IsEqualTo(MutationKind.BooleanLiteral); - _ = await Assert.That(supported).Count().IsEqualTo(2); - _ = await Assert.That(supported).Contains(SyntaxKind.TrueLiteralExpression); - _ = await Assert.That(supported).Contains(SyntaxKind.FalseLiteralExpression); + using (Assert.Multiple()) + { + _ = await Assert.That(mutator.Id).IsEqualTo("boolean-literal"); + _ = await Assert.That(mutator.Kind).IsEqualTo(MutationKind.BooleanLiteral); + _ = await Assert.That(supported).Count().IsEqualTo(2); + _ = await Assert.That(supported).Contains(SyntaxKind.TrueLiteralExpression); + _ = await Assert.That(supported).Contains(SyntaxKind.FalseLiteralExpression); + } } [Test] @@ -88,12 +91,15 @@ public async Task CreateMutations_TrueLiteral_ReplacesItByFalse() { var (tree, mutations) = Run(TrueSource); - _ = await Assert.That(mutations).Count().IsEqualTo(1); - _ = await Assert.That(mutations[0].Kind).IsEqualTo(MutationKind.BooleanLiteral); - _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("boolean-literal.true-to-false"); - _ = await Assert.That(mutations[0].DisplayName).IsEqualTo("true => false"); - _ = await Assert.That(mutations[0].Replacement.IsKind(SyntaxKind.FalseLiteralExpression)).IsTrue(); - _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(FalseSource); + using (Assert.Multiple()) + { + _ = await Assert.That(mutations).Count().IsEqualTo(1); + _ = await Assert.That(mutations[0].Kind).IsEqualTo(MutationKind.BooleanLiteral); + _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("boolean-literal.true-to-false"); + _ = await Assert.That(mutations[0].DisplayName).IsEqualTo("true => false"); + _ = await Assert.That(mutations[0].Replacement.IsKind(SyntaxKind.FalseLiteralExpression)).IsTrue(); + _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(FalseSource); + } } [Test] @@ -101,11 +107,14 @@ public async Task CreateMutations_FalseLiteral_ReplacesItByTrue() { var (tree, mutations) = Run(FalseSource); - _ = await Assert.That(mutations).Count().IsEqualTo(1); - _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("boolean-literal.false-to-true"); - _ = await Assert.That(mutations[0].DisplayName).IsEqualTo("false => true"); - _ = await Assert.That(mutations[0].Replacement.IsKind(SyntaxKind.TrueLiteralExpression)).IsTrue(); - _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(TrueSource); + using (Assert.Multiple()) + { + _ = await Assert.That(mutations).Count().IsEqualTo(1); + _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("boolean-literal.false-to-true"); + _ = await Assert.That(mutations[0].DisplayName).IsEqualTo("false => true"); + _ = await Assert.That(mutations[0].Replacement.IsKind(SyntaxKind.TrueLiteralExpression)).IsTrue(); + _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(TrueSource); + } } [Test] @@ -113,8 +122,11 @@ public async Task CreateMutations_NonConstantFieldInitializer_IsMutated() { var (_, mutations) = Run(InstanceFieldSource); - _ = await Assert.That(mutations).Count().IsEqualTo(1); - _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("boolean-literal.true-to-false"); + using (Assert.Multiple()) + { + _ = await Assert.That(mutations).Count().IsEqualTo(1); + _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("boolean-literal.true-to-false"); + } } /// @@ -127,9 +139,12 @@ public async Task CreateMutations_NonConstantLocalDeclaration_IsMutated() var expected = LocalDeclarationSource.Replace("= true", "= false", StringComparison.Ordinal); var (tree, mutations) = Run(LocalDeclarationSource); - _ = await Assert.That(mutations).Count().IsEqualTo(1); - _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("boolean-literal.true-to-false"); - _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(expected); + using (Assert.Multiple()) + { + _ = await Assert.That(mutations).Count().IsEqualTo(1); + _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("boolean-literal.true-to-false"); + _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(expected); + } } [Test] @@ -252,9 +267,12 @@ public async Task CreateMutations_DetachedLiteralWithoutParent_IsMutated() var mutations = mutator.CreateMutations(literal, semanticModel, CancellationToken.None).ToArray(); - _ = await Assert.That(literal.Parent).IsNull(); - _ = await Assert.That(mutations.Length).IsEqualTo(1); - _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("boolean-literal.true-to-false"); + using (Assert.Multiple()) + { + _ = await Assert.That(literal.Parent).IsNull(); + _ = await Assert.That(mutations.Length).IsEqualTo(1); + _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("boolean-literal.true-to-false"); + } } private static (SyntaxTree Tree, Mutation[] Mutations) Run(string source) => Run(source, FindBooleanLiteral); diff --git a/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/CaseConversionMutatorTests.cs b/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/CaseConversionMutatorTests.cs index acca42f..d3494bf 100644 --- a/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/CaseConversionMutatorTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/CaseConversionMutatorTests.cs @@ -262,8 +262,11 @@ public async Task SupportedSyntaxKinds_Always_IsTheInvocationKind() [Test] public async Task Metadata_Always_IdentifiesTheCaseConversionFamily() { - _ = await Assert.That(_mutator.Id).IsEqualTo("culture.case-conversion"); - _ = await Assert.That(_mutator.Kind).IsEqualTo(MutationKind.CaseConversion); + using (Assert.Multiple()) + { + _ = await Assert.That(_mutator.Id).IsEqualTo("culture.case-conversion"); + _ = await Assert.That(_mutator.Kind).IsEqualTo(MutationKind.CaseConversion); + } } /// @@ -319,12 +322,15 @@ string secondId string[] expectedIds = [firstId, secondId]; var (mutations, node, _, _, errors) = MutateCall(CreateSource(source), source); - _ = await Assert.That(errors).IsEqualTo(string.Empty); - _ = await Assert.That(Join(DisplayNames(mutations))).IsEqualTo(Join(expectedNames)); - _ = await Assert.That(Join(OperatorIds(mutations))).IsEqualTo(Join(expectedIds)); - _ = await Assert.That(Join(Kinds(mutations))).IsEqualTo("CaseConversion, CaseConversion"); - _ = await Assert.That(mutations[0].Original.ToString()).IsEqualTo($"value.{source}()"); - _ = await Assert.That(mutations[0].Location.SourceSpan).IsEqualTo(node.Span); + using (Assert.Multiple()) + { + _ = await Assert.That(errors).IsEqualTo(string.Empty); + _ = await Assert.That(Join(DisplayNames(mutations))).IsEqualTo(Join(expectedNames)); + _ = await Assert.That(Join(OperatorIds(mutations))).IsEqualTo(Join(expectedIds)); + _ = await Assert.That(Join(Kinds(mutations))).IsEqualTo("CaseConversion, CaseConversion"); + _ = await Assert.That(mutations[0].Original.ToString()).IsEqualTo($"value.{source}()"); + _ = await Assert.That(mutations[0].Location.SourceSpan).IsEqualTo(node.Span); + } } /// @@ -353,9 +359,12 @@ public async Task ApplyTo_ParameterlessConversion_ProducesTheRenamedCall(string var mutated = Pick(mutations, source, target).ApplyTo(tree).ToString(); var compilation = CompilationFactory.Create(mutated); - _ = await Assert.That(errors).IsEqualTo(string.Empty); - _ = await Assert.That(mutated).IsEqualTo(CreateSource(target)); - _ = await Assert.That(Describe(CompilationFactory.GetCompileErrors(compilation))).IsEqualTo(string.Empty); + using (Assert.Multiple()) + { + _ = await Assert.That(errors).IsEqualTo(string.Empty); + _ = await Assert.That(mutated).IsEqualTo(CreateSource(target)); + _ = await Assert.That(Describe(CompilationFactory.GetCompileErrors(compilation))).IsEqualTo(string.Empty); + } } [Test] @@ -365,8 +374,11 @@ public async Task ApplyTo_UpperToUpperInvariant_KeepsTheSurroundingTrivia() var (mutations, _, tree, _, errors) = MutateCall(TriviaSource, "ToUpper"); var mutated = Pick(mutations, "ToUpper", "ToUpperInvariant").ApplyTo(tree).ToString(); - _ = await Assert.That(errors).IsEqualTo(string.Empty); - _ = await Assert.That(mutated).IsEqualTo(expected); + using (Assert.Multiple()) + { + _ = await Assert.That(errors).IsEqualTo(string.Empty); + _ = await Assert.That(mutated).IsEqualTo(expected); + } } /// @@ -380,10 +392,13 @@ public async Task CreateMutations_ConversionWithACulture_ProducesBothCounterpart var (mutations, node, _, model, errors) = MutateCall(CultureArgumentSource, "ToUpper"); var method = model.GetSymbolInfo(node).Symbol as IMethodSymbol; - _ = await Assert.That(errors).IsEqualTo(string.Empty); - _ = await Assert.That(method?.Parameters.Length).IsEqualTo(1); - _ = await Assert.That(method?.Parameters[0].Type.Name).IsEqualTo("CultureInfo"); - _ = await Assert.That(Join(DisplayNames(mutations))).IsEqualTo(Join(expected)); + using (Assert.Multiple()) + { + _ = await Assert.That(errors).IsEqualTo(string.Empty); + _ = await Assert.That(method?.Parameters.Length).IsEqualTo(1); + _ = await Assert.That(method?.Parameters[0].Type.Name).IsEqualTo("CultureInfo"); + _ = await Assert.That(Join(DisplayNames(mutations))).IsEqualTo(Join(expected)); + } } [Test] @@ -398,9 +413,12 @@ public async Task ApplyTo_ConversionWithACulture_DropsTheArgumentForTheInvariant var mutated = Pick(mutations, "ToUpper", "ToUpperInvariant").ApplyTo(tree).ToString(); var compilation = CompilationFactory.Create(mutated); - _ = await Assert.That(errors).IsEqualTo(string.Empty); - _ = await Assert.That(mutated).IsEqualTo(expected); - _ = await Assert.That(Describe(CompilationFactory.GetCompileErrors(compilation))).IsEqualTo(string.Empty); + using (Assert.Multiple()) + { + _ = await Assert.That(errors).IsEqualTo(string.Empty); + _ = await Assert.That(mutated).IsEqualTo(expected); + _ = await Assert.That(Describe(CompilationFactory.GetCompileErrors(compilation))).IsEqualTo(string.Empty); + } } [Test] @@ -415,9 +433,12 @@ public async Task ApplyTo_ConversionWithACulture_KeepsTheArgumentForTheCultureAw var mutated = Pick(mutations, "ToUpper", "ToLower").ApplyTo(tree).ToString(); var compilation = CompilationFactory.Create(mutated); - _ = await Assert.That(errors).IsEqualTo(string.Empty); - _ = await Assert.That(mutated).IsEqualTo(expected); - _ = await Assert.That(Describe(CompilationFactory.GetCompileErrors(compilation))).IsEqualTo(string.Empty); + using (Assert.Multiple()) + { + _ = await Assert.That(errors).IsEqualTo(string.Empty); + _ = await Assert.That(mutated).IsEqualTo(expected); + _ = await Assert.That(Describe(CompilationFactory.GetCompileErrors(compilation))).IsEqualTo(string.Empty); + } } [Test] @@ -428,10 +449,13 @@ public async Task ApplyTo_ConversionInsideAChain_RewritesOnlyTheConversion() var (mutations, node, tree, _, errors) = MutateCall(ChainedSource, "ToUpper"); var mutated = Pick(mutations, "ToUpper", "ToLower").ApplyTo(tree).ToString(); - _ = await Assert.That(errors).IsEqualTo(string.Empty); - _ = await Assert.That(node.ToString()).IsEqualTo("value.Trim().ToUpper()"); - _ = await Assert.That(Join(DisplayNames(mutations))).IsEqualTo(Join(expected)); - _ = await Assert.That(mutated).IsEqualTo(expectedSource); + using (Assert.Multiple()) + { + _ = await Assert.That(errors).IsEqualTo(string.Empty); + _ = await Assert.That(node.ToString()).IsEqualTo("value.Trim().ToUpper()"); + _ = await Assert.That(Join(DisplayNames(mutations))).IsEqualTo(Join(expected)); + _ = await Assert.That(mutated).IsEqualTo(expectedSource); + } } [Test] @@ -443,10 +467,13 @@ public async Task ApplyTo_ConversionInsideAnInterpolation_RewritesTheCall() var mutated = Pick(mutations, "ToUpper", "ToUpperInvariant").ApplyTo(tree).ToString(); var compilation = CompilationFactory.Create(mutated); - _ = await Assert.That(errors).IsEqualTo(string.Empty); - _ = await Assert.That(Join(DisplayNames(mutations))).IsEqualTo(Join(expected)); - _ = await Assert.That(mutated).IsEqualTo(expectedSource); - _ = await Assert.That(Describe(CompilationFactory.GetCompileErrors(compilation))).IsEqualTo(string.Empty); + using (Assert.Multiple()) + { + _ = await Assert.That(errors).IsEqualTo(string.Empty); + _ = await Assert.That(Join(DisplayNames(mutations))).IsEqualTo(Join(expected)); + _ = await Assert.That(mutated).IsEqualTo(expectedSource); + _ = await Assert.That(Describe(CompilationFactory.GetCompileErrors(compilation))).IsEqualTo(string.Empty); + } } /// @@ -463,10 +490,13 @@ public async Task CreateMutations_NullConditionalConversion_ReturnsEmpty() var invocation = (InvocationExpressionSyntax)node; var method = model.GetSymbolInfo(invocation).Symbol as IMethodSymbol; - _ = await Assert.That(errors).IsEqualTo(string.Empty); - _ = await Assert.That(invocation.Expression.Kind()).IsEqualTo(SyntaxKind.MemberBindingExpression); - _ = await Assert.That(method?.ContainingType.SpecialType).IsEqualTo(SpecialType.System_String); - _ = await Assert.That(mutations.ToArray()).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(errors).IsEqualTo(string.Empty); + _ = await Assert.That(invocation.Expression.Kind()).IsEqualTo(SyntaxKind.MemberBindingExpression); + _ = await Assert.That(method?.ContainingType.SpecialType).IsEqualTo(SpecialType.System_String); + _ = await Assert.That(mutations.ToArray()).IsEmpty(); + } } /// @@ -478,12 +508,15 @@ public async Task CreateMutations_ConversionUsedAsAMethodGroup_ReturnsEmpty() { var (mutations, node, _, _, errors) = Mutate(MethodGroupSource, SyntaxNodeLocator.FindMarked); - _ = await Assert.That(errors).IsEqualTo(string.Empty); - _ = await Assert.That(node.Kind()).IsEqualTo(SyntaxKind.SimpleMemberAccessExpression); - _ = await Assert - .That(_mutator.SupportedSyntaxKinds.Contains(SyntaxKind.SimpleMemberAccessExpression)) - .IsFalse(); - _ = await Assert.That(mutations.ToArray()).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(errors).IsEqualTo(string.Empty); + _ = await Assert.That(node.Kind()).IsEqualTo(SyntaxKind.SimpleMemberAccessExpression); + _ = await Assert + .That(_mutator.SupportedSyntaxKinds.Contains(SyntaxKind.SimpleMemberAccessExpression)) + .IsFalse(); + _ = await Assert.That(mutations.ToArray()).IsEmpty(); + } } /// @@ -496,11 +529,14 @@ public async Task CreateMutations_ExtensionMethodNamedLikeAConversion_ReturnsEmp var (mutations, node, _, model, errors) = MutateCall(ExtensionMethodSource, "ToUpper"); var method = model.GetSymbolInfo(node).Symbol as IMethodSymbol; - _ = await Assert.That(errors).IsEqualTo(string.Empty); - _ = await Assert.That(method?.IsExtensionMethod).IsTrue(); - _ = await Assert.That(method?.ContainingType.Name).IsEqualTo("CaseExtensions"); - _ = await Assert.That(method?.ContainingType.SpecialType).IsEqualTo(SpecialType.None); - _ = await Assert.That(mutations.ToArray()).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(errors).IsEqualTo(string.Empty); + _ = await Assert.That(method?.IsExtensionMethod).IsTrue(); + _ = await Assert.That(method?.ContainingType.Name).IsEqualTo("CaseExtensions"); + _ = await Assert.That(method?.ContainingType.SpecialType).IsEqualTo(SpecialType.None); + _ = await Assert.That(mutations.ToArray()).IsEmpty(); + } } /// @@ -522,10 +558,13 @@ public async Task CreateMutations_ConversionOnAnotherType_ReturnsEmpty(string me var (mutations, node, _, model, errors) = MutateCall(source, methodName); var method = model.GetSymbolInfo(node).Symbol as IMethodSymbol; - _ = await Assert.That(errors).IsEqualTo(string.Empty); - _ = await Assert.That(method?.Name).IsEqualTo(methodName); - _ = await Assert.That(method?.ContainingType.Name).IsEqualTo("Label"); - _ = await Assert.That(mutations.ToArray()).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(errors).IsEqualTo(string.Empty); + _ = await Assert.That(method?.Name).IsEqualTo(methodName); + _ = await Assert.That(method?.ContainingType.Name).IsEqualTo("Label"); + _ = await Assert.That(mutations.ToArray()).IsEmpty(); + } } /// @@ -545,9 +584,12 @@ public async Task CreateMutations_ConversionOfAnotherBclType_ReturnsEmpty(string var (mutations, node, _, model, errors) = MutateCall(source, "ToUpper"); var method = model.GetSymbolInfo(node).Symbol as IMethodSymbol; - _ = await Assert.That(errors).IsEqualTo(string.Empty); - _ = await Assert.That(method?.ContainingType.Name).IsEqualTo(expectedTypeName); - _ = await Assert.That(mutations.ToArray()).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(errors).IsEqualTo(string.Empty); + _ = await Assert.That(method?.ContainingType.Name).IsEqualTo(expectedTypeName); + _ = await Assert.That(mutations.ToArray()).IsEmpty(); + } } /// @@ -571,9 +613,12 @@ public async Task CreateMutations_ConversionInAConstantContext_ReturnsEmpty(stri var (mutations, node, _, model, _) = MutateCall(source, "ToUpper"); var method = model.GetSymbolInfo(node).Symbol as IMethodSymbol; - _ = await Assert.That(method?.Name).IsEqualTo("ToUpper"); - _ = await Assert.That(method?.ContainingType.SpecialType).IsEqualTo(SpecialType.System_String); - _ = await Assert.That(mutations.ToArray()).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(method?.Name).IsEqualTo("ToUpper"); + _ = await Assert.That(method?.ContainingType.SpecialType).IsEqualTo(SpecialType.System_String); + _ = await Assert.That(mutations.ToArray()).IsEmpty(); + } } /// @@ -586,9 +631,12 @@ public async Task CreateMutations_PointerMemberAccess_ReturnsEmpty() var (mutations, node, _, _, _) = MutateMarked(PointerAccessSource); var invocation = (InvocationExpressionSyntax)node; - _ = await Assert.That(invocation.Expression is MemberAccessExpressionSyntax).IsTrue(); - _ = await Assert.That(invocation.Expression.Kind()).IsEqualTo(SyntaxKind.PointerMemberAccessExpression); - _ = await Assert.That(mutations.ToArray()).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(invocation.Expression is MemberAccessExpressionSyntax).IsTrue(); + _ = await Assert.That(invocation.Expression.Kind()).IsEqualTo(SyntaxKind.PointerMemberAccessExpression); + _ = await Assert.That(mutations.ToArray()).IsEmpty(); + } } /// @@ -601,9 +649,12 @@ public async Task CreateMutations_UnresolvableConversion_ReturnsEmpty() var (mutations, node, _, model, _) = MutateMarked(UnresolvedOverloadSource); var info = model.GetSymbolInfo(node); - _ = await Assert.That(info.Symbol).IsNull(); - _ = await Assert.That(info.CandidateReason).IsEqualTo(CandidateReason.OverloadResolutionFailure); - _ = await Assert.That(mutations.ToArray()).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(info.Symbol).IsNull(); + _ = await Assert.That(info.CandidateReason).IsEqualTo(CandidateReason.OverloadResolutionFailure); + _ = await Assert.That(mutations.ToArray()).IsEmpty(); + } } /// @@ -616,9 +667,12 @@ public async Task CreateMutations_DelegateInvocation_ReturnsEmpty() var (mutations, node, _, model, errors) = MutateMarked(DelegateInvokeSource); var method = model.GetSymbolInfo(node).Symbol as IMethodSymbol; - _ = await Assert.That(errors).IsEqualTo(string.Empty); - _ = await Assert.That(method?.MethodKind).IsEqualTo(MethodKind.DelegateInvoke); - _ = await Assert.That(mutations.ToArray()).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(errors).IsEqualTo(string.Empty); + _ = await Assert.That(method?.MethodKind).IsEqualTo(MethodKind.DelegateInvoke); + _ = await Assert.That(mutations.ToArray()).IsEmpty(); + } } /// @@ -631,10 +685,13 @@ public async Task CreateMutations_OtherInstanceMethodOfString_ReturnsEmpty() var (mutations, node, _, model, errors) = MutateMarked(OtherStringMethodSource); var method = model.GetSymbolInfo(node).Symbol as IMethodSymbol; - _ = await Assert.That(errors).IsEqualTo(string.Empty); - _ = await Assert.That(method?.Name).IsEqualTo("Trim"); - _ = await Assert.That(method?.ContainingType.SpecialType).IsEqualTo(SpecialType.System_String); - _ = await Assert.That(mutations.ToArray()).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(errors).IsEqualTo(string.Empty); + _ = await Assert.That(method?.Name).IsEqualTo("Trim"); + _ = await Assert.That(method?.ContainingType.SpecialType).IsEqualTo(SpecialType.System_String); + _ = await Assert.That(mutations.ToArray()).IsEmpty(); + } } /// @@ -661,10 +718,13 @@ int expectedParameterCount var (mutations, node, _, model, errors) = MutateMarked(source); var method = model.GetSymbolInfo(node).Symbol as IMethodSymbol; - _ = await Assert.That(errors).IsEqualTo(string.Empty); - _ = await Assert.That(method?.Name).IsEqualTo(expectedName); - _ = await Assert.That(method?.Parameters.Length).IsEqualTo(expectedParameterCount); - _ = await Assert.That(mutations.ToArray()).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(errors).IsEqualTo(string.Empty); + _ = await Assert.That(method?.Name).IsEqualTo(expectedName); + _ = await Assert.That(method?.Parameters.Length).IsEqualTo(expectedParameterCount); + _ = await Assert.That(mutations.ToArray()).IsEmpty(); + } } /// @@ -689,9 +749,12 @@ public async Task CreateMutations_ConversionInANonConstantInitializer_ProducesBo ]; var (mutations, _, _, _, errors) = MutateMarked(source); - _ = await Assert.That(errors).IsEqualTo(string.Empty); - _ = await Assert.That(Join(DisplayNames(mutations))).IsEqualTo(Join(expected)); - _ = await Assert.That(Join(OperatorIds(mutations))).IsEqualTo(Join(expectedIds)); + using (Assert.Multiple()) + { + _ = await Assert.That(errors).IsEqualTo(string.Empty); + _ = await Assert.That(Join(DisplayNames(mutations))).IsEqualTo(Join(expected)); + _ = await Assert.That(Join(OperatorIds(mutations))).IsEqualTo(Join(expectedIds)); + } } private static string CreateSource(string methodName) => diff --git a/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/ConditionalExpressionMutatorTests.cs b/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/ConditionalExpressionMutatorTests.cs index c1de90d..2b216e5 100644 --- a/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/ConditionalExpressionMutatorTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/ConditionalExpressionMutatorTests.cs @@ -309,10 +309,13 @@ public async Task Metadata_Operator_DescribesConditionalExpressionFamily() var mutator = new ConditionalExpressionMutator(); SyntaxKind[] supported = [.. mutator.SupportedSyntaxKinds]; - _ = await Assert.That(mutator.Id).IsEqualTo("conditional-expression"); - _ = await Assert.That(mutator.Kind).IsEqualTo(MutationKind.ConditionalExpression); - _ = await Assert.That(supported).Count().IsEqualTo(1); - _ = await Assert.That(supported).Contains(SyntaxKind.ConditionalExpression); + using (Assert.Multiple()) + { + _ = await Assert.That(mutator.Id).IsEqualTo("conditional-expression"); + _ = await Assert.That(mutator.Kind).IsEqualTo(MutationKind.ConditionalExpression); + _ = await Assert.That(supported).Count().IsEqualTo(1); + _ = await Assert.That(supported).Contains(SyntaxKind.ConditionalExpression); + } } [Test] @@ -320,12 +323,15 @@ public async Task CreateMutations_Ternary_SwapsBranchesAndNegatesTheCondition() { var (_, mutations) = Run(TernarySource); - _ = await Assert.That(mutations).Count().IsEqualTo(2); - _ = await Assert.That(mutations[0].Kind).IsEqualTo(MutationKind.ConditionalExpression); - _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("conditional-expression.swap-branches"); - _ = await Assert.That(mutations[0].DisplayName).IsEqualTo("c ? a : b => c ? b : a"); - _ = await Assert.That(mutations[1].OperatorId).IsEqualTo("conditional-expression.negate-condition"); - _ = await Assert.That(mutations[1].DisplayName).IsEqualTo("c ? a : b => !c ? a : b"); + using (Assert.Multiple()) + { + _ = await Assert.That(mutations).Count().IsEqualTo(2); + _ = await Assert.That(mutations[0].Kind).IsEqualTo(MutationKind.ConditionalExpression); + _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("conditional-expression.swap-branches"); + _ = await Assert.That(mutations[0].DisplayName).IsEqualTo("c ? a : b => c ? b : a"); + _ = await Assert.That(mutations[1].OperatorId).IsEqualTo("conditional-expression.negate-condition"); + _ = await Assert.That(mutations[1].DisplayName).IsEqualTo("c ? a : b => !c ? a : b"); + } } [Test] @@ -351,9 +357,12 @@ public async Task CreateMutations_NegatedCondition_RemovesTheNegation() { var (tree, mutations) = Run(NegatedSource); - _ = await Assert.That(mutations).Count().IsEqualTo(2); - _ = await Assert.That(mutations[1].OperatorId).IsEqualTo("conditional-expression.negate-condition"); - _ = await Assert.That(Rewrite(tree, mutations[1])).IsEqualTo(TernarySource); + using (Assert.Multiple()) + { + _ = await Assert.That(mutations).Count().IsEqualTo(2); + _ = await Assert.That(mutations[1].OperatorId).IsEqualTo("conditional-expression.negate-condition"); + _ = await Assert.That(Rewrite(tree, mutations[1])).IsEqualTo(TernarySource); + } } [Test] @@ -364,8 +373,11 @@ public async Task CreateMutations_ComparisonCondition_ParenthesizesTheNegatedCon var negation = (PrefixUnaryExpressionSyntax)negated.Condition; var parenthesized = (ParenthesizedExpressionSyntax)negation.Operand; - _ = await Assert.That(negation.IsKind(SyntaxKind.LogicalNotExpression)).IsTrue(); - _ = await Assert.That(parenthesized.Expression.ToString().Trim()).IsEqualTo("a == b"); + using (Assert.Multiple()) + { + _ = await Assert.That(negation.IsKind(SyntaxKind.LogicalNotExpression)).IsTrue(); + _ = await Assert.That(parenthesized.Expression.ToString().Trim()).IsEqualTo("a == b"); + } } [Test] @@ -400,8 +412,11 @@ public async Task CreateMutations_MutatedNode_IsTheWholeConditionalExpression() var (tree, mutations) = Run(TernarySource); var conditional = FindConditional(tree); - _ = await Assert.That(mutations[0].Original.ToString()).IsEqualTo("flag ? 1 : 2"); - _ = await Assert.That(mutations[0].Location.SourceSpan).IsEqualTo(conditional.Span); + using (Assert.Multiple()) + { + _ = await Assert.That(mutations[0].Original.ToString()).IsEqualTo("flag ? 1 : 2"); + _ = await Assert.That(mutations[0].Location.SourceSpan).IsEqualTo(conditional.Span); + } } /// @@ -430,9 +445,12 @@ public async Task CreateMutations_ConditionNeedingNoParentheses_NegatesItInPlace var (_, mutations) = Run(source); - _ = await Assert.That(mutations).Count().IsEqualTo(2); - _ = await Assert.That(mutations[1].OperatorId).IsEqualTo("conditional-expression.negate-condition"); - _ = await Assert.That(NegatedCondition(mutations[1])).IsEqualTo(expected); + using (Assert.Multiple()) + { + _ = await Assert.That(mutations).Count().IsEqualTo(2); + _ = await Assert.That(mutations[1].OperatorId).IsEqualTo("conditional-expression.negate-condition"); + _ = await Assert.That(NegatedCondition(mutations[1])).IsEqualTo(expected); + } } [Test] @@ -445,8 +463,11 @@ public async Task CreateMutations_ConditionNeedingParentheses_WrapsItBeforeNegat var (_, mutations) = Run(source); - _ = await Assert.That(mutations).Count().IsEqualTo(2); - _ = await Assert.That(NegatedCondition(mutations[1])).IsEqualTo(expected); + using (Assert.Multiple()) + { + _ = await Assert.That(mutations).Count().IsEqualTo(2); + _ = await Assert.That(NegatedCondition(mutations[1])).IsEqualTo(expected); + } } [Test] @@ -455,8 +476,11 @@ public async Task CreateMutations_NegatedComparison_UnwrapsTheNegationAndKeepsTh var (tree, mutations) = Run(NegatedComparisonSource); var expected = Expected(NegatedComparisonSource, "!(a == b)", "(a == b)"); - _ = await Assert.That(NegatedCondition(mutations[1])).IsEqualTo("(a == b)"); - _ = await Assert.That(Rewrite(tree, mutations[1])).IsEqualTo(expected); + using (Assert.Multiple()) + { + _ = await Assert.That(NegatedCondition(mutations[1])).IsEqualTo("(a == b)"); + _ = await Assert.That(Rewrite(tree, mutations[1])).IsEqualTo(expected); + } } [Test] @@ -472,10 +496,13 @@ public async Task CreateMutations_ConditionalInAnyExpressionContext_SwapsTheBran var expected = Expected(source, "flag ? 1 : 2", "flag ? 2 : 1"); var mutated = Rewrite(tree, mutations[0]); - _ = await Assert.That(CompileErrors(source)).IsEqualTo(string.Empty); - _ = await Assert.That(mutations).Count().IsEqualTo(2); - _ = await Assert.That(mutated).IsEqualTo(expected); - _ = await Assert.That(CompileErrors(mutated)).IsEqualTo(string.Empty); + using (Assert.Multiple()) + { + _ = await Assert.That(CompileErrors(source)).IsEqualTo(string.Empty); + _ = await Assert.That(mutations).Count().IsEqualTo(2); + _ = await Assert.That(mutated).IsEqualTo(expected); + _ = await Assert.That(CompileErrors(mutated)).IsEqualTo(string.Empty); + } } [Test] @@ -485,9 +512,12 @@ public async Task CreateMutations_BranchesSharingACommonBase_SwapsThemAndStaysCo var expected = Expected(CommonBaseSource, "flag ? dog : animal", "flag ? animal : dog"); var mutated = Rewrite(tree, mutations[0]); - _ = await Assert.That(mutations).Count().IsEqualTo(2); - _ = await Assert.That(mutated).IsEqualTo(expected); - _ = await Assert.That(CompileErrors(mutated)).IsEqualTo(string.Empty); + using (Assert.Multiple()) + { + _ = await Assert.That(mutations).Count().IsEqualTo(2); + _ = await Assert.That(mutated).IsEqualTo(expected); + _ = await Assert.That(CompileErrors(mutated)).IsEqualTo(string.Empty); + } } [Test] @@ -501,10 +531,13 @@ public async Task CreateMutations_BranchesWithoutACommonType_SwapsTheTargetTyped var expected = Expected(NoCommonTypeSource, "flag ? 1 : \"one\"", "flag ? \"one\" : 1"); var mutated = Rewrite(tree, mutations[0]); - _ = await Assert.That(typeInfo.Type).IsNull(); - _ = await Assert.That(typeInfo.ConvertedType?.ToDisplayString()).IsEqualTo("Money"); - _ = await Assert.That(mutated).IsEqualTo(expected); - _ = await Assert.That(CompileErrors(mutated)).IsEqualTo(string.Empty); + using (Assert.Multiple()) + { + _ = await Assert.That(typeInfo.Type).IsNull(); + _ = await Assert.That(typeInfo.ConvertedType?.ToDisplayString()).IsEqualTo("Money"); + _ = await Assert.That(mutated).IsEqualTo(expected); + _ = await Assert.That(CompileErrors(mutated)).IsEqualTo(string.Empty); + } } [Test] @@ -514,10 +547,13 @@ public async Task CreateMutations_RefConditional_SwapsTheRefBranches() var expected = Expected(RefConditionalSource, "ref flag ? ref a : ref b", "ref flag ? ref b : ref a"); var mutated = Rewrite(tree, mutations[0]); - _ = await Assert.That(CompileErrors(RefConditionalSource)).IsEqualTo(string.Empty); - _ = await Assert.That(mutations).Count().IsEqualTo(2); - _ = await Assert.That(mutated).IsEqualTo(expected); - _ = await Assert.That(CompileErrors(mutated)).IsEqualTo(string.Empty); + using (Assert.Multiple()) + { + _ = await Assert.That(CompileErrors(RefConditionalSource)).IsEqualTo(string.Empty); + _ = await Assert.That(mutations).Count().IsEqualTo(2); + _ = await Assert.That(mutated).IsEqualTo(expected); + _ = await Assert.That(CompileErrors(mutated)).IsEqualTo(string.Empty); + } } /// @@ -530,8 +566,11 @@ public async Task CreateMutations_ThrowBranches_SwapsTheThrowExpressions() { var (tree, mutations) = Run(ThrowBranchesSource); - _ = await Assert.That(mutations).Count().IsEqualTo(2); - _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(ThrowBranchesSwappedSource); + using (Assert.Multiple()) + { + _ = await Assert.That(mutations).Count().IsEqualTo(2); + _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(ThrowBranchesSwappedSource); + } } [Test] @@ -544,8 +583,13 @@ public async Task CreateMutations_BranchesDifferingOnlyInTrivia_ReturnsEmpty(str var (tree, mutations) = Run(source); var conditional = (ConditionalExpressionSyntax)FindConditional(tree); - _ = await Assert.That(conditional.WhenTrue.ToFullString()).IsNotEqualTo(conditional.WhenFalse.ToFullString()); - _ = await Assert.That(mutations).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert + .That(conditional.WhenTrue.ToFullString()) + .IsNotEqualTo(conditional.WhenFalse.ToFullString()); + _ = await Assert.That(mutations).IsEmpty(); + } } [Test] @@ -554,8 +598,11 @@ public async Task CreateMutations_ParenthesizedBranch_IsNotEquivalentToItsBareCo var (tree, mutations) = Run(ParenthesizedBranchSource); var expected = Expected(ParenthesizedBranchSource, "flag ? value : (value)", "flag ? (value) : value"); - _ = await Assert.That(mutations).Count().IsEqualTo(2); - _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(expected); + using (Assert.Multiple()) + { + _ = await Assert.That(mutations).Count().IsEqualTo(2); + _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(expected); + } } [Test] @@ -565,9 +612,12 @@ public async Task CreateMutations_NestedConditionalInTheCondition_MutatesTheOute var swapped = Expected(NestedConditionSource, "(a ? b : !b) ? 1 : 2", "(a ? b : !b) ? 2 : 1"); var negated = Expected(NestedConditionSource, "(a ? b : !b) ? 1 : 2", "!(a ? b : !b) ? 1 : 2"); - _ = await Assert.That(mutations[0].Original.ToString()).IsEqualTo("(a ? b : !b) ? 1 : 2"); - _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(swapped); - _ = await Assert.That(Rewrite(tree, mutations[1])).IsEqualTo(negated); + using (Assert.Multiple()) + { + _ = await Assert.That(mutations[0].Original.ToString()).IsEqualTo("(a ? b : !b) ? 1 : 2"); + _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(swapped); + _ = await Assert.That(Rewrite(tree, mutations[1])).IsEqualTo(negated); + } } [Test] @@ -576,9 +626,12 @@ public async Task CreateMutations_NestedConditionalInTheTrueBranch_SwapsTheWhole var (tree, mutations) = Run(NestedTrueBranchSource); var expected = Expected(NestedTrueBranchSource, "a ? (b ? 1 : 2) : 3", "a ? 3 : (b ? 1 : 2)"); - _ = await Assert.That(mutations[0].Original.ToString()).IsEqualTo("a ? (b ? 1 : 2) : 3"); - _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(expected); - _ = await Assert.That(CompileErrors(Rewrite(tree, mutations[0]))).IsEqualTo(string.Empty); + using (Assert.Multiple()) + { + _ = await Assert.That(mutations[0].Original.ToString()).IsEqualTo("a ? (b ? 1 : 2) : 3"); + _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(expected); + _ = await Assert.That(CompileErrors(Rewrite(tree, mutations[0]))).IsEqualTo(string.Empty); + } } [Test] @@ -587,9 +640,12 @@ public async Task CreateMutations_NestedConditionalInTheFalseBranch_SwapsTheWhol var (tree, mutations) = Run(NestedFalseBranchSource); var expected = Expected(NestedFalseBranchSource, "a ? 1 : b ? 2 : 3", "a ? b ? 2 : 3 : 1"); - _ = await Assert.That(mutations[0].Original.ToString()).IsEqualTo("a ? 1 : b ? 2 : 3"); - _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(expected); - _ = await Assert.That(CompileErrors(Rewrite(tree, mutations[0]))).IsEqualTo(string.Empty); + using (Assert.Multiple()) + { + _ = await Assert.That(mutations[0].Original.ToString()).IsEqualTo("a ? 1 : b ? 2 : 3"); + _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(expected); + _ = await Assert.That(CompileErrors(Rewrite(tree, mutations[0]))).IsEqualTo(string.Empty); + } } [Test] @@ -598,8 +654,11 @@ public async Task CreateMutations_MarkedInnerConditional_LeavesTheOuterCondition var (tree, mutations) = RunMarked(MarkedInnerConditionalSource); var expected = Expected(MarkedInnerConditionalSource, "/*!*/b ? 2 : 3", "/*!*/b ? 3 : 2"); - _ = await Assert.That(mutations[0].Original.ToString()).IsEqualTo("b ? 2 : 3"); - _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(expected); + using (Assert.Multiple()) + { + _ = await Assert.That(mutations[0].Original.ToString()).IsEqualTo("b ? 2 : 3"); + _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(expected); + } } [Test] @@ -617,8 +676,11 @@ public async Task CreateMutations_CommentedConditional_KeepsTheCommentsInPlaceWh var (tree, mutations) = Run(CommentedSource); var expected = Expected(CommentedSource, " flag", " !flag"); - _ = await Assert.That(Rewrite(tree, mutations[1])).IsEqualTo(expected); - _ = await Assert.That(CompileErrors(Rewrite(tree, mutations[1]))).IsEqualTo(string.Empty); + using (Assert.Multiple()) + { + _ = await Assert.That(Rewrite(tree, mutations[1])).IsEqualTo(expected); + _ = await Assert.That(CompileErrors(Rewrite(tree, mutations[1]))).IsEqualTo(string.Empty); + } } [Test] @@ -682,13 +744,16 @@ public async Task CreateMutations_MemberBindingCondition_NegatesItWithoutParenth Mutation[] mutations = [.. mutator.CreateMutations(conditional, semanticModel, CancellationToken.None)]; var swapped = (ConditionalExpressionSyntax)mutations[0].Replacement; - _ = await Assert.That(conditional.Condition.Kind()).IsEqualTo(SyntaxKind.MemberBindingExpression); - _ = await Assert.That(mutations.Length).IsEqualTo(2); - _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("conditional-expression.swap-branches"); - _ = await Assert.That(swapped.WhenTrue.ToString()).IsEqualTo("2"); - _ = await Assert.That(swapped.WhenFalse.ToString()).IsEqualTo("1"); - _ = await Assert.That(mutations[1].OperatorId).IsEqualTo("conditional-expression.negate-condition"); - _ = await Assert.That(NegatedCondition(mutations[1])).IsEqualTo("!.Flag"); + using (Assert.Multiple()) + { + _ = await Assert.That(conditional.Condition.Kind()).IsEqualTo(SyntaxKind.MemberBindingExpression); + _ = await Assert.That(mutations.Length).IsEqualTo(2); + _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("conditional-expression.swap-branches"); + _ = await Assert.That(swapped.WhenTrue.ToString()).IsEqualTo("2"); + _ = await Assert.That(swapped.WhenFalse.ToString()).IsEqualTo("1"); + _ = await Assert.That(mutations[1].OperatorId).IsEqualTo("conditional-expression.negate-condition"); + _ = await Assert.That(NegatedCondition(mutations[1])).IsEqualTo("!.Flag"); + } } private static LiteralExpressionSyntax NumericLiteral(int value) => diff --git a/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/CultureInfoMutatorTests.cs b/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/CultureInfoMutatorTests.cs index 3c83dc4..405f062 100644 --- a/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/CultureInfoMutatorTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/CultureInfoMutatorTests.cs @@ -359,9 +359,12 @@ public async Task Metadata_Operator_DescribesTheCultureFamily() var mutator = new CultureInfoMutator(); SyntaxKind[] supported = [.. mutator.SupportedSyntaxKinds]; - _ = await Assert.That(mutator.Id).IsEqualTo("culture.culture-info"); - _ = await Assert.That(mutator.Kind).IsEqualTo(MutationKind.CultureInfo); - _ = await Assert.That(supported).IsEquivalentTo(new[] { SyntaxKind.SimpleMemberAccessExpression }); + using (Assert.Multiple()) + { + _ = await Assert.That(mutator.Id).IsEqualTo("culture.culture-info"); + _ = await Assert.That(mutator.Kind).IsEqualTo(MutationKind.CultureInfo); + _ = await Assert.That(supported).IsEquivalentTo(new[] { SyntaxKind.SimpleMemberAccessExpression }); + } } /// @@ -374,10 +377,13 @@ public async Task CreateMutations_InvariantCulture_ProducesTheCurrentCultureSwap var expected = InvariantSource.Replace("InvariantCulture", "CurrentCulture", StringComparison.Ordinal); var (tree, mutations) = Run(InvariantSource); - _ = await Assert.That(Ids(mutations)).IsEqualTo("culture.culture-info.invariant-to-current"); - _ = await Assert.That(mutations[0].Kind).IsEqualTo(MutationKind.CultureInfo); - _ = await Assert.That(mutations[0].DisplayName).IsEqualTo("InvariantCulture => CurrentCulture"); - _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(expected); + using (Assert.Multiple()) + { + _ = await Assert.That(Ids(mutations)).IsEqualTo("culture.culture-info.invariant-to-current"); + _ = await Assert.That(mutations[0].Kind).IsEqualTo(MutationKind.CultureInfo); + _ = await Assert.That(mutations[0].DisplayName).IsEqualTo("InvariantCulture => CurrentCulture"); + _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(expected); + } } /// @@ -392,13 +398,16 @@ public async Task CreateMutations_CurrentCulture_ProducesTheInvariantAndTheResou var expectedUi = CurrentSource.Replace("CurrentCulture", "CurrentUICulture", StringComparison.Ordinal); var (tree, mutations) = Run(CurrentSource); - _ = await Assert - .That(Ids(mutations)) - .IsEqualTo("culture.culture-info.current-to-invariant, culture.culture-info.current-to-current-ui"); - _ = await Assert.That(mutations[0].DisplayName).IsEqualTo("CurrentCulture => InvariantCulture"); - _ = await Assert.That(mutations[1].DisplayName).IsEqualTo("CurrentCulture => CurrentUICulture"); - _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(expectedInvariant); - _ = await Assert.That(Rewrite(tree, mutations[1])).IsEqualTo(expectedUi); + using (Assert.Multiple()) + { + _ = await Assert + .That(Ids(mutations)) + .IsEqualTo("culture.culture-info.current-to-invariant, culture.culture-info.current-to-current-ui"); + _ = await Assert.That(mutations[0].DisplayName).IsEqualTo("CurrentCulture => InvariantCulture"); + _ = await Assert.That(mutations[1].DisplayName).IsEqualTo("CurrentCulture => CurrentUICulture"); + _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(expectedInvariant); + _ = await Assert.That(Rewrite(tree, mutations[1])).IsEqualTo(expectedUi); + } } /// @@ -412,9 +421,12 @@ public async Task CreateMutations_CurrentUiCulture_ProducesTheCurrentCultureSwap var expected = CurrentUiSource.Replace("CurrentUICulture", "CurrentCulture", StringComparison.Ordinal); var (tree, mutations) = Run(CurrentUiSource); - _ = await Assert.That(Ids(mutations)).IsEqualTo("culture.culture-info.current-ui-to-current"); - _ = await Assert.That(mutations[0].DisplayName).IsEqualTo("CurrentUICulture => CurrentCulture"); - _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(expected); + using (Assert.Multiple()) + { + _ = await Assert.That(Ids(mutations)).IsEqualTo("culture.culture-info.current-ui-to-current"); + _ = await Assert.That(mutations[0].DisplayName).IsEqualTo("CurrentUICulture => CurrentCulture"); + _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(expected); + } } [Test] @@ -423,9 +435,14 @@ public async Task CreateMutations_FullyQualifiedName_KeepsTheQualification() var expected = FullyQualifiedSource.Replace("InvariantCulture", "CurrentCulture", StringComparison.Ordinal); var (tree, mutations) = Run(FullyQualifiedSource); - _ = await Assert.That(Ids(mutations)).IsEqualTo("culture.culture-info.invariant-to-current"); - _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(expected); - _ = await Assert.That(Rewrite(tree, mutations[0])).Contains("System.Globalization.CultureInfo.CurrentCulture"); + using (Assert.Multiple()) + { + _ = await Assert.That(Ids(mutations)).IsEqualTo("culture.culture-info.invariant-to-current"); + _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(expected); + _ = await Assert + .That(Rewrite(tree, mutations[0])) + .Contains("System.Globalization.CultureInfo.CurrentCulture"); + } } [Test] @@ -434,8 +451,11 @@ public async Task CreateMutations_CommentAroundTheAccess_KeepsTheTrivia() var expected = CommentedSource.Replace("InvariantCulture", "CurrentCulture", StringComparison.Ordinal); var (tree, mutations) = Run(CommentedSource); - _ = await Assert.That(Ids(mutations)).IsEqualTo("culture.culture-info.invariant-to-current"); - _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(expected); + using (Assert.Multiple()) + { + _ = await Assert.That(Ids(mutations)).IsEqualTo("culture.culture-info.invariant-to-current"); + _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(expected); + } } /// @@ -447,9 +467,12 @@ public async Task CreateMutations_CommentInsideTheAccess_KeepsTheTrivia() var expected = TriviaInsideAccessSource.Replace("InvariantCulture", "CurrentCulture", StringComparison.Ordinal); var (tree, mutations) = Run(TriviaInsideAccessSource); - _ = await Assert.That(Ids(mutations)).IsEqualTo("culture.culture-info.invariant-to-current"); - _ = await Assert.That(Rewrite(tree, mutations[0])).Contains("CultureInfo. /* pinned */ CurrentCulture"); - _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(expected); + using (Assert.Multiple()) + { + _ = await Assert.That(Ids(mutations)).IsEqualTo("culture.culture-info.invariant-to-current"); + _ = await Assert.That(Rewrite(tree, mutations[0])).Contains("CultureInfo. /* pinned */ CurrentCulture"); + _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(expected); + } } [Test] @@ -458,8 +481,11 @@ public async Task CreateMutations_ParseArgument_IsMutated() var expected = ParseSource.Replace("InvariantCulture", "CurrentCulture", StringComparison.Ordinal); var (tree, mutations) = Run(ParseSource); - _ = await Assert.That(Ids(mutations)).IsEqualTo("culture.culture-info.invariant-to-current"); - _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(expected); + using (Assert.Multiple()) + { + _ = await Assert.That(Ids(mutations)).IsEqualTo("culture.culture-info.invariant-to-current"); + _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(expected); + } } [Test] @@ -468,8 +494,11 @@ public async Task CreateMutations_StringFormatArgument_IsMutated() var expected = StringFormatSource.Replace("InvariantCulture", "CurrentCulture", StringComparison.Ordinal); var (tree, mutations) = Run(StringFormatSource); - _ = await Assert.That(Ids(mutations)).IsEqualTo("culture.culture-info.invariant-to-current"); - _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(expected); + using (Assert.Multiple()) + { + _ = await Assert.That(Ids(mutations)).IsEqualTo("culture.culture-info.invariant-to-current"); + _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(expected); + } } [Test] @@ -478,8 +507,11 @@ public async Task CreateMutations_ConvertToStringArgument_IsMutated() var expected = ConvertSource.Replace("InvariantCulture", "CurrentCulture", StringComparison.Ordinal); var (tree, mutations) = Run(ConvertSource); - _ = await Assert.That(Ids(mutations)).IsEqualTo("culture.culture-info.invariant-to-current"); - _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(expected); + using (Assert.Multiple()) + { + _ = await Assert.That(Ids(mutations)).IsEqualTo("culture.culture-info.invariant-to-current"); + _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(expected); + } } [Test] @@ -488,8 +520,11 @@ public async Task CreateMutations_InsideLambda_IsMutated() var expected = LambdaSource.Replace("InvariantCulture", "CurrentCulture", StringComparison.Ordinal); var (tree, mutations) = Run(LambdaSource); - _ = await Assert.That(Ids(mutations)).IsEqualTo("culture.culture-info.invariant-to-current"); - _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(expected); + using (Assert.Multiple()) + { + _ = await Assert.That(Ids(mutations)).IsEqualTo("culture.culture-info.invariant-to-current"); + _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(expected); + } } [Test] @@ -498,8 +533,11 @@ public async Task CreateMutations_InsideLocalFunction_IsMutated() var expected = LocalFunctionSource.Replace("InvariantCulture", "CurrentCulture", StringComparison.Ordinal); var (tree, mutations) = Run(LocalFunctionSource); - _ = await Assert.That(Ids(mutations)).IsEqualTo("culture.culture-info.invariant-to-current"); - _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(expected); + using (Assert.Multiple()) + { + _ = await Assert.That(Ids(mutations)).IsEqualTo("culture.culture-info.invariant-to-current"); + _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(expected); + } } /// @@ -512,8 +550,11 @@ public async Task CreateMutations_AccessUsedAsReceiver_IsMutated() var expected = NestedAccessSource.Replace("InvariantCulture", "CurrentCulture", StringComparison.Ordinal); var (tree, mutations) = Run(NestedAccessSource); - _ = await Assert.That(Ids(mutations)).IsEqualTo("culture.culture-info.invariant-to-current"); - _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(expected); + using (Assert.Multiple()) + { + _ = await Assert.That(Ids(mutations)).IsEqualTo("culture.culture-info.invariant-to-current"); + _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(expected); + } } /// @@ -557,8 +598,11 @@ public async Task CreateMutations_CultureConstruction_ReturnsEmpty() var mutator = new CultureInfoMutator(); var (_, mutations) = Run(ObjectCreationSource, SyntaxNodeLocator.FindFirst); - _ = await Assert.That(mutator.SupportedSyntaxKinds.Contains(SyntaxKind.ObjectCreationExpression)).IsFalse(); - _ = await Assert.That(mutations).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(mutator.SupportedSyntaxKinds.Contains(SyntaxKind.ObjectCreationExpression)).IsFalse(); + _ = await Assert.That(mutations).IsEmpty(); + } } /// @@ -582,8 +626,11 @@ public async Task CreateMutations_AssignedCulture_IsMutated() var expected = AssignmentSourceSource.Replace("InvariantCulture", "CurrentCulture", StringComparison.Ordinal); var (tree, mutations) = Run(AssignmentSourceSource, SyntaxNodeLocator.FindMarked); - _ = await Assert.That(Ids(mutations)).IsEqualTo("culture.culture-info.invariant-to-current"); - _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(expected); + using (Assert.Multiple()) + { + _ = await Assert.That(Ids(mutations)).IsEqualTo("culture.culture-info.invariant-to-current"); + _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(expected); + } } /// @@ -648,9 +695,14 @@ public async Task CreateMutations_PositionRequiringAConstant_ReturnsEmpty(string var info = semanticModel.GetSymbolInfo(access); var symbol = info.Symbol ?? info.CandidateSymbols.FirstOrDefault(); - _ = await Assert.That(symbol?.Name).IsEqualTo("InvariantCulture"); - _ = await Assert.That(symbol?.ContainingType.ToDisplayString()).IsEqualTo("System.Globalization.CultureInfo"); - _ = await Assert.That(mutations).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(symbol?.Name).IsEqualTo("InvariantCulture"); + _ = await Assert + .That(symbol?.ContainingType.ToDisplayString()) + .IsEqualTo("System.Globalization.CultureInfo"); + _ = await Assert.That(mutations).IsEmpty(); + } } /// @@ -670,8 +722,11 @@ public async Task CreateMutations_CultureInANonConstantInitializer_ProducesTheCu var expected = source.Replace("InvariantCulture", "CurrentCulture", StringComparison.Ordinal); var (tree, mutations) = Run(source); - _ = await Assert.That(Ids(mutations)).IsEqualTo("culture.culture-info.invariant-to-current"); - _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(expected); + using (Assert.Multiple()) + { + _ = await Assert.That(Ids(mutations)).IsEqualTo("culture.culture-info.invariant-to-current"); + _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(expected); + } } [Test] diff --git a/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/EqualityOperatorMutatorTests.cs b/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/EqualityOperatorMutatorTests.cs index ce469e8..90ea05e 100644 --- a/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/EqualityOperatorMutatorTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/EqualityOperatorMutatorTests.cs @@ -304,8 +304,11 @@ public async Task SupportedSyntaxKinds_Always_AreTheTwoEqualityKinds() [Test] public async Task Metadata_Always_IdentifiesTheEqualityFamily() { - _ = await Assert.That(_mutator.Id).IsEqualTo("equality"); - _ = await Assert.That(_mutator.Kind).IsEqualTo(MutationKind.EqualityOperator); + using (Assert.Multiple()) + { + _ = await Assert.That(_mutator.Id).IsEqualTo("equality"); + _ = await Assert.That(_mutator.Kind).IsEqualTo(MutationKind.EqualityOperator); + } } [Test] @@ -320,10 +323,13 @@ string expectedId string[] expected = [expectedName]; var (mutations, _, _, errors) = Mutate(CreateSource(source)); - _ = await Assert.That(errors).IsEqualTo(string.Empty); - _ = await Assert.That(DisplayNames(mutations)).IsEquivalentTo(expected); - _ = await Assert.That(mutations.Single().OperatorId).IsEqualTo(expectedId); - _ = await Assert.That(mutations.Single().Kind).IsEqualTo(MutationKind.EqualityOperator); + using (Assert.Multiple()) + { + _ = await Assert.That(errors).IsEqualTo(string.Empty); + _ = await Assert.That(DisplayNames(mutations)).IsEquivalentTo(expected); + _ = await Assert.That(mutations.Single().OperatorId).IsEqualTo(expectedId); + _ = await Assert.That(mutations.Single().Kind).IsEqualTo(MutationKind.EqualityOperator); + } } [Test] @@ -334,9 +340,12 @@ public async Task CreateMutations_UserDefinedOperatorWithCounterpart_ProducesThe var binary = SyntaxNodeLocator.FindMarked(tree); var method = model.GetSymbolInfo(binary).Symbol as IMethodSymbol; - _ = await Assert.That(errors).IsEqualTo(string.Empty); - _ = await Assert.That(method?.MethodKind).IsEqualTo(MethodKind.UserDefinedOperator); - _ = await Assert.That(DisplayNames(mutations)).IsEquivalentTo(expected); + using (Assert.Multiple()) + { + _ = await Assert.That(errors).IsEqualTo(string.Empty); + _ = await Assert.That(method?.MethodKind).IsEqualTo(MethodKind.UserDefinedOperator); + _ = await Assert.That(DisplayNames(mutations)).IsEquivalentTo(expected); + } } /// @@ -352,10 +361,13 @@ public async Task CreateMutations_UserDefinedEqualsWithoutCounterpart_ReturnsEmp var binary = SyntaxNodeLocator.FindMarked(tree); var method = model.GetSymbolInfo(binary).Symbol as IMethodSymbol; - _ = await Assert.That(method?.Name).IsEqualTo("op_Equality"); - _ = await Assert.That(method?.ContainingType.Name).IsEqualTo("Money"); - _ = await Assert.That(CounterpartCount(method, "op_Inequality")).IsEqualTo(0); - _ = await Assert.That(mutations.ToArray()).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(method?.Name).IsEqualTo("op_Equality"); + _ = await Assert.That(method?.ContainingType.Name).IsEqualTo("Money"); + _ = await Assert.That(CounterpartCount(method, "op_Inequality")).IsEqualTo(0); + _ = await Assert.That(mutations.ToArray()).IsEmpty(); + } } /// @@ -369,10 +381,13 @@ public async Task CreateMutations_UserDefinedNotEqualsWithoutCounterpart_Returns var binary = SyntaxNodeLocator.FindMarked(tree); var method = model.GetSymbolInfo(binary).Symbol as IMethodSymbol; - _ = await Assert.That(method?.Name).IsEqualTo("op_Inequality"); - _ = await Assert.That(method?.ContainingType.Name).IsEqualTo("Money"); - _ = await Assert.That(CounterpartCount(method, "op_Equality")).IsEqualTo(0); - _ = await Assert.That(mutations.ToArray()).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(method?.Name).IsEqualTo("op_Inequality"); + _ = await Assert.That(method?.ContainingType.Name).IsEqualTo("Money"); + _ = await Assert.That(CounterpartCount(method, "op_Equality")).IsEqualTo(0); + _ = await Assert.That(mutations.ToArray()).IsEmpty(); + } } [Test] @@ -381,8 +396,11 @@ public async Task ApplyTo_EqualsToNotEquals_KeepsTheSurroundingTrivia() var expected = TriviaSource.Replace("== right", "!= right", StringComparison.Ordinal); var (mutations, tree, _, errors) = Mutate(TriviaSource); - _ = await Assert.That(errors).IsEqualTo(string.Empty); - _ = await Assert.That(mutations.Single().ApplyTo(tree).ToString()).IsEqualTo(expected); + using (Assert.Multiple()) + { + _ = await Assert.That(errors).IsEqualTo(string.Empty); + _ = await Assert.That(mutations.Single().ApplyTo(tree).ToString()).IsEqualTo(expected); + } } [Test] @@ -392,8 +410,11 @@ public async Task ApplyTo_EqualsToNotEquals_ProducesCompilableSource() var mutated = mutations.Single().ApplyTo(tree).ToString(); var compilation = CompilationFactory.Create(mutated); - _ = await Assert.That(mutated).Contains("left != right"); - _ = await Assert.That(Describe(CompilationFactory.GetCompileErrors(compilation))).IsEqualTo(string.Empty); + using (Assert.Multiple()) + { + _ = await Assert.That(mutated).Contains("left != right"); + _ = await Assert.That(Describe(CompilationFactory.GetCompileErrors(compilation))).IsEqualTo(string.Empty); + } } [Test] @@ -401,8 +422,11 @@ public async Task CreateMutations_RelationalExpression_ReturnsEmpty() { var (mutations, _, _, errors) = Mutate(RelationalSource); - _ = await Assert.That(errors).IsEqualTo(string.Empty); - _ = await Assert.That(mutations.ToArray()).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(errors).IsEqualTo(string.Empty); + _ = await Assert.That(mutations.ToArray()).IsEmpty(); + } } [Test] @@ -420,9 +444,12 @@ string expectedTypeName var binary = SyntaxNodeLocator.FindMarked(tree); var method = model.GetSymbolInfo(binary).Symbol as IMethodSymbol; - _ = await Assert.That(errors).IsEqualTo(string.Empty); - _ = await Assert.That(method?.ContainingType.Name).IsEqualTo(expectedTypeName); - _ = await Assert.That(DisplayNames(mutations)).IsEquivalentTo(expected); + using (Assert.Multiple()) + { + _ = await Assert.That(errors).IsEqualTo(string.Empty); + _ = await Assert.That(method?.ContainingType.Name).IsEqualTo(expectedTypeName); + _ = await Assert.That(DisplayNames(mutations)).IsEquivalentTo(expected); + } } /// @@ -436,9 +463,12 @@ public async Task CreateMutations_LiftedUserDefinedPair_ProducesTheCounterpart() var (mutations, tree, model, errors) = Mutate(LiftedPairSource); var binary = SyntaxNodeLocator.FindMarked(tree); - _ = await Assert.That(errors).IsEqualTo(string.Empty); - _ = await Assert.That(model.GetTypeInfo(binary.Left).Type?.ToDisplayString()).IsEqualTo("Money?"); - _ = await Assert.That(DisplayNames(mutations)).IsEquivalentTo(expected); + using (Assert.Multiple()) + { + _ = await Assert.That(errors).IsEqualTo(string.Empty); + _ = await Assert.That(model.GetTypeInfo(binary.Left).Type?.ToDisplayString()).IsEqualTo("Money?"); + _ = await Assert.That(DisplayNames(mutations)).IsEquivalentTo(expected); + } } /// @@ -454,9 +484,12 @@ public async Task CreateMutations_CounterpartDeclaredOnTheNullableOperandType_Pr var binary = SyntaxNodeLocator.FindMarked(tree); var method = model.GetSymbolInfo(binary).Symbol as IMethodSymbol; - _ = await Assert.That(method?.Name).IsEqualTo("op_Equality"); - _ = await Assert.That(CounterpartCount(method, "op_Inequality")).IsEqualTo(1); - _ = await Assert.That(DisplayNames(mutations)).IsEquivalentTo(expected); + using (Assert.Multiple()) + { + _ = await Assert.That(method?.Name).IsEqualTo("op_Equality"); + _ = await Assert.That(CounterpartCount(method, "op_Inequality")).IsEqualTo(1); + _ = await Assert.That(DisplayNames(mutations)).IsEquivalentTo(expected); + } } /// @@ -470,9 +503,12 @@ public async Task CreateMutations_CounterpartWithDifferentParameterTypes_Returns var binary = SyntaxNodeLocator.FindMarked(tree); var method = model.GetSymbolInfo(binary).Symbol as IMethodSymbol; - _ = await Assert.That(method?.Name).IsEqualTo("op_Equality"); - _ = await Assert.That(CounterpartCount(method, "op_Inequality")).IsEqualTo(1); - _ = await Assert.That(mutations.ToArray()).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(method?.Name).IsEqualTo("op_Equality"); + _ = await Assert.That(CounterpartCount(method, "op_Inequality")).IsEqualTo(1); + _ = await Assert.That(mutations.ToArray()).IsEmpty(); + } } /// @@ -487,10 +523,13 @@ public async Task CreateMutations_OperatorReachedThroughAnImplicitConversion_Pro var binary = SyntaxNodeLocator.FindMarked(tree); var method = model.GetSymbolInfo(binary).Symbol as IMethodSymbol; - _ = await Assert.That(errors).IsEqualTo(string.Empty); - _ = await Assert.That(method?.ContainingType.Name).IsEqualTo("Money"); - _ = await Assert.That(model.GetTypeInfo(binary.Right).Type?.Name).IsEqualTo("Cents"); - _ = await Assert.That(DisplayNames(mutations)).IsEquivalentTo(expected); + using (Assert.Multiple()) + { + _ = await Assert.That(errors).IsEqualTo(string.Empty); + _ = await Assert.That(method?.ContainingType.Name).IsEqualTo("Money"); + _ = await Assert.That(model.GetTypeInfo(binary.Right).Type?.Name).IsEqualTo("Cents"); + _ = await Assert.That(DisplayNames(mutations)).IsEquivalentTo(expected); + } } /// @@ -512,10 +551,13 @@ public async Task CreateMutations_ComparisonAgainstNull_ProducesTheCounterpart(s var binary = SyntaxNodeLocator.FindMarked(tree); var method = model.GetSymbolInfo(binary).Symbol as IMethodSymbol; - _ = await Assert.That(errors).IsEqualTo(string.Empty); - _ = await Assert.That(method?.MethodKind).IsNotEqualTo(MethodKind.UserDefinedOperator); - _ = await Assert.That(DisplayNames(mutations)).IsEquivalentTo(expected); - _ = await Assert.That(mutations.Single().OperatorId).IsEqualTo("equality.equals-to-not-equals"); + using (Assert.Multiple()) + { + _ = await Assert.That(errors).IsEqualTo(string.Empty); + _ = await Assert.That(method?.MethodKind).IsNotEqualTo(MethodKind.UserDefinedOperator); + _ = await Assert.That(DisplayNames(mutations)).IsEquivalentTo(expected); + _ = await Assert.That(mutations.Single().OperatorId).IsEqualTo("equality.equals-to-not-equals"); + } } /// @@ -531,9 +573,12 @@ public async Task CreateMutations_ComparisonBoundToTheBuiltInOperator_ProducesTh var binary = SyntaxNodeLocator.FindMarked(tree); var bound = model.GetSymbolInfo(binary).Symbol as IMethodSymbol; - _ = await Assert.That(bound?.MethodKind).IsEqualTo(MethodKind.BuiltinOperator); - _ = await Assert.That(bound?.ToDisplayString()).IsEqualTo("object.operator ==(object, object)"); - _ = await Assert.That(DisplayNames(mutations)).IsEquivalentTo(expected); + using (Assert.Multiple()) + { + _ = await Assert.That(bound?.MethodKind).IsEqualTo(MethodKind.BuiltinOperator); + _ = await Assert.That(bound?.ToDisplayString()).IsEqualTo("object.operator ==(object, object)"); + _ = await Assert.That(DisplayNames(mutations)).IsEquivalentTo(expected); + } } /// @@ -555,10 +600,13 @@ public async Task CreateMutations_MemberNamedLikeTheCounterpartIsNoOperator_Retu var binary = SyntaxNodeLocator.FindMarked(tree); var method = model.GetSymbolInfo(binary).Symbol as IMethodSymbol; - _ = await Assert.That(method?.Name).IsEqualTo("op_Equality"); - _ = await Assert.That(CounterpartCount(method, "op_Inequality")).IsEqualTo(1); - _ = await Assert.That(CounterpartOperatorCount(method, "op_Inequality")).IsEqualTo(0); - _ = await Assert.That(mutations.ToArray()).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(method?.Name).IsEqualTo("op_Equality"); + _ = await Assert.That(CounterpartCount(method, "op_Inequality")).IsEqualTo(1); + _ = await Assert.That(CounterpartOperatorCount(method, "op_Inequality")).IsEqualTo(0); + _ = await Assert.That(mutations.ToArray()).IsEmpty(); + } } /// @@ -573,12 +621,15 @@ public async Task CreateMutations_CounterpartWithADifferentParameterCount_Return var binary = SyntaxNodeLocator.FindMarked(tree); var method = model.GetSymbolInfo(binary).Symbol as IMethodSymbol; - _ = await Assert.That(method?.Parameters.Length).IsEqualTo(2); - _ = await Assert.That(CounterpartCount(method, "op_Inequality")).IsEqualTo(1); - _ = await Assert - .That(CounterpartParameterCounts(method, "op_Inequality")) - .IsEquivalentTo(expectedParameterCounts); - _ = await Assert.That(mutations.ToArray()).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(method?.Parameters.Length).IsEqualTo(2); + _ = await Assert.That(CounterpartCount(method, "op_Inequality")).IsEqualTo(1); + _ = await Assert + .That(CounterpartParameterCounts(method, "op_Inequality")) + .IsEquivalentTo(expectedParameterCounts); + _ = await Assert.That(mutations.ToArray()).IsEmpty(); + } } private static string CreateSource(string source) => diff --git a/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/FormatProviderArgumentMutatorTests.cs b/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/FormatProviderArgumentMutatorTests.cs index be5d28d..b4a98d8 100644 --- a/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/FormatProviderArgumentMutatorTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/FormatProviderArgumentMutatorTests.cs @@ -354,8 +354,11 @@ public async Task SupportedSyntaxKinds_Always_IsTheInvocationKind() [Test] public async Task Metadata_Always_IdentifiesTheFormatProviderFamily() { - _ = await Assert.That(_mutator.Id).IsEqualTo(OperatorId); - _ = await Assert.That(_mutator.Kind).IsEqualTo(MutationKind.FormatProvider); + using (Assert.Multiple()) + { + _ = await Assert.That(_mutator.Id).IsEqualTo(OperatorId); + _ = await Assert.That(_mutator.Kind).IsEqualTo(MutationKind.FormatProvider); + } } /// @@ -391,10 +394,13 @@ public async Task CreateMutations_ProviderArgument_RemovesIt(string expression, string[] expectedIds = [RemoveId]; var (mutations, _, tree, _, errors) = Mutate(CreateSource(expression)); - _ = await Assert.That(errors).IsEqualTo(string.Empty); - _ = await Assert.That(OperatorIds(mutations)).IsEquivalentTo(expectedIds); - _ = await Assert.That(mutations.Single().Kind).IsEqualTo(MutationKind.FormatProvider); - _ = await Assert.That(mutations.Single().ApplyTo(tree).ToString()).IsEqualTo(CreateSource(expected)); + using (Assert.Multiple()) + { + _ = await Assert.That(errors).IsEqualTo(string.Empty); + _ = await Assert.That(OperatorIds(mutations)).IsEquivalentTo(expectedIds); + _ = await Assert.That(mutations.Single().Kind).IsEqualTo(MutationKind.FormatProvider); + _ = await Assert.That(mutations.Single().ApplyTo(tree).ToString()).IsEqualTo(CreateSource(expected)); + } } [Test] @@ -405,12 +411,15 @@ public async Task CreateMutations_ProviderArgument_ReportsTheRemovedArgumentAsTh var invocation = SyntaxNodeLocator.FindMarked(tree); var mutation = mutations.Single(); - _ = await Assert.That(errors).IsEqualTo(string.Empty); - _ = await Assert.That(mutation.OperatorId).IsEqualTo(RemoveId); - _ = await Assert.That(mutation.DisplayName).IsEqualTo("CultureInfo.InvariantCulture => (removed)"); - _ = await Assert.That(mutation.Location.SourceSpan).IsEqualTo(invocation.ArgumentList.Arguments[0].Span); - _ = await Assert.That(mutation.Original.ToString()).IsEqualTo("(CultureInfo.InvariantCulture)"); - _ = await Assert.That(mutation.Replacement.ToString()).IsEqualTo("()"); + using (Assert.Multiple()) + { + _ = await Assert.That(errors).IsEqualTo(string.Empty); + _ = await Assert.That(mutation.OperatorId).IsEqualTo(RemoveId); + _ = await Assert.That(mutation.DisplayName).IsEqualTo("CultureInfo.InvariantCulture => (removed)"); + _ = await Assert.That(mutation.Location.SourceSpan).IsEqualTo(invocation.ArgumentList.Arguments[0].Span); + _ = await Assert.That(mutation.Original.ToString()).IsEqualTo("(CultureInfo.InvariantCulture)"); + _ = await Assert.That(mutation.Replacement.ToString()).IsEqualTo("()"); + } } [Test] @@ -420,8 +429,11 @@ public async Task ApplyTo_ProviderRemoved_ProducesCompilableSource() var mutated = mutations.Single().ApplyTo(tree).ToString(); var compilation = CompilationFactory.Create(mutated); - _ = await Assert.That(mutated).Contains("value.ToString()"); - _ = await Assert.That(Describe(CompilationFactory.GetCompileErrors(compilation))).IsEqualTo(string.Empty); + using (Assert.Multiple()) + { + _ = await Assert.That(mutated).Contains("value.ToString()"); + _ = await Assert.That(Describe(CompilationFactory.GetCompileErrors(compilation))).IsEqualTo(string.Empty); + } } /// @@ -439,10 +451,13 @@ public async Task CreateMutations_NamedProviderBehindAnOmittedOptionalParameter_ StringComparison.Ordinal ); - _ = await Assert.That(errors).IsEqualTo(string.Empty); - _ = await Assert.That(ParameterNames(tree, model)).IsEqualTo("value, format, provider"); - _ = await Assert.That(OperatorIds(mutations)).IsEquivalentTo(expectedIds); - _ = await Assert.That(mutations.Single().ApplyTo(tree).ToString()).IsEqualTo(expected); + using (Assert.Multiple()) + { + _ = await Assert.That(errors).IsEqualTo(string.Empty); + _ = await Assert.That(ParameterNames(tree, model)).IsEqualTo("value, format, provider"); + _ = await Assert.That(OperatorIds(mutations)).IsEquivalentTo(expectedIds); + _ = await Assert.That(mutations.Single().ApplyTo(tree).ToString()).IsEqualTo(expected); + } } /// @@ -460,11 +475,14 @@ public async Task CreateMutations_ReducedExtensionMethod_RemovesTheProvider() StringComparison.Ordinal ); - _ = await Assert.That(errors).IsEqualTo(string.Empty); - _ = await Assert.That(MethodKindOf(tree, model)).IsEqualTo(MethodKind.ReducedExtension); - _ = await Assert.That(ParameterNames(tree, model)).IsEqualTo("provider"); - _ = await Assert.That(OperatorIds(mutations)).IsEquivalentTo(expectedIds); - _ = await Assert.That(mutations.Single().ApplyTo(tree).ToString()).IsEqualTo(expected); + using (Assert.Multiple()) + { + _ = await Assert.That(errors).IsEqualTo(string.Empty); + _ = await Assert.That(MethodKindOf(tree, model)).IsEqualTo(MethodKind.ReducedExtension); + _ = await Assert.That(ParameterNames(tree, model)).IsEqualTo("provider"); + _ = await Assert.That(OperatorIds(mutations)).IsEquivalentTo(expectedIds); + _ = await Assert.That(mutations.Single().ApplyTo(tree).ToString()).IsEqualTo(expected); + } } /// @@ -482,10 +500,13 @@ public async Task CreateMutations_ParameterImplementsTheProviderInterface_Remove StringComparison.Ordinal ); - _ = await Assert.That(errors).IsEqualTo(string.Empty); - _ = await Assert.That(ParameterTypes(tree, model)).IsEqualTo("int, System.Globalization.CultureInfo"); - _ = await Assert.That(OperatorIds(mutations)).IsEquivalentTo(expectedIds); - _ = await Assert.That(mutations.Single().ApplyTo(tree).ToString()).IsEqualTo(expected); + using (Assert.Multiple()) + { + _ = await Assert.That(errors).IsEqualTo(string.Empty); + _ = await Assert.That(ParameterTypes(tree, model)).IsEqualTo("int, System.Globalization.CultureInfo"); + _ = await Assert.That(OperatorIds(mutations)).IsEquivalentTo(expectedIds); + _ = await Assert.That(mutations.Single().ApplyTo(tree).ToString()).IsEqualTo(expected); + } } /// @@ -498,9 +519,12 @@ public async Task CreateMutations_ForeignInterfaceOfTheSameName_ReturnsEmpty() { var (mutations, _, tree, model, errors) = Mutate(ForeignProviderSource); - _ = await Assert.That(errors).IsEqualTo(string.Empty); - _ = await Assert.That(ParameterTypes(tree, model)).IsEqualTo("int, Fake.IFormatProvider"); - _ = await Assert.That(mutations.ToArray()).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(errors).IsEqualTo(string.Empty); + _ = await Assert.That(ParameterTypes(tree, model)).IsEqualTo("int, Fake.IFormatProvider"); + _ = await Assert.That(mutations.ToArray()).IsEmpty(); + } } /// @@ -513,10 +537,13 @@ public async Task CreateMutations_ProviderInsideAParamsArray_ReturnsEmpty() var (mutations, _, tree, model, errors) = Mutate(ParamsSource); var method = ResolveMethod(tree, model); - _ = await Assert.That(errors).IsEqualTo(string.Empty); - _ = await Assert.That(method?.Parameters[0].IsParams).IsTrue(); - _ = await Assert.That(ParameterTypes(tree, model)).IsEqualTo("object[]"); - _ = await Assert.That(mutations.ToArray()).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(errors).IsEqualTo(string.Empty); + _ = await Assert.That(method?.Parameters[0].IsParams).IsTrue(); + _ = await Assert.That(ParameterTypes(tree, model)).IsEqualTo("object[]"); + _ = await Assert.That(mutations.ToArray()).IsEmpty(); + } } /// @@ -545,9 +572,12 @@ public async Task CreateMutations_OptionalProviderLeftOut_ReturnsEmpty() { var (mutations, _, tree, model, errors) = Mutate(OmittedProviderSource); - _ = await Assert.That(errors).IsEqualTo(string.Empty); - _ = await Assert.That(ParameterNames(tree, model)).IsEqualTo("value, format, provider"); - _ = await Assert.That(mutations.ToArray()).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(errors).IsEqualTo(string.Empty); + _ = await Assert.That(ParameterNames(tree, model)).IsEqualTo("value, format, provider"); + _ = await Assert.That(mutations.ToArray()).IsEmpty(); + } } /// @@ -559,8 +589,11 @@ public async Task CreateMutations_UnresolvableSymbol_ReturnsEmpty() { var (mutations, _, tree, model, _) = Mutate(UnresolvedSource); - _ = await Assert.That(ResolveMethod(tree, model)).IsNull(); - _ = await Assert.That(mutations.ToArray()).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(ResolveMethod(tree, model)).IsNull(); + _ = await Assert.That(mutations.ToArray()).IsEmpty(); + } } /// @@ -580,9 +613,12 @@ public async Task CreateMutations_ConstantContext_ReturnsEmpty(string source) var (mutations, _, tree, model, _) = Mutate(source); - _ = await Assert.That(ResolveMethod(tree, model)?.Name).IsEqualTo("Format"); - _ = await Assert.That(ParameterTypes(tree, model)).IsEqualTo("System.IFormatProvider, string, object"); - _ = await Assert.That(mutations.ToArray()).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(ResolveMethod(tree, model)?.Name).IsEqualTo("Format"); + _ = await Assert.That(ParameterTypes(tree, model)).IsEqualTo("System.IFormatProvider, string, object"); + _ = await Assert.That(mutations.ToArray()).IsEmpty(); + } } /// @@ -607,9 +643,12 @@ public async Task CreateMutations_ProviderInANonConstantInitializer_RemovesIt(st ); var (mutations, _, tree, _, errors) = Mutate(source); - _ = await Assert.That(errors).IsEqualTo(string.Empty); - _ = await Assert.That(OperatorIds(mutations)).IsEquivalentTo(expectedIds); - _ = await Assert.That(mutations.Single().ApplyTo(tree).ToString()).IsEqualTo(expected); + using (Assert.Multiple()) + { + _ = await Assert.That(errors).IsEqualTo(string.Empty); + _ = await Assert.That(OperatorIds(mutations)).IsEquivalentTo(expectedIds); + _ = await Assert.That(mutations.Single().ApplyTo(tree).ToString()).IsEqualTo(expected); + } } [Test] @@ -617,8 +656,11 @@ public async Task ApplyTo_ProviderRemoved_KeepsTheTriviaOfTheRemainingArguments( { var (mutations, _, tree, _, errors) = Mutate(TriviaSource); - _ = await Assert.That(errors).IsEqualTo(string.Empty); - _ = await Assert.That(mutations.Single().ApplyTo(tree).ToString()).IsEqualTo(TriviaExpected); + using (Assert.Multiple()) + { + _ = await Assert.That(errors).IsEqualTo(string.Empty); + _ = await Assert.That(mutations.Single().ApplyTo(tree).ToString()).IsEqualTo(TriviaExpected); + } } /// @@ -634,10 +676,13 @@ public async Task CreateMutations_WithoutAProviderLessOverload_IsOfferedAndDisca var mutation = mutations.Single(); var viability = new MutantCompiler(compilation).Verify(mutation, tree, CancellationToken.None); - _ = await Assert.That(errors).IsEqualTo(string.Empty); - _ = await Assert.That(OperatorIds(mutations)).IsEquivalentTo(expectedIds); - _ = await Assert.That(mutation.ApplyTo(tree).ToString()).Contains("Render(value)"); - _ = await Assert.That(viability).IsEqualTo(MutantViability.DoesNotCompile); + using (Assert.Multiple()) + { + _ = await Assert.That(errors).IsEqualTo(string.Empty); + _ = await Assert.That(OperatorIds(mutations)).IsEquivalentTo(expectedIds); + _ = await Assert.That(mutation.ApplyTo(tree).ToString()).Contains("Render(value)"); + _ = await Assert.That(viability).IsEqualTo(MutantViability.DoesNotCompile); + } } private static string CreateSource(string expression) => diff --git a/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/IncrementDecrementMutatorTests.cs b/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/IncrementDecrementMutatorTests.cs index f8a5c7b..af58f81 100644 --- a/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/IncrementDecrementMutatorTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/IncrementDecrementMutatorTests.cs @@ -271,19 +271,22 @@ public async Task Metadata_Operator_ExposesIdKindAndSupportedKinds() { var mutator = new IncrementDecrementMutator(); - _ = await Assert.That(mutator.Id).IsEqualTo("increment-decrement"); - _ = await Assert.That(mutator.Kind).IsEqualTo(MutationKind.Increment); - _ = await Assert - .That(mutator.SupportedSyntaxKinds) - .IsEquivalentTo( - new[] - { - SyntaxKind.PreIncrementExpression, - SyntaxKind.PreDecrementExpression, - SyntaxKind.PostIncrementExpression, - SyntaxKind.PostDecrementExpression, - } - ); + using (Assert.Multiple()) + { + _ = await Assert.That(mutator.Id).IsEqualTo("increment-decrement"); + _ = await Assert.That(mutator.Kind).IsEqualTo(MutationKind.Increment); + _ = await Assert + .That(mutator.SupportedSyntaxKinds) + .IsEquivalentTo( + new[] + { + SyntaxKind.PreIncrementExpression, + SyntaxKind.PreDecrementExpression, + SyntaxKind.PostIncrementExpression, + SyntaxKind.PostDecrementExpression, + } + ); + } } [Test] @@ -308,14 +311,17 @@ string expectedReplacement { var result = Mutate(Fixture(expression)); - _ = await Assert - .That(Sorted(result.Mutations.Select(mutation => mutation.OperatorId))) - .IsEquivalentTo(new[] { expectedId }); - _ = await Assert - .That(Sorted(result.Mutations.Select(mutation => mutation.DisplayName))) - .IsEquivalentTo(new[] { expectedDisplayName }); - _ = await Assert.That(result.Mutations[0].Replacement.ToString()).IsEqualTo(expectedReplacement); - _ = await Assert.That(result.Mutations[0].Original).IsEqualTo(result.Node); + using (Assert.Multiple()) + { + _ = await Assert + .That(Sorted(result.Mutations.Select(mutation => mutation.OperatorId))) + .IsEquivalentTo(new[] { expectedId }); + _ = await Assert + .That(Sorted(result.Mutations.Select(mutation => mutation.DisplayName))) + .IsEquivalentTo(new[] { expectedDisplayName }); + _ = await Assert.That(result.Mutations[0].Replacement.ToString()).IsEqualTo(expectedReplacement); + _ = await Assert.That(result.Mutations[0].Original).IsEqualTo(result.Node); + } } [Test] @@ -340,9 +346,12 @@ public async Task SupportedSyntaxKinds_EveryKind_IsHandledByCreateMutations(stri var mutator = new IncrementDecrementMutator(); var result = Mutate(Fixture(expression)); - _ = await Assert.That(result.Node.Kind()).IsEqualTo(kind); - _ = await Assert.That(mutator.SupportedSyntaxKinds).Contains(kind); - _ = await Assert.That(result.Mutations).Count().IsEqualTo(1); + using (Assert.Multiple()) + { + _ = await Assert.That(result.Node.Kind()).IsEqualTo(kind); + _ = await Assert.That(mutator.SupportedSyntaxKinds).Contains(kind); + _ = await Assert.That(result.Mutations).Count().IsEqualTo(1); + } } [Test] @@ -365,12 +374,15 @@ public async Task ApplyTo_PostfixIncrementToDecrement_RewritesOperatorAndKeepsTr var mutated = mutation.ApplyTo(result.Tree).ToString(); - _ = await Assert - .That(mutated) - .IsEqualTo(TriviaSource.Replace("++ /* after */", "-- /* after */", StringComparison.Ordinal)); - _ = await Assert.That(mutated).Contains("// Advances a value."); - _ = await Assert.That(mutated).Contains("/* leading */"); - _ = await Assert.That(mutated).Contains("value /* inner */ -- /* after */; // tail"); + using (Assert.Multiple()) + { + _ = await Assert + .That(mutated) + .IsEqualTo(TriviaSource.Replace("++ /* after */", "-- /* after */", StringComparison.Ordinal)); + _ = await Assert.That(mutated).Contains("// Advances a value."); + _ = await Assert.That(mutated).Contains("/* leading */"); + _ = await Assert.That(mutated).Contains("value /* inner */ -- /* after */; // tail"); + } } [Test] @@ -378,8 +390,11 @@ public async Task CreateMutations_UserDefinedIncrementWithoutDecrement_ReturnsEm { var result = Mutate(IncrementOnlyOperatorSource); - _ = await Assert.That(result.Node.Kind()).IsEqualTo(SyntaxKind.PostIncrementExpression); - _ = await Assert.That(result.Mutations).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(result.Node.Kind()).IsEqualTo(SyntaxKind.PostIncrementExpression); + _ = await Assert.That(result.Mutations).IsEmpty(); + } } [Test] @@ -387,8 +402,11 @@ public async Task CreateMutations_UserDefinedDecrementWithoutIncrement_ReturnsEm { var result = Mutate(DecrementOnlyOperatorSource); - _ = await Assert.That(result.Node.Kind()).IsEqualTo(SyntaxKind.PostDecrementExpression); - _ = await Assert.That(result.Mutations).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(result.Node.Kind()).IsEqualTo(SyntaxKind.PostDecrementExpression); + _ = await Assert.That(result.Mutations).IsEmpty(); + } } [Test] @@ -397,10 +415,13 @@ public async Task CreateMutations_UserDefinedIncrementAndDecrement_ProducesTheSw string[] expectedIds = ["increment-decrement.postfix-increment-to-decrement"]; var result = Mutate(BothOperatorsSource); - _ = await Assert - .That(Sorted(result.Mutations.Select(mutation => mutation.OperatorId))) - .IsEquivalentTo(expectedIds); - _ = await Assert.That(result.Mutations[0].Replacement.ToString()).IsEqualTo("current--"); + using (Assert.Multiple()) + { + _ = await Assert + .That(Sorted(result.Mutations.Select(mutation => mutation.OperatorId))) + .IsEquivalentTo(expectedIds); + _ = await Assert.That(result.Mutations[0].Replacement.ToString()).IsEqualTo("current--"); + } } [Test] @@ -409,10 +430,13 @@ public async Task CreateMutations_UserDefinedOperatorsOnAGenericType_ProducesThe string[] expectedIds = ["increment-decrement.prefix-increment-to-decrement"]; var result = Mutate(GenericBothOperatorsSource); - _ = await Assert - .That(Sorted(result.Mutations.Select(mutation => mutation.OperatorId))) - .IsEquivalentTo(expectedIds); - _ = await Assert.That(result.Mutations[0].Replacement.ToString()).IsEqualTo("--current"); + using (Assert.Multiple()) + { + _ = await Assert + .That(Sorted(result.Mutations.Select(mutation => mutation.OperatorId))) + .IsEquivalentTo(expectedIds); + _ = await Assert.That(result.Mutations[0].Replacement.ToString()).IsEqualTo("--current"); + } } [Test] @@ -420,8 +444,11 @@ public async Task CreateMutations_UserDefinedIncrementOnAGenericTypeWithoutDecre { var result = Mutate(GenericIncrementOnlySource); - _ = await Assert.That(result.Node.Kind()).IsEqualTo(SyntaxKind.PreIncrementExpression); - _ = await Assert.That(result.Mutations).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(result.Node.Kind()).IsEqualTo(SyntaxKind.PreIncrementExpression); + _ = await Assert.That(result.Mutations).IsEmpty(); + } } /// @@ -444,8 +471,11 @@ public async Task CreateMutations_LiftedUserDefinedIncrementWithoutDecrement_Ret { var result = Mutate(NullableLiftedIncrementOnlySource); - _ = await Assert.That(result.Node.Kind()).IsEqualTo(SyntaxKind.PostIncrementExpression); - _ = await Assert.That(result.Mutations).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(result.Node.Kind()).IsEqualTo(SyntaxKind.PostIncrementExpression); + _ = await Assert.That(result.Mutations).IsEmpty(); + } } /// @@ -468,11 +498,14 @@ string expectedReplacement { var result = Mutate(CreateSource(MemberTemplate, expression, ExpressionPlaceholder)); - _ = await Assert - .That(Sorted(result.Mutations.Select(mutation => mutation.OperatorId))) - .IsEquivalentTo(new[] { expectedId }); - _ = await Assert.That(result.Mutations[0].Replacement.ToString()).IsEqualTo(expectedReplacement); - _ = await Assert.That(result.Mutations[0].Original).IsEqualTo(result.Node); + using (Assert.Multiple()) + { + _ = await Assert + .That(Sorted(result.Mutations.Select(mutation => mutation.OperatorId))) + .IsEquivalentTo(new[] { expectedId }); + _ = await Assert.That(result.Mutations[0].Replacement.ToString()).IsEqualTo(expectedReplacement); + _ = await Assert.That(result.Mutations[0].Original).IsEqualTo(result.Node); + } } /// @@ -487,11 +520,14 @@ public async Task CreateMutations_CheckedOrUncheckedContext_SwapsTheOperator(str string[] expectedIds = ["increment-decrement.postfix-increment-to-decrement"]; var result = Mutate(CreateSource(CheckedTemplate, keyword, KeywordPlaceholder)); - _ = await Assert.That(result.Node.Kind()).IsEqualTo(SyntaxKind.PostIncrementExpression); - _ = await Assert - .That(Sorted(result.Mutations.Select(mutation => mutation.OperatorId))) - .IsEquivalentTo(expectedIds); - _ = await Assert.That(result.Mutations[0].Replacement.ToString()).IsEqualTo("value--"); + using (Assert.Multiple()) + { + _ = await Assert.That(result.Node.Kind()).IsEqualTo(SyntaxKind.PostIncrementExpression); + _ = await Assert + .That(Sorted(result.Mutations.Select(mutation => mutation.OperatorId))) + .IsEquivalentTo(expectedIds); + _ = await Assert.That(result.Mutations[0].Replacement.ToString()).IsEqualTo("value--"); + } } /// @@ -503,8 +539,11 @@ public async Task CreateMutations_MemberWithTheCounterpartNameThatIsNoOperator_R { var result = Mutate(BorrowedOperatorNameSource); - _ = await Assert.That(result.Node.Kind()).IsEqualTo(SyntaxKind.PostIncrementExpression); - _ = await Assert.That(result.Mutations).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(result.Node.Kind()).IsEqualTo(SyntaxKind.PostIncrementExpression); + _ = await Assert.That(result.Mutations).IsEmpty(); + } } [Test] diff --git a/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/LogicalNegationMutatorTests.cs b/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/LogicalNegationMutatorTests.cs index e3f6db6..725dcb0 100644 --- a/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/LogicalNegationMutatorTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/LogicalNegationMutatorTests.cs @@ -215,8 +215,11 @@ public async Task SupportedSyntaxKinds_Always_AreTheNegationAndConditionKinds() [Test] public async Task Metadata_Always_IdentifiesTheNegationFamily() { - _ = await Assert.That(_mutator.Id).IsEqualTo("negation"); - _ = await Assert.That(_mutator.Kind).IsEqualTo(MutationKind.LogicalNegation); + using (Assert.Multiple()) + { + _ = await Assert.That(_mutator.Id).IsEqualTo("negation"); + _ = await Assert.That(_mutator.Kind).IsEqualTo(MutationKind.LogicalNegation); + } } [Test] @@ -230,11 +233,14 @@ public async Task CreateMutations_LogicalNotExpression_UnwrapsTheOperand(string var (mutations, tree, _, errors) = Mutate(source); var mutation = mutations.Single(); - _ = await Assert.That(errors).IsEqualTo(string.Empty); - _ = await Assert.That(DisplayNames(mutations)).IsEquivalentTo(expected); - _ = await Assert.That(mutation.OperatorId).IsEqualTo("negation.remove-negation"); - _ = await Assert.That(mutation.Kind).IsEqualTo(MutationKind.LogicalNegation); - _ = await Assert.That(mutation.ApplyTo(tree).ToString()).IsEqualTo(Unnegated(source)); + using (Assert.Multiple()) + { + _ = await Assert.That(errors).IsEqualTo(string.Empty); + _ = await Assert.That(DisplayNames(mutations)).IsEquivalentTo(expected); + _ = await Assert.That(mutation.OperatorId).IsEqualTo("negation.remove-negation"); + _ = await Assert.That(mutation.Kind).IsEqualTo(MutationKind.LogicalNegation); + _ = await Assert.That(mutation.ApplyTo(tree).ToString()).IsEqualTo(Unnegated(source)); + } } [Test] @@ -244,9 +250,12 @@ public async Task CreateMutations_NonBooleanOperand_ReturnsEmpty() var negation = SyntaxNodeLocator.FindMarked(tree); var operandType = model.GetTypeInfo(negation.Operand).Type; - _ = await Assert.That(errors).IsEqualTo(string.Empty); - _ = await Assert.That(operandType?.ToDisplayString()).IsEqualTo("Flag"); - _ = await Assert.That(mutations.ToArray()).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(errors).IsEqualTo(string.Empty); + _ = await Assert.That(operandType?.ToDisplayString()).IsEqualTo("Flag"); + _ = await Assert.That(mutations.ToArray()).IsEmpty(); + } } [Test] @@ -254,8 +263,11 @@ public async Task CreateMutations_UnaryMinusExpression_ReturnsEmpty() { var (mutations, _, _, errors) = Mutate(UnaryMinusSource); - _ = await Assert.That(errors).IsEqualTo(string.Empty); - _ = await Assert.That(mutations.ToArray()).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(errors).IsEqualTo(string.Empty); + _ = await Assert.That(mutations.ToArray()).IsEmpty(); + } } [Test] @@ -265,11 +277,14 @@ public async Task CreateMutations_IfStatement_WrapsTheConditionIntoParentheses() var (mutations, tree, _, errors) = Mutate(IfSource); var mutation = mutations.Single(); - _ = await Assert.That(errors).IsEqualTo(string.Empty); - _ = await Assert.That(mutation.DisplayName).IsEqualTo("x => !(x)"); - _ = await Assert.That(mutation.OperatorId).IsEqualTo("negation.negate-condition"); - _ = await Assert.That(mutation.Original.ToString()).IsEqualTo("value > 0"); - _ = await Assert.That(mutation.ApplyTo(tree).ToString()).IsEqualTo(expected); + using (Assert.Multiple()) + { + _ = await Assert.That(errors).IsEqualTo(string.Empty); + _ = await Assert.That(mutation.DisplayName).IsEqualTo("x => !(x)"); + _ = await Assert.That(mutation.OperatorId).IsEqualTo("negation.negate-condition"); + _ = await Assert.That(mutation.Original.ToString()).IsEqualTo("value > 0"); + _ = await Assert.That(mutation.ApplyTo(tree).ToString()).IsEqualTo(expected); + } } [Test] @@ -279,10 +294,13 @@ public async Task CreateMutations_WhileStatement_WrapsTheConditionIntoParenthese var (mutations, tree, _, errors) = Mutate(WhileSource); var mutation = mutations.Single(); - _ = await Assert.That(errors).IsEqualTo(string.Empty); - _ = await Assert.That(mutation.DisplayName).IsEqualTo("x => !(x)"); - _ = await Assert.That(mutation.Original.ToString()).IsEqualTo("flag"); - _ = await Assert.That(mutation.ApplyTo(tree).ToString()).IsEqualTo(expected); + using (Assert.Multiple()) + { + _ = await Assert.That(errors).IsEqualTo(string.Empty); + _ = await Assert.That(mutation.DisplayName).IsEqualTo("x => !(x)"); + _ = await Assert.That(mutation.Original.ToString()).IsEqualTo("flag"); + _ = await Assert.That(mutation.ApplyTo(tree).ToString()).IsEqualTo(expected); + } } [Test] @@ -292,10 +310,13 @@ public async Task CreateMutations_DoStatement_WrapsTheConditionIntoParentheses() var (mutations, tree, _, errors) = Mutate(DoSource); var mutation = mutations.Single(); - _ = await Assert.That(errors).IsEqualTo(string.Empty); - _ = await Assert.That(mutation.DisplayName).IsEqualTo("x => !(x)"); - _ = await Assert.That(mutation.Original.ToString()).IsEqualTo("flag"); - _ = await Assert.That(mutation.ApplyTo(tree).ToString()).IsEqualTo(expected); + using (Assert.Multiple()) + { + _ = await Assert.That(errors).IsEqualTo(string.Empty); + _ = await Assert.That(mutation.DisplayName).IsEqualTo("x => !(x)"); + _ = await Assert.That(mutation.Original.ToString()).IsEqualTo("flag"); + _ = await Assert.That(mutation.ApplyTo(tree).ToString()).IsEqualTo(expected); + } } [Test] @@ -305,10 +326,13 @@ public async Task CreateMutations_ConditionalExpression_WrapsTheConditionIntoPar var (mutations, tree, _, errors) = Mutate(ConditionalSource); var mutation = mutations.Single(); - _ = await Assert.That(errors).IsEqualTo(string.Empty); - _ = await Assert.That(mutation.DisplayName).IsEqualTo("x => !(x)"); - _ = await Assert.That(mutation.Original.ToString()).IsEqualTo("flag"); - _ = await Assert.That(mutation.ApplyTo(tree).ToString()).IsEqualTo(expected); + using (Assert.Multiple()) + { + _ = await Assert.That(errors).IsEqualTo(string.Empty); + _ = await Assert.That(mutation.DisplayName).IsEqualTo("x => !(x)"); + _ = await Assert.That(mutation.Original.ToString()).IsEqualTo("flag"); + _ = await Assert.That(mutation.ApplyTo(tree).ToString()).IsEqualTo(expected); + } } [Test] @@ -317,9 +341,12 @@ public async Task CreateMutations_AlreadyNegatedCondition_ReturnsEmpty() var (mutations, tree, _, errors) = Mutate(NegatedIfSource); var ifStatement = SyntaxNodeLocator.FindMarked(tree); - _ = await Assert.That(errors).IsEqualTo(string.Empty); - _ = await Assert.That(ifStatement.Condition.ToString()).IsEqualTo("!flag"); - _ = await Assert.That(mutations.ToArray()).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(errors).IsEqualTo(string.Empty); + _ = await Assert.That(ifStatement.Condition.ToString()).IsEqualTo("!flag"); + _ = await Assert.That(mutations.ToArray()).IsEmpty(); + } } /// @@ -334,8 +361,11 @@ public async Task CreateMutations_NullableBooleanCondition_ReturnsEmpty() var conditional = SyntaxNodeLocator.FindMarked(tree); var conditionType = model.GetTypeInfo(conditional.Condition).Type; - _ = await Assert.That(conditionType?.ToDisplayString()).IsEqualTo("bool?"); - _ = await Assert.That(mutations.ToArray()).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(conditionType?.ToDisplayString()).IsEqualTo("bool?"); + _ = await Assert.That(mutations.ToArray()).IsEmpty(); + } } [Test] @@ -345,8 +375,11 @@ public async Task ApplyTo_NegatedCondition_ProducesCompilableSource() var mutated = mutations.Single().ApplyTo(tree).ToString(); var compilation = CompilationFactory.Create(mutated); - _ = await Assert.That(mutated).Contains("if (!(value > 0))"); - _ = await Assert.That(Describe(CompilationFactory.GetCompileErrors(compilation))).IsEqualTo(string.Empty); + using (Assert.Multiple()) + { + _ = await Assert.That(mutated).Contains("if (!(value > 0))"); + _ = await Assert.That(Describe(CompilationFactory.GetCompileErrors(compilation))).IsEqualTo(string.Empty); + } } [Test] @@ -356,8 +389,11 @@ public async Task ApplyTo_RemovedNegation_ProducesCompilableSource() var mutated = mutations.Single().ApplyTo(tree).ToString(); var compilation = CompilationFactory.Create(mutated); - _ = await Assert.That(mutated).Contains("Negate(bool value) => /*!*/value;"); - _ = await Assert.That(Describe(CompilationFactory.GetCompileErrors(compilation))).IsEqualTo(string.Empty); + using (Assert.Multiple()) + { + _ = await Assert.That(mutated).Contains("Negate(bool value) => /*!*/value;"); + _ = await Assert.That(Describe(CompilationFactory.GetCompileErrors(compilation))).IsEqualTo(string.Empty); + } } /// @@ -371,9 +407,12 @@ public async Task CreateMutations_TypelessOperand_ReturnsEmpty() var (mutations, tree, model, _) = Mutate(MethodGroupOperandSource); var negation = SyntaxNodeLocator.FindMarked(tree); - _ = await Assert.That(negation.Kind()).IsEqualTo(SyntaxKind.LogicalNotExpression); - _ = await Assert.That(model.GetTypeInfo(negation.Operand).Type).IsNull(); - _ = await Assert.That(mutations.ToArray()).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(negation.Kind()).IsEqualTo(SyntaxKind.LogicalNotExpression); + _ = await Assert.That(model.GetTypeInfo(negation.Operand).Type).IsNull(); + _ = await Assert.That(mutations.ToArray()).IsEmpty(); + } } /// @@ -387,9 +426,12 @@ public async Task CreateMutations_ConditionWithTrueAndFalseOperators_ReturnsEmpt var (mutations, tree, model, errors) = Mutate(TrueFalseOperatorConditionSource); var ifStatement = SyntaxNodeLocator.FindMarked(tree); - _ = await Assert.That(errors).IsEqualTo(string.Empty); - _ = await Assert.That(model.GetTypeInfo(ifStatement.Condition).Type?.ToDisplayString()).IsEqualTo("Flag"); - _ = await Assert.That(mutations.ToArray()).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(errors).IsEqualTo(string.Empty); + _ = await Assert.That(model.GetTypeInfo(ifStatement.Condition).Type?.ToDisplayString()).IsEqualTo("Flag"); + _ = await Assert.That(mutations.ToArray()).IsEmpty(); + } } /// @@ -405,8 +447,11 @@ public async Task CreateMutations_AlreadyNegatedConditionOfEveryNode_ReturnsEmpt var (mutations, _, _, errors) = Mutate(source); - _ = await Assert.That(errors).IsEqualTo(string.Empty); - _ = await Assert.That(mutations.ToArray()).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(errors).IsEqualTo(string.Empty); + _ = await Assert.That(mutations.ToArray()).IsEmpty(); + } } /// @@ -420,9 +465,12 @@ public async Task CreateMutations_TypelessCondition_ReturnsEmpty() var (mutations, tree, model, _) = Mutate(MethodGroupConditionSource); var ifStatement = SyntaxNodeLocator.FindMarked(tree); - _ = await Assert.That(ifStatement.Condition.ToString()).IsEqualTo("Flag"); - _ = await Assert.That(model.GetTypeInfo(ifStatement.Condition).Type).IsNull(); - _ = await Assert.That(mutations.ToArray()).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(ifStatement.Condition.ToString()).IsEqualTo("Flag"); + _ = await Assert.That(model.GetTypeInfo(ifStatement.Condition).Type).IsNull(); + _ = await Assert.That(mutations.ToArray()).IsEmpty(); + } } [Test] diff --git a/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/LogicalOperatorMutatorTests.cs b/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/LogicalOperatorMutatorTests.cs index c0325c9..75cc77f 100644 --- a/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/LogicalOperatorMutatorTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/LogicalOperatorMutatorTests.cs @@ -106,8 +106,11 @@ public async Task SupportedSyntaxKinds_Always_AreTheConditionalAndBooleanKinds() [Test] public async Task Metadata_Always_IdentifiesTheLogicalFamily() { - _ = await Assert.That(_mutator.Id).IsEqualTo("logical"); - _ = await Assert.That(_mutator.Kind).IsEqualTo(MutationKind.LogicalOperator); + using (Assert.Multiple()) + { + _ = await Assert.That(_mutator.Id).IsEqualTo("logical"); + _ = await Assert.That(_mutator.Kind).IsEqualTo(MutationKind.LogicalOperator); + } } [Test] @@ -124,10 +127,13 @@ string expectedId string[] expected = [expectedName]; var (mutations, _, _, errors) = Mutate(CreateSource(BooleanTemplate, source)); - _ = await Assert.That(errors).IsEqualTo(string.Empty); - _ = await Assert.That(DisplayNames(mutations)).IsEquivalentTo(expected); - _ = await Assert.That(mutations.Single().OperatorId).IsEqualTo(expectedId); - _ = await Assert.That(mutations.Single().Kind).IsEqualTo(MutationKind.LogicalOperator); + using (Assert.Multiple()) + { + _ = await Assert.That(errors).IsEqualTo(string.Empty); + _ = await Assert.That(DisplayNames(mutations)).IsEquivalentTo(expected); + _ = await Assert.That(mutations.Single().OperatorId).IsEqualTo(expectedId); + _ = await Assert.That(mutations.Single().Kind).IsEqualTo(MutationKind.LogicalOperator); + } } [Test] @@ -141,8 +147,11 @@ string expectedName string[] expected = [expectedName]; var (mutations, _, _, errors) = Mutate(CreateSource(NullableBooleanTemplate, source)); - _ = await Assert.That(errors).IsEqualTo(string.Empty); - _ = await Assert.That(DisplayNames(mutations)).IsEquivalentTo(expected); + using (Assert.Multiple()) + { + _ = await Assert.That(errors).IsEqualTo(string.Empty); + _ = await Assert.That(DisplayNames(mutations)).IsEquivalentTo(expected); + } } [Test] @@ -154,9 +163,12 @@ public async Task CreateMutations_IntegralOperands_ReturnsEmptyBecauseTheBitwise var binary = SyntaxNodeLocator.FindMarked(tree); var leftType = model.GetTypeInfo(binary.Left).ConvertedType; - _ = await Assert.That(errors).IsEqualTo(string.Empty); - _ = await Assert.That(leftType?.ToDisplayString()).IsEqualTo("int"); - _ = await Assert.That(mutations.ToArray()).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(errors).IsEqualTo(string.Empty); + _ = await Assert.That(leftType?.ToDisplayString()).IsEqualTo("int"); + _ = await Assert.That(mutations.ToArray()).IsEmpty(); + } } [Test] @@ -164,8 +176,11 @@ public async Task CreateMutations_ExclusiveOrExpression_ReturnsEmpty() { var (mutations, _, _, errors) = Mutate(CreateSource(IntegralTemplate, "^")); - _ = await Assert.That(errors).IsEqualTo(string.Empty); - _ = await Assert.That(mutations.ToArray()).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(errors).IsEqualTo(string.Empty); + _ = await Assert.That(mutations.ToArray()).IsEmpty(); + } } [Test] @@ -174,8 +189,11 @@ public async Task ApplyTo_ConditionalAndToConditionalOr_KeepsTheSurroundingTrivi var expected = TriviaSource.Replace("&& right", "|| right", StringComparison.Ordinal); var (mutations, tree, _, errors) = Mutate(TriviaSource); - _ = await Assert.That(errors).IsEqualTo(string.Empty); - _ = await Assert.That(mutations.Single().ApplyTo(tree).ToString()).IsEqualTo(expected); + using (Assert.Multiple()) + { + _ = await Assert.That(errors).IsEqualTo(string.Empty); + _ = await Assert.That(mutations.Single().ApplyTo(tree).ToString()).IsEqualTo(expected); + } } [Test] @@ -189,8 +207,11 @@ public async Task ApplyTo_BooleanOperands_ProducesCompilableSource(string source var mutated = mutations.Single().ApplyTo(tree).ToString(); var compilation = CompilationFactory.Create(mutated); - _ = await Assert.That(mutated).Contains(expectedText); - _ = await Assert.That(Describe(CompilationFactory.GetCompileErrors(compilation))).IsEqualTo(string.Empty); + using (Assert.Multiple()) + { + _ = await Assert.That(mutated).Contains(expectedText); + _ = await Assert.That(Describe(CompilationFactory.GetCompileErrors(compilation))).IsEqualTo(string.Empty); + } } /// @@ -210,9 +231,12 @@ string expectedName var (mutations, tree, model, errors) = Mutate(CreateSource(TrueFalseOperatorTemplate, source)); var binary = SyntaxNodeLocator.FindMarked(tree); - _ = await Assert.That(errors).IsEqualTo(string.Empty); - _ = await Assert.That(model.GetTypeInfo(binary.Left).ConvertedType?.ToDisplayString()).IsEqualTo("Flag"); - _ = await Assert.That(DisplayNames(mutations)).IsEquivalentTo(expected); + using (Assert.Multiple()) + { + _ = await Assert.That(errors).IsEqualTo(string.Empty); + _ = await Assert.That(model.GetTypeInfo(binary.Left).ConvertedType?.ToDisplayString()).IsEqualTo("Flag"); + _ = await Assert.That(DisplayNames(mutations)).IsEquivalentTo(expected); + } } /// @@ -226,8 +250,11 @@ public async Task CreateMutations_UserDefinedBooleanLikeOperator_ReturnsEmpty(st { var (mutations, _, _, errors) = Mutate(CreateSource(TrueFalseOperatorTemplate, source)); - _ = await Assert.That(errors).IsEqualTo(string.Empty); - _ = await Assert.That(mutations.ToArray()).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(errors).IsEqualTo(string.Empty); + _ = await Assert.That(mutations.ToArray()).IsEmpty(); + } } /// @@ -241,9 +268,12 @@ public async Task CreateMutations_TypelessOperands_ReturnsEmpty() var (mutations, tree, model, _) = Mutate(MethodGroupOperandSource); var binary = SyntaxNodeLocator.FindMarked(tree); - _ = await Assert.That(binary.Kind()).IsEqualTo(SyntaxKind.BitwiseAndExpression); - _ = await Assert.That(model.GetTypeInfo(binary.Left).ConvertedType).IsNull(); - _ = await Assert.That(mutations.ToArray()).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(binary.Kind()).IsEqualTo(SyntaxKind.BitwiseAndExpression); + _ = await Assert.That(model.GetTypeInfo(binary.Left).ConvertedType).IsNull(); + _ = await Assert.That(mutations.ToArray()).IsEmpty(); + } } /// @@ -263,11 +293,14 @@ string expectedId var (mutations, tree, model, errors) = Mutate(CreateSource(MixedNullableBooleanTemplate, source)); var binary = SyntaxNodeLocator.FindMarked(tree); - _ = await Assert.That(errors).IsEqualTo(string.Empty); - _ = await Assert.That(model.GetTypeInfo(binary.Left).Type?.ToDisplayString()).IsEqualTo("bool"); - _ = await Assert.That(model.GetTypeInfo(binary.Right).Type?.ToDisplayString()).IsEqualTo("bool?"); - _ = await Assert.That(DisplayNames(mutations)).IsEquivalentTo(expected); - _ = await Assert.That(mutations.Single().OperatorId).IsEqualTo(expectedId); + using (Assert.Multiple()) + { + _ = await Assert.That(errors).IsEqualTo(string.Empty); + _ = await Assert.That(model.GetTypeInfo(binary.Left).Type?.ToDisplayString()).IsEqualTo("bool"); + _ = await Assert.That(model.GetTypeInfo(binary.Right).Type?.ToDisplayString()).IsEqualTo("bool?"); + _ = await Assert.That(DisplayNames(mutations)).IsEquivalentTo(expected); + _ = await Assert.That(mutations.Single().OperatorId).IsEqualTo(expectedId); + } } [Test] diff --git a/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/NullCoalescingMutatorTests.cs b/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/NullCoalescingMutatorTests.cs index b53b071..3025064 100644 --- a/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/NullCoalescingMutatorTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/NullCoalescingMutatorTests.cs @@ -81,10 +81,13 @@ public async Task Metadata_Operator_DescribesNullCoalescingFamily() var mutator = new NullCoalescingMutator(); SyntaxKind[] supported = [.. mutator.SupportedSyntaxKinds]; - _ = await Assert.That(mutator.Id).IsEqualTo("null-coalescing"); - _ = await Assert.That(mutator.Kind).IsEqualTo(MutationKind.NullCoalescing); - _ = await Assert.That(supported).Count().IsEqualTo(1); - _ = await Assert.That(supported).Contains(SyntaxKind.CoalesceExpression); + using (Assert.Multiple()) + { + _ = await Assert.That(mutator.Id).IsEqualTo("null-coalescing"); + _ = await Assert.That(mutator.Kind).IsEqualTo(MutationKind.NullCoalescing); + _ = await Assert.That(supported).Count().IsEqualTo(1); + _ = await Assert.That(supported).Contains(SyntaxKind.CoalesceExpression); + } } [Test] @@ -92,18 +95,21 @@ public async Task CreateMutations_ReferenceOperands_KeepsLeftAndRight() { var (tree, mutations) = Run(ReferenceSource); - _ = await Assert.That(mutations).Count().IsEqualTo(2); - _ = await Assert.That(mutations[0].Kind).IsEqualTo(MutationKind.NullCoalescing); - _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("null-coalescing.keep-left"); - _ = await Assert.That(mutations[0].DisplayName).IsEqualTo("a ?? b => a"); - _ = await Assert.That(mutations[1].OperatorId).IsEqualTo("null-coalescing.keep-right"); - _ = await Assert.That(mutations[1].DisplayName).IsEqualTo("a ?? b => b"); - _ = await Assert - .That(Rewrite(tree, mutations[0])) - .IsEqualTo("public class Sample { public string Get(string? a, string b) => a; }"); - _ = await Assert - .That(Rewrite(tree, mutations[1])) - .IsEqualTo("public class Sample { public string Get(string? a, string b) => b; }"); + using (Assert.Multiple()) + { + _ = await Assert.That(mutations).Count().IsEqualTo(2); + _ = await Assert.That(mutations[0].Kind).IsEqualTo(MutationKind.NullCoalescing); + _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("null-coalescing.keep-left"); + _ = await Assert.That(mutations[0].DisplayName).IsEqualTo("a ?? b => a"); + _ = await Assert.That(mutations[1].OperatorId).IsEqualTo("null-coalescing.keep-right"); + _ = await Assert.That(mutations[1].DisplayName).IsEqualTo("a ?? b => b"); + _ = await Assert + .That(Rewrite(tree, mutations[0])) + .IsEqualTo("public class Sample { public string Get(string? a, string b) => a; }"); + _ = await Assert + .That(Rewrite(tree, mutations[1])) + .IsEqualTo("public class Sample { public string Get(string? a, string b) => b; }"); + } } [Test] @@ -111,11 +117,14 @@ public async Task CreateMutations_ThrowExpressionOnTheRight_KeepsOnlyLeft() { var (tree, mutations) = Run(ThrowSource); - _ = await Assert.That(mutations).Count().IsEqualTo(1); - _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("null-coalescing.keep-left"); - _ = await Assert - .That(Rewrite(tree, mutations[0])) - .IsEqualTo("public class Sample { public string Get(string? a) => a; }"); + using (Assert.Multiple()) + { + _ = await Assert.That(mutations).Count().IsEqualTo(1); + _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("null-coalescing.keep-left"); + _ = await Assert + .That(Rewrite(tree, mutations[0])) + .IsEqualTo("public class Sample { public string Get(string? a) => a; }"); + } } [Test] @@ -123,11 +132,14 @@ public async Task CreateMutations_NullableValueTypeOnTheLeft_KeepsOnlyRight() { var (tree, mutations) = Run(NullableValueSource); - _ = await Assert.That(mutations).Count().IsEqualTo(1); - _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("null-coalescing.keep-right"); - _ = await Assert - .That(Rewrite(tree, mutations[0])) - .IsEqualTo("public class Sample { public int Get(int? a) => 0; }"); + using (Assert.Multiple()) + { + _ = await Assert.That(mutations).Count().IsEqualTo(1); + _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("null-coalescing.keep-right"); + _ = await Assert + .That(Rewrite(tree, mutations[0])) + .IsEqualTo("public class Sample { public int Get(int? a) => 0; }"); + } } [Test] @@ -152,9 +164,12 @@ public async Task CreateMutations_MutatedNode_IsTheWholeCoalesceExpression() var (tree, mutations) = Run(ReferenceSource); var coalesce = FindCoalesce(tree); - _ = await Assert.That(mutations[0].Original.ToString()).IsEqualTo("a ?? b"); - _ = await Assert.That(mutations[0].Original.Span).IsEqualTo(coalesce.Span); - _ = await Assert.That(mutations[0].Location.SourceSpan).IsEqualTo(coalesce.Span); + using (Assert.Multiple()) + { + _ = await Assert.That(mutations[0].Original.ToString()).IsEqualTo("a ?? b"); + _ = await Assert.That(mutations[0].Original.Span).IsEqualTo(coalesce.Span); + _ = await Assert.That(mutations[0].Location.SourceSpan).IsEqualTo(coalesce.Span); + } } /// @@ -168,10 +183,13 @@ public async Task CreateMutations_UnknownTargetType_KeepsLeftAndRight() var coalesce = (BinaryExpressionSyntax)FindCoalesce(tree); var targetType = semanticModel.GetTypeInfo(coalesce).ConvertedType; - _ = await Assert.That(targetType is null || targetType.TypeKind == TypeKind.Error).IsTrue(); - _ = await Assert.That(mutations).Count().IsEqualTo(2); - _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("null-coalescing.keep-left"); - _ = await Assert.That(mutations[1].OperatorId).IsEqualTo("null-coalescing.keep-right"); + using (Assert.Multiple()) + { + _ = await Assert.That(targetType is null || targetType.TypeKind == TypeKind.Error).IsTrue(); + _ = await Assert.That(mutations).Count().IsEqualTo(2); + _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("null-coalescing.keep-left"); + _ = await Assert.That(mutations[1].OperatorId).IsEqualTo("null-coalescing.keep-right"); + } } /// @@ -184,10 +202,13 @@ public async Task CreateMutations_OperandsWithoutAConversionToTheTargetType_Retu var coalesce = (BinaryExpressionSyntax)FindCoalesce(tree); var targetType = semanticModel.GetTypeInfo(coalesce).ConvertedType!; - _ = await Assert.That(targetType.Name).IsEqualTo("Euro"); - _ = await Assert.That(semanticModel.ClassifyConversion(coalesce.Left, targetType).Exists).IsFalse(); - _ = await Assert.That(semanticModel.ClassifyConversion(coalesce.Right, targetType).Exists).IsFalse(); - _ = await Assert.That(mutations).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(targetType.Name).IsEqualTo("Euro"); + _ = await Assert.That(semanticModel.ClassifyConversion(coalesce.Left, targetType).Exists).IsFalse(); + _ = await Assert.That(semanticModel.ClassifyConversion(coalesce.Right, targetType).Exists).IsFalse(); + _ = await Assert.That(mutations).IsEmpty(); + } } /// @@ -199,15 +220,18 @@ public async Task CreateMutations_NonNullableValueTypeOnTheLeft_KeepsLeftAndRigh { var (tree, mutations) = Run(NonNullableValueLeftSource); - _ = await Assert.That(mutations).Count().IsEqualTo(2); - _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("null-coalescing.keep-left"); - _ = await Assert.That(mutations[1].OperatorId).IsEqualTo("null-coalescing.keep-right"); - _ = await Assert - .That(Rewrite(tree, mutations[0])) - .IsEqualTo(NonNullableValueLeftSource.Replace("a ?? b", "a", StringComparison.Ordinal)); - _ = await Assert - .That(Rewrite(tree, mutations[1])) - .IsEqualTo(NonNullableValueLeftSource.Replace("a ?? b", "b", StringComparison.Ordinal)); + using (Assert.Multiple()) + { + _ = await Assert.That(mutations).Count().IsEqualTo(2); + _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("null-coalescing.keep-left"); + _ = await Assert.That(mutations[1].OperatorId).IsEqualTo("null-coalescing.keep-right"); + _ = await Assert + .That(Rewrite(tree, mutations[0])) + .IsEqualTo(NonNullableValueLeftSource.Replace("a ?? b", "a", StringComparison.Ordinal)); + _ = await Assert + .That(Rewrite(tree, mutations[1])) + .IsEqualTo(NonNullableValueLeftSource.Replace("a ?? b", "b", StringComparison.Ordinal)); + } } private static (SyntaxTree Tree, Mutation[] Mutations) Run(string source) => Run(source, FindCoalesce); diff --git a/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/NullableBooleanLiteralMutatorTests.cs b/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/NullableBooleanLiteralMutatorTests.cs index 77ead39..836b294 100644 --- a/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/NullableBooleanLiteralMutatorTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/NullableBooleanLiteralMutatorTests.cs @@ -47,12 +47,15 @@ public async Task Metadata_Operator_DescribesNullableBooleanLiteralFamily() var mutator = new NullableBooleanLiteralMutator(); SyntaxKind[] supported = [.. mutator.SupportedSyntaxKinds]; - _ = await Assert.That(mutator.Id).IsEqualTo("nullable-boolean-literal"); - _ = await Assert.That(mutator.Kind).IsEqualTo(MutationKind.NullableBooleanLiteral); - _ = await Assert.That(supported).Count().IsEqualTo(3); - _ = await Assert.That(supported).Contains(SyntaxKind.TrueLiteralExpression); - _ = await Assert.That(supported).Contains(SyntaxKind.FalseLiteralExpression); - _ = await Assert.That(supported).Contains(SyntaxKind.NullLiteralExpression); + using (Assert.Multiple()) + { + _ = await Assert.That(mutator.Id).IsEqualTo("nullable-boolean-literal"); + _ = await Assert.That(mutator.Kind).IsEqualTo(MutationKind.NullableBooleanLiteral); + _ = await Assert.That(supported).Count().IsEqualTo(3); + _ = await Assert.That(supported).Contains(SyntaxKind.TrueLiteralExpression); + _ = await Assert.That(supported).Contains(SyntaxKind.FalseLiteralExpression); + _ = await Assert.That(supported).Contains(SyntaxKind.NullLiteralExpression); + } } /// @@ -79,8 +82,11 @@ string expectedNullId var swaps = new BooleanLiteralMutator().CreateMutations(literal, semanticModel, CancellationToken.None); var nulls = new NullableBooleanLiteralMutator().CreateMutations(literal, semanticModel, CancellationToken.None); - _ = await Assert.That(Join(swaps)).IsEqualTo(expectedSwapId); - _ = await Assert.That(Join(nulls)).IsEqualTo(expectedNullId); + using (Assert.Multiple()) + { + _ = await Assert.That(Join(swaps)).IsEqualTo(expectedSwapId); + _ = await Assert.That(Join(nulls)).IsEqualTo(expectedNullId); + } } [Test] @@ -88,12 +94,15 @@ public async Task CreateMutations_TrueLiteral_ReplacesItByNull() { var (tree, mutations) = Run(TrueSource); - _ = await Assert.That(mutations).Count().IsEqualTo(1); - _ = await Assert.That(mutations[0].Kind).IsEqualTo(MutationKind.NullableBooleanLiteral); - _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("nullable-boolean-literal.true-to-null"); - _ = await Assert.That(mutations[0].DisplayName).IsEqualTo("true => null"); - _ = await Assert.That(mutations[0].Replacement.IsKind(SyntaxKind.NullLiteralExpression)).IsTrue(); - _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(NullSource); + using (Assert.Multiple()) + { + _ = await Assert.That(mutations).Count().IsEqualTo(1); + _ = await Assert.That(mutations[0].Kind).IsEqualTo(MutationKind.NullableBooleanLiteral); + _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("nullable-boolean-literal.true-to-null"); + _ = await Assert.That(mutations[0].DisplayName).IsEqualTo("true => null"); + _ = await Assert.That(mutations[0].Replacement.IsKind(SyntaxKind.NullLiteralExpression)).IsTrue(); + _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(NullSource); + } } [Test] @@ -101,11 +110,14 @@ public async Task CreateMutations_FalseLiteral_ReplacesItByNull() { var (tree, mutations) = Run(FalseSource); - _ = await Assert.That(mutations).Count().IsEqualTo(1); - _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("nullable-boolean-literal.false-to-null"); - _ = await Assert.That(mutations[0].DisplayName).IsEqualTo("false => null"); - _ = await Assert.That(mutations[0].Replacement.IsKind(SyntaxKind.NullLiteralExpression)).IsTrue(); - _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(NullSource); + using (Assert.Multiple()) + { + _ = await Assert.That(mutations).Count().IsEqualTo(1); + _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("nullable-boolean-literal.false-to-null"); + _ = await Assert.That(mutations[0].DisplayName).IsEqualTo("false => null"); + _ = await Assert.That(mutations[0].Replacement.IsKind(SyntaxKind.NullLiteralExpression)).IsTrue(); + _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(NullSource); + } } [Test] @@ -113,15 +125,18 @@ public async Task CreateMutations_NullLiteral_ReplacesItByBothBooleanStates() { var (tree, mutations) = Run(NullSource); - _ = await Assert.That(mutations).Count().IsEqualTo(2); - _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("nullable-boolean-literal.null-to-true"); - _ = await Assert.That(mutations[0].DisplayName).IsEqualTo("null => true"); - _ = await Assert.That(mutations[0].Replacement.IsKind(SyntaxKind.TrueLiteralExpression)).IsTrue(); - _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(TrueSource); - _ = await Assert.That(mutations[1].OperatorId).IsEqualTo("nullable-boolean-literal.null-to-false"); - _ = await Assert.That(mutations[1].DisplayName).IsEqualTo("null => false"); - _ = await Assert.That(mutations[1].Replacement.IsKind(SyntaxKind.FalseLiteralExpression)).IsTrue(); - _ = await Assert.That(Rewrite(tree, mutations[1])).IsEqualTo(FalseSource); + using (Assert.Multiple()) + { + _ = await Assert.That(mutations).Count().IsEqualTo(2); + _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("nullable-boolean-literal.null-to-true"); + _ = await Assert.That(mutations[0].DisplayName).IsEqualTo("null => true"); + _ = await Assert.That(mutations[0].Replacement.IsKind(SyntaxKind.TrueLiteralExpression)).IsTrue(); + _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(TrueSource); + _ = await Assert.That(mutations[1].OperatorId).IsEqualTo("nullable-boolean-literal.null-to-false"); + _ = await Assert.That(mutations[1].DisplayName).IsEqualTo("null => false"); + _ = await Assert.That(mutations[1].Replacement.IsKind(SyntaxKind.FalseLiteralExpression)).IsTrue(); + _ = await Assert.That(Rewrite(tree, mutations[1])).IsEqualTo(FalseSource); + } } [Test] @@ -130,9 +145,12 @@ public async Task CreateMutations_NullableFieldInitializer_IsMutated() var expected = FieldInitializerSource.Replace("= false", "= null", StringComparison.Ordinal); var (tree, mutations) = Run(FieldInitializerSource); - _ = await Assert.That(mutations).Count().IsEqualTo(1); - _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("nullable-boolean-literal.false-to-null"); - _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(expected); + using (Assert.Multiple()) + { + _ = await Assert.That(mutations).Count().IsEqualTo(1); + _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("nullable-boolean-literal.false-to-null"); + _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(expected); + } } /// @@ -146,9 +164,12 @@ public async Task CreateMutations_LiftedComparison_IsMutated() var expected = LiftedComparisonSource.Replace("== true", "== null", StringComparison.Ordinal); var (tree, mutations) = Run(LiftedComparisonSource); - _ = await Assert.That(mutations).Count().IsEqualTo(1); - _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("nullable-boolean-literal.true-to-null"); - _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(expected); + using (Assert.Multiple()) + { + _ = await Assert.That(mutations).Count().IsEqualTo(1); + _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("nullable-boolean-literal.true-to-null"); + _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(expected); + } } /// @@ -161,8 +182,11 @@ public async Task CreateMutations_LiteralWithTrivia_KeepsTheSurroundingTrivia() var expected = TriviaSource.Replace("true;", "null;", StringComparison.Ordinal); var (tree, mutations) = Run(TriviaSource); - _ = await Assert.That(mutations).Count().IsEqualTo(1); - _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(expected); + using (Assert.Multiple()) + { + _ = await Assert.That(mutations).Count().IsEqualTo(1); + _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(expected); + } } [Test] diff --git a/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/NumericLiteralMutatorTests.cs b/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/NumericLiteralMutatorTests.cs index 62ac699..d90319b 100644 --- a/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/NumericLiteralMutatorTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/NumericLiteralMutatorTests.cs @@ -126,10 +126,13 @@ public async Task Metadata_Operator_DescribesNumericLiteralFamily() var mutator = new NumericLiteralMutator(); SyntaxKind[] supported = [.. mutator.SupportedSyntaxKinds]; - _ = await Assert.That(mutator.Id).IsEqualTo("numeric-literal"); - _ = await Assert.That(mutator.Kind).IsEqualTo(MutationKind.NumericLiteral); - _ = await Assert.That(supported).Count().IsEqualTo(1); - _ = await Assert.That(supported).Contains(SyntaxKind.NumericLiteralExpression); + using (Assert.Multiple()) + { + _ = await Assert.That(mutator.Id).IsEqualTo("numeric-literal"); + _ = await Assert.That(mutator.Kind).IsEqualTo(MutationKind.NumericLiteral); + _ = await Assert.That(supported).Count().IsEqualTo(1); + _ = await Assert.That(supported).Contains(SyntaxKind.NumericLiteralExpression); + } } [Test] @@ -162,13 +165,20 @@ public async Task CreateMutations_IntegerLiteral_IncrementsAndDecrements() { var (tree, mutations) = Run("public class Sample { public int Get() => 5; }"); - _ = await Assert.That(mutations).Count().IsEqualTo(2); - _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("numeric-literal.increment"); - _ = await Assert.That(mutations[0].DisplayName).IsEqualTo("5 => 6"); - _ = await Assert.That(mutations[1].OperatorId).IsEqualTo("numeric-literal.decrement"); - _ = await Assert.That(mutations[1].DisplayName).IsEqualTo("5 => 4"); - _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo("public class Sample { public int Get() => 6; }"); - _ = await Assert.That(Rewrite(tree, mutations[1])).IsEqualTo("public class Sample { public int Get() => 4; }"); + using (Assert.Multiple()) + { + _ = await Assert.That(mutations).Count().IsEqualTo(2); + _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("numeric-literal.increment"); + _ = await Assert.That(mutations[0].DisplayName).IsEqualTo("5 => 6"); + _ = await Assert.That(mutations[1].OperatorId).IsEqualTo("numeric-literal.decrement"); + _ = await Assert.That(mutations[1].DisplayName).IsEqualTo("5 => 4"); + _ = await Assert + .That(Rewrite(tree, mutations[0])) + .IsEqualTo("public class Sample { public int Get() => 6; }"); + _ = await Assert + .That(Rewrite(tree, mutations[1])) + .IsEqualTo("public class Sample { public int Get() => 4; }"); + } } [Test] @@ -176,10 +186,15 @@ public async Task CreateMutations_ZeroLiteral_ReturnsOnlyTheZeroToOneMutation() { var (tree, mutations) = Run("public class Sample { public int Get() => 0; }"); - _ = await Assert.That(mutations).Count().IsEqualTo(1); - _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("numeric-literal.zero-to-one"); - _ = await Assert.That(mutations[0].DisplayName).IsEqualTo("0 => 1"); - _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo("public class Sample { public int Get() => 1; }"); + using (Assert.Multiple()) + { + _ = await Assert.That(mutations).Count().IsEqualTo(1); + _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("numeric-literal.zero-to-one"); + _ = await Assert.That(mutations[0].DisplayName).IsEqualTo("0 => 1"); + _ = await Assert + .That(Rewrite(tree, mutations[0])) + .IsEqualTo("public class Sample { public int Get() => 1; }"); + } } [Test] @@ -187,10 +202,15 @@ public async Task CreateMutations_OneLiteral_ReturnsOnlyTheOneToZeroMutation() { var (tree, mutations) = Run("public class Sample { public int Get() => 1; }"); - _ = await Assert.That(mutations).Count().IsEqualTo(1); - _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("numeric-literal.one-to-zero"); - _ = await Assert.That(mutations[0].DisplayName).IsEqualTo("1 => 0"); - _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo("public class Sample { public int Get() => 0; }"); + using (Assert.Multiple()) + { + _ = await Assert.That(mutations).Count().IsEqualTo(1); + _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("numeric-literal.one-to-zero"); + _ = await Assert.That(mutations[0].DisplayName).IsEqualTo("1 => 0"); + _ = await Assert + .That(Rewrite(tree, mutations[0])) + .IsEqualTo("public class Sample { public int Get() => 0; }"); + } } /// @@ -221,10 +241,13 @@ string expected { var (tree, mutations) = Run(Fixture(type, literal)); - _ = await Assert.That(mutations).Count().IsEqualTo(1); - _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("numeric-literal.decrement"); - _ = await Assert.That(mutations[0].DisplayName).IsEqualTo($"{literal} => {expected}"); - _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(Fixture(type, expected)); + using (Assert.Multiple()) + { + _ = await Assert.That(mutations).Count().IsEqualTo(1); + _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("numeric-literal.decrement"); + _ = await Assert.That(mutations[0].DisplayName).IsEqualTo($"{literal} => {expected}"); + _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(Fixture(type, expected)); + } } /// @@ -243,10 +266,13 @@ public async Task CreateMutations_BoxedMaximum_OffersOnlyTheDecrement(string lit { var (tree, mutations) = Run(Fixture("object", literal)); - _ = await Assert.That(mutations).Count().IsEqualTo(1); - _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("numeric-literal.decrement"); - _ = await Assert.That(mutations[0].DisplayName).IsEqualTo($"{literal} => {expected}"); - _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(Fixture("object", expected)); + using (Assert.Multiple()) + { + _ = await Assert.That(mutations).Count().IsEqualTo(1); + _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("numeric-literal.decrement"); + _ = await Assert.That(mutations[0].DisplayName).IsEqualTo($"{literal} => {expected}"); + _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(Fixture("object", expected)); + } } /// @@ -274,10 +300,13 @@ string expected { var (tree, mutations) = Run(Fixture(type, literal)); - _ = await Assert.That(mutations).Count().IsEqualTo(1); - _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("numeric-literal.zero-to-one"); - _ = await Assert.That(mutations[0].DisplayName).IsEqualTo("0 => 1"); - _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(Fixture(type, expected)); + using (Assert.Multiple()) + { + _ = await Assert.That(mutations).Count().IsEqualTo(1); + _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("numeric-literal.zero-to-one"); + _ = await Assert.That(mutations[0].DisplayName).IsEqualTo("0 => 1"); + _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(Fixture(type, expected)); + } } /// @@ -300,10 +329,13 @@ string expected { var (tree, mutations) = Run(Fixture(type, literal)); - _ = await Assert.That(mutations).Count().IsEqualTo(1); - _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("numeric-literal.one-to-zero"); - _ = await Assert.That(mutations[0].DisplayName).IsEqualTo("1 => 0"); - _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(Fixture(type, expected)); + using (Assert.Multiple()) + { + _ = await Assert.That(mutations).Count().IsEqualTo(1); + _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("numeric-literal.one-to-zero"); + _ = await Assert.That(mutations[0].DisplayName).IsEqualTo("1 => 0"); + _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(Fixture(type, expected)); + } } /// @@ -341,13 +373,16 @@ string decremented { var (tree, mutations) = Run(Fixture(type, literal)); - _ = await Assert.That(mutations).Count().IsEqualTo(2); - _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("numeric-literal.increment"); - _ = await Assert.That(mutations[0].DisplayName).IsEqualTo($"{literal} => {incremented}"); - _ = await Assert.That(mutations[1].OperatorId).IsEqualTo("numeric-literal.decrement"); - _ = await Assert.That(mutations[1].DisplayName).IsEqualTo($"{literal} => {decremented}"); - _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(Fixture(type, incremented)); - _ = await Assert.That(Rewrite(tree, mutations[1])).IsEqualTo(Fixture(type, decremented)); + using (Assert.Multiple()) + { + _ = await Assert.That(mutations).Count().IsEqualTo(2); + _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("numeric-literal.increment"); + _ = await Assert.That(mutations[0].DisplayName).IsEqualTo($"{literal} => {incremented}"); + _ = await Assert.That(mutations[1].OperatorId).IsEqualTo("numeric-literal.decrement"); + _ = await Assert.That(mutations[1].DisplayName).IsEqualTo($"{literal} => {decremented}"); + _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(Fixture(type, incremented)); + _ = await Assert.That(Rewrite(tree, mutations[1])).IsEqualTo(Fixture(type, decremented)); + } } /// @@ -360,11 +395,18 @@ public async Task CreateMutations_NegatedIntegerLiteral_MutatesThePositiveToken( { var (tree, mutations) = Run("public class Sample { public int Get() => -5; }"); - _ = await Assert.That(mutations).Count().IsEqualTo(2); - _ = await Assert.That(mutations[0].DisplayName).IsEqualTo("5 => 6"); - _ = await Assert.That(mutations[1].DisplayName).IsEqualTo("5 => 4"); - _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo("public class Sample { public int Get() => -6; }"); - _ = await Assert.That(Rewrite(tree, mutations[1])).IsEqualTo("public class Sample { public int Get() => -4; }"); + using (Assert.Multiple()) + { + _ = await Assert.That(mutations).Count().IsEqualTo(2); + _ = await Assert.That(mutations[0].DisplayName).IsEqualTo("5 => 6"); + _ = await Assert.That(mutations[1].DisplayName).IsEqualTo("5 => 4"); + _ = await Assert + .That(Rewrite(tree, mutations[0])) + .IsEqualTo("public class Sample { public int Get() => -6; }"); + _ = await Assert + .That(Rewrite(tree, mutations[1])) + .IsEqualTo("public class Sample { public int Get() => -4; }"); + } } /// @@ -388,9 +430,12 @@ string decremented { var (_, mutations) = Run(Fixture(type, "-" + literal)); - _ = await Assert.That(mutations).Count().IsEqualTo(2); - _ = await Assert.That(mutations[0].DisplayName).IsEqualTo($"{literal} => {incremented}"); - _ = await Assert.That(mutations[1].DisplayName).IsEqualTo($"{literal} => {decremented}"); + using (Assert.Multiple()) + { + _ = await Assert.That(mutations).Count().IsEqualTo(2); + _ = await Assert.That(mutations[0].DisplayName).IsEqualTo($"{literal} => {incremented}"); + _ = await Assert.That(mutations[1].DisplayName).IsEqualTo($"{literal} => {decremented}"); + } } [Test] @@ -398,9 +443,12 @@ public async Task CreateMutations_NullableTargetType_UsesTheUnderlyingRange() { var (_, mutations) = Run("public class Sample { public byte? Get() => 255; }"); - _ = await Assert.That(mutations).Count().IsEqualTo(1); - _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("numeric-literal.decrement"); - _ = await Assert.That(mutations[0].DisplayName).IsEqualTo("255 => 254"); + using (Assert.Multiple()) + { + _ = await Assert.That(mutations).Count().IsEqualTo(1); + _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("numeric-literal.decrement"); + _ = await Assert.That(mutations[0].DisplayName).IsEqualTo("255 => 254"); + } } /// @@ -414,14 +462,17 @@ public async Task CreateMutations_DynamicTargetType_OffersBothNeighbours() { var (tree, mutations) = Run("public class Sample { public dynamic Get() => 42; }"); - _ = await Assert.That(mutations).Count().IsEqualTo(2); - _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("numeric-literal.increment"); - _ = await Assert.That(mutations[0].DisplayName).IsEqualTo("42 => 43"); - _ = await Assert.That(mutations[1].OperatorId).IsEqualTo("numeric-literal.decrement"); - _ = await Assert.That(mutations[1].DisplayName).IsEqualTo("42 => 41"); - _ = await Assert - .That(Rewrite(tree, mutations[0])) - .IsEqualTo("public class Sample { public dynamic Get() => 43; }"); + using (Assert.Multiple()) + { + _ = await Assert.That(mutations).Count().IsEqualTo(2); + _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("numeric-literal.increment"); + _ = await Assert.That(mutations[0].DisplayName).IsEqualTo("42 => 43"); + _ = await Assert.That(mutations[1].OperatorId).IsEqualTo("numeric-literal.decrement"); + _ = await Assert.That(mutations[1].DisplayName).IsEqualTo("42 => 41"); + _ = await Assert + .That(Rewrite(tree, mutations[0])) + .IsEqualTo("public class Sample { public dynamic Get() => 43; }"); + } } [Test] @@ -429,9 +480,12 @@ public async Task CreateMutations_ArgumentConvertedToByte_OffersOnlyTheDecrement { var (_, mutations) = Run(ByteArgumentSource); - _ = await Assert.That(mutations).Count().IsEqualTo(1); - _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("numeric-literal.decrement"); - _ = await Assert.That(mutations[0].DisplayName).IsEqualTo("255 => 254"); + using (Assert.Multiple()) + { + _ = await Assert.That(mutations).Count().IsEqualTo(1); + _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("numeric-literal.decrement"); + _ = await Assert.That(mutations[0].DisplayName).IsEqualTo("255 => 254"); + } } /// @@ -453,10 +507,13 @@ string expected { var (tree, mutations) = Run(Fixture(type, literal)); - _ = await Assert.That(mutations).Count().IsEqualTo(1); - _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("numeric-literal.decrement"); - _ = await Assert.That(mutations[0].DisplayName).IsEqualTo($"{literal} => {expected}"); - _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(Fixture(type, expected)); + using (Assert.Multiple()) + { + _ = await Assert.That(mutations).Count().IsEqualTo(1); + _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("numeric-literal.decrement"); + _ = await Assert.That(mutations[0].DisplayName).IsEqualTo($"{literal} => {expected}"); + _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(Fixture(type, expected)); + } } /// @@ -471,10 +528,13 @@ public async Task CreateMutations_ValueOutsideTheTargetRange_ReturnsEmpty() var mutator = new NumericLiteralMutator(); Mutation[] mutations = [.. mutator.CreateMutations(literal, semanticModel, CancellationToken.None)]; - _ = await Assert - .That(semanticModel.GetTypeInfo(literal).ConvertedType?.SpecialType) - .IsEqualTo(SpecialType.System_Byte); - _ = await Assert.That(mutations).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert + .That(semanticModel.GetTypeInfo(literal).ConvertedType?.SpecialType) + .IsEqualTo(SpecialType.System_Byte); + _ = await Assert.That(mutations).IsEmpty(); + } } /// @@ -494,8 +554,11 @@ public async Task CreateMutations_LiteralWithoutAConstantValue_ReturnsEmpty() var mutator = new NumericLiteralMutator(); Mutation[] mutations = [.. mutator.CreateMutations(literal, semanticModel, CancellationToken.None)]; - _ = await Assert.That(semanticModel.GetConstantValue(literal).HasValue).IsFalse(); - _ = await Assert.That(mutations).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(semanticModel.GetConstantValue(literal).HasValue).IsFalse(); + _ = await Assert.That(mutations).IsEmpty(); + } } /// @@ -507,14 +570,17 @@ public async Task CreateMutations_NonConstantFieldInitializer_IsMutated() { var (tree, mutations) = Run("public class Sample { private int _value = 42; }"); - _ = await Assert.That(mutations).Count().IsEqualTo(2); - _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("numeric-literal.increment"); - _ = await Assert.That(mutations[0].DisplayName).IsEqualTo("42 => 43"); - _ = await Assert.That(mutations[1].OperatorId).IsEqualTo("numeric-literal.decrement"); - _ = await Assert.That(mutations[1].DisplayName).IsEqualTo("42 => 41"); - _ = await Assert - .That(Rewrite(tree, mutations[0])) - .IsEqualTo("public class Sample { private int _value = 43; }"); + using (Assert.Multiple()) + { + _ = await Assert.That(mutations).Count().IsEqualTo(2); + _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("numeric-literal.increment"); + _ = await Assert.That(mutations[0].DisplayName).IsEqualTo("42 => 43"); + _ = await Assert.That(mutations[1].OperatorId).IsEqualTo("numeric-literal.decrement"); + _ = await Assert.That(mutations[1].DisplayName).IsEqualTo("42 => 41"); + _ = await Assert + .That(Rewrite(tree, mutations[0])) + .IsEqualTo("public class Sample { private int _value = 43; }"); + } } /// @@ -527,14 +593,17 @@ public async Task CreateMutations_NonConstantLocalDeclaration_IsMutated() { var (tree, mutations) = Run("public class Sample { public int Get() { int value = 42; return value; } }"); - _ = await Assert.That(mutations).Count().IsEqualTo(2); - _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("numeric-literal.increment"); - _ = await Assert.That(mutations[0].DisplayName).IsEqualTo("42 => 43"); - _ = await Assert.That(mutations[1].OperatorId).IsEqualTo("numeric-literal.decrement"); - _ = await Assert.That(mutations[1].DisplayName).IsEqualTo("42 => 41"); - _ = await Assert - .That(Rewrite(tree, mutations[0])) - .IsEqualTo("public class Sample { public int Get() { int value = 43; return value; } }"); + using (Assert.Multiple()) + { + _ = await Assert.That(mutations).Count().IsEqualTo(2); + _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("numeric-literal.increment"); + _ = await Assert.That(mutations[0].DisplayName).IsEqualTo("42 => 43"); + _ = await Assert.That(mutations[1].OperatorId).IsEqualTo("numeric-literal.decrement"); + _ = await Assert.That(mutations[1].DisplayName).IsEqualTo("42 => 41"); + _ = await Assert + .That(Rewrite(tree, mutations[0])) + .IsEqualTo("public class Sample { public int Get() { int value = 43; return value; } }"); + } } /// @@ -550,9 +619,12 @@ public async Task CreateMutations_MaximumInArithmeticContext_OffersOnlyTheDecrem { var (_, mutations) = Run(Fixture("int", expression)); - _ = await Assert.That(mutations).Count().IsEqualTo(1); - _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("numeric-literal.decrement"); - _ = await Assert.That(mutations[0].DisplayName).IsEqualTo("2147483647 => 2147483646"); + using (Assert.Multiple()) + { + _ = await Assert.That(mutations).Count().IsEqualTo(1); + _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("numeric-literal.decrement"); + _ = await Assert.That(mutations[0].DisplayName).IsEqualTo("2147483647 => 2147483646"); + } } /// @@ -565,12 +637,15 @@ public async Task CreateMutations_IntegerLiteralInFloatingContext_StaysIntegral( { var (tree, mutations) = Run("public class Sample { public double Get() => 5; }"); - _ = await Assert.That(mutations).Count().IsEqualTo(2); - _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("numeric-literal.increment"); - _ = await Assert.That(mutations[1].OperatorId).IsEqualTo("numeric-literal.decrement"); - _ = await Assert - .That(Rewrite(tree, mutations[0])) - .IsEqualTo("public class Sample { public double Get() => 6; }"); + using (Assert.Multiple()) + { + _ = await Assert.That(mutations).Count().IsEqualTo(2); + _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("numeric-literal.increment"); + _ = await Assert.That(mutations[1].OperatorId).IsEqualTo("numeric-literal.decrement"); + _ = await Assert + .That(Rewrite(tree, mutations[0])) + .IsEqualTo("public class Sample { public double Get() => 6; }"); + } } [Test] @@ -578,11 +653,14 @@ public async Task CreateMutations_IntegerZeroInFloatingContext_ReturnsTheIntegra { var (tree, mutations) = Run("public class Sample { public float Get() => 0; }"); - _ = await Assert.That(mutations).Count().IsEqualTo(1); - _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("numeric-literal.zero-to-one"); - _ = await Assert - .That(Rewrite(tree, mutations[0])) - .IsEqualTo("public class Sample { public float Get() => 1; }"); + using (Assert.Multiple()) + { + _ = await Assert.That(mutations).Count().IsEqualTo(1); + _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("numeric-literal.zero-to-one"); + _ = await Assert + .That(Rewrite(tree, mutations[0])) + .IsEqualTo("public class Sample { public float Get() => 1; }"); + } } /// @@ -605,10 +683,13 @@ public async Task CreateMutations_FloatingLiteral_NegatesItKeepingTheNotation(st { var (tree, mutations) = Run(Fixture(type, literal)); - _ = await Assert.That(mutations).Count().IsEqualTo(1); - _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("numeric-literal.negate"); - _ = await Assert.That(mutations[0].DisplayName).IsEqualTo($"{literal} => -{literal}"); - _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(Fixture(type, "-" + literal)); + using (Assert.Multiple()) + { + _ = await Assert.That(mutations).Count().IsEqualTo(1); + _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("numeric-literal.negate"); + _ = await Assert.That(mutations[0].DisplayName).IsEqualTo($"{literal} => -{literal}"); + _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(Fixture(type, "-" + literal)); + } } /// @@ -638,10 +719,13 @@ string expected { var (tree, mutations) = Run(Fixture(type, literal)); - _ = await Assert.That(mutations).Count().IsEqualTo(1); - _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("numeric-literal.zero-to-one"); - _ = await Assert.That(mutations[0].DisplayName).IsEqualTo("0 => 1"); - _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(Fixture(type, expected)); + using (Assert.Multiple()) + { + _ = await Assert.That(mutations).Count().IsEqualTo(1); + _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("numeric-literal.zero-to-one"); + _ = await Assert.That(mutations[0].DisplayName).IsEqualTo("0 => 1"); + _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(Fixture(type, expected)); + } } /// @@ -654,11 +738,14 @@ public async Task CreateMutations_NegativeFloatingZero_ReturnsTheZeroToOneMutati { var (tree, mutations) = Run("public class Sample { public double Get() => -0.0; }"); - _ = await Assert.That(mutations).Count().IsEqualTo(1); - _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("numeric-literal.zero-to-one"); - _ = await Assert - .That(Rewrite(tree, mutations[0])) - .IsEqualTo("public class Sample { public double Get() => -1.0; }"); + using (Assert.Multiple()) + { + _ = await Assert.That(mutations).Count().IsEqualTo(1); + _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("numeric-literal.zero-to-one"); + _ = await Assert + .That(Rewrite(tree, mutations[0])) + .IsEqualTo("public class Sample { public double Get() => -1.0; }"); + } } /// @@ -783,12 +870,15 @@ public async Task CreateMutations_LiteralInsideADirective_ReturnsEmpty() var mutator = new NumericLiteralMutator(); Mutation[] mutations = [.. mutator.CreateMutations(literal, semanticModel, CancellationToken.None)]; - _ = await Assert.That(CompilationFactory.GetCompileErrors(compilation)).IsEmpty(); - _ = await Assert.That(literal.ToString()).IsEqualTo("1591"); - _ = await Assert.That(literal.Parent?.Kind()).IsEqualTo(SyntaxKind.PragmaWarningDirectiveTrivia); - _ = await Assert.That(literal.Parent?.Parent).IsNull(); - _ = await Assert.That(semanticModel.GetConstantValue(literal).HasValue).IsFalse(); - _ = await Assert.That(mutations).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(CompilationFactory.GetCompileErrors(compilation)).IsEmpty(); + _ = await Assert.That(literal.ToString()).IsEqualTo("1591"); + _ = await Assert.That(literal.Parent?.Kind()).IsEqualTo(SyntaxKind.PragmaWarningDirectiveTrivia); + _ = await Assert.That(literal.Parent?.Parent).IsNull(); + _ = await Assert.That(semanticModel.GetConstantValue(literal).HasValue).IsFalse(); + _ = await Assert.That(mutations).IsEmpty(); + } } [Test] diff --git a/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/RegexOptionsMutatorTests.cs b/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/RegexOptionsMutatorTests.cs index 1a441b1..cae3d3e 100644 --- a/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/RegexOptionsMutatorTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/RegexOptionsMutatorTests.cs @@ -330,11 +330,14 @@ public async Task Metadata_Operator_ExposesIdKindAndSupportedKinds() { var mutator = new RegexOptionsMutator(); - _ = await Assert.That(mutator.Id).IsEqualTo("culture.regex-options"); - _ = await Assert.That(mutator.Kind).IsEqualTo(MutationKind.RegexOptions); - _ = await Assert - .That(mutator.SupportedSyntaxKinds) - .IsEquivalentTo(new[] { SyntaxKind.SimpleMemberAccessExpression, SyntaxKind.BitwiseOrExpression }); + using (Assert.Multiple()) + { + _ = await Assert.That(mutator.Id).IsEqualTo("culture.regex-options"); + _ = await Assert.That(mutator.Kind).IsEqualTo(MutationKind.RegexOptions); + _ = await Assert + .That(mutator.SupportedSyntaxKinds) + .IsEquivalentTo(new[] { SyntaxKind.SimpleMemberAccessExpression, SyntaxKind.BitwiseOrExpression }); + } } /// @@ -360,12 +363,15 @@ public async Task CreateMutations_EveryMutation_UsesTheOperatorIdPrefixAndFamily .Where(mutation => !mutation.OperatorId.StartsWith(OperatorIdPrefix, StringComparison.Ordinal)) .Select(mutation => mutation.OperatorId); - _ = await Assert.That(offenders).IsEmpty(); - _ = await Assert - .That(mutations.Select(mutation => mutation.Kind).Distinct()) - .IsEquivalentTo(new[] { MutationKind.RegexOptions }); - _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("culture.regex-options.remove-ignore-case"); - _ = await Assert.That(mutations[0].DisplayName).IsEqualTo("RegexOptions - IgnoreCase"); + using (Assert.Multiple()) + { + _ = await Assert.That(offenders).IsEmpty(); + _ = await Assert + .That(mutations.Select(mutation => mutation.Kind).Distinct()) + .IsEquivalentTo(new[] { MutationKind.RegexOptions }); + _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("culture.regex-options.remove-ignore-case"); + _ = await Assert.That(mutations[0].DisplayName).IsEqualTo("RegexOptions - IgnoreCase"); + } } [Test] @@ -373,14 +379,17 @@ public async Task CreateMutations_SingleFlag_RemovesItAndAddsEveryAbsentFlag() { var (_, mutations) = Mutate(ConstructorSource); - _ = await Assert.That(Suffixes(mutations)).IsEqualTo(Join(_singleFlagSuffixes)); - _ = await Assert - .That(DisplayNames(mutations)) - .IsEqualTo( - "RegexOptions - IgnoreCase, RegexOptions + CultureInvariant, RegexOptions + Multiline, " - + "RegexOptions + Singleline, RegexOptions + ExplicitCapture, " - + "RegexOptions + IgnorePatternWhitespace, RegexOptions + RightToLeft" - ); + using (Assert.Multiple()) + { + _ = await Assert.That(Suffixes(mutations)).IsEqualTo(Join(_singleFlagSuffixes)); + _ = await Assert + .That(DisplayNames(mutations)) + .IsEqualTo( + "RegexOptions - IgnoreCase, RegexOptions + CultureInvariant, RegexOptions + Multiline, " + + "RegexOptions + Singleline, RegexOptions + ExplicitCapture, " + + "RegexOptions + IgnorePatternWhitespace, RegexOptions + RightToLeft" + ); + } } /// @@ -392,20 +401,23 @@ public async Task CreateMutations_SingleFlag_RewritesTheSource() { var (tree, mutations) = Mutate(ConstructorSource); - _ = await Assert - .That(Rewrite(tree, Single(mutations, "remove-ignore-case"))) - .IsEqualTo( - ConstructorSource.Replace("RegexOptions.IgnoreCase", "RegexOptions.None", StringComparison.Ordinal) - ); - _ = await Assert - .That(Rewrite(tree, Single(mutations, "add-culture-invariant"))) - .IsEqualTo( - ConstructorSource.Replace( - "RegexOptions.IgnoreCase", - "RegexOptions.IgnoreCase | RegexOptions.CultureInvariant", - StringComparison.Ordinal - ) - ); + using (Assert.Multiple()) + { + _ = await Assert + .That(Rewrite(tree, Single(mutations, "remove-ignore-case"))) + .IsEqualTo( + ConstructorSource.Replace("RegexOptions.IgnoreCase", "RegexOptions.None", StringComparison.Ordinal) + ); + _ = await Assert + .That(Rewrite(tree, Single(mutations, "add-culture-invariant"))) + .IsEqualTo( + ConstructorSource.Replace( + "RegexOptions.IgnoreCase", + "RegexOptions.IgnoreCase | RegexOptions.CultureInvariant", + StringComparison.Ordinal + ) + ); + } } [Test] @@ -413,17 +425,20 @@ public async Task CreateMutations_StaticIsMatchArgument_IsMutated() { var (tree, mutations) = Mutate(StaticIsMatchSource); - _ = await Assert - .That(Suffixes(mutations)) - .IsEqualTo( - "remove-multiline, add-ignore-case, add-culture-invariant, add-singleline, add-explicit-capture, " - + "add-ignore-pattern-whitespace, add-right-to-left" - ); - _ = await Assert - .That(Rewrite(tree, Single(mutations, "remove-multiline"))) - .IsEqualTo( - StaticIsMatchSource.Replace("RegexOptions.Multiline", "RegexOptions.None", StringComparison.Ordinal) - ); + using (Assert.Multiple()) + { + _ = await Assert + .That(Suffixes(mutations)) + .IsEqualTo( + "remove-multiline, add-ignore-case, add-culture-invariant, add-singleline, add-explicit-capture, " + + "add-ignore-pattern-whitespace, add-right-to-left" + ); + _ = await Assert + .That(Rewrite(tree, Single(mutations, "remove-multiline"))) + .IsEqualTo( + StaticIsMatchSource.Replace("RegexOptions.Multiline", "RegexOptions.None", StringComparison.Ordinal) + ); + } } [Test] @@ -431,17 +446,20 @@ public async Task CreateMutations_TwoOperands_RemovesEachOperandIndividually() { var (_, mutations) = Mutate(TwoOperandSource); - _ = await Assert - .That(Suffixes(mutations)) - .IsEqualTo( - "remove-ignore-case, remove-multiline, add-culture-invariant, add-singleline, " - + "add-explicit-capture, add-ignore-pattern-whitespace, add-right-to-left" - ); - _ = await Assert.That(Replacement(mutations, "remove-ignore-case")).IsEqualTo("RegexOptions.Multiline"); - _ = await Assert.That(Replacement(mutations, "remove-multiline")).IsEqualTo("RegexOptions.IgnoreCase"); - _ = await Assert - .That(Replacement(mutations, "add-singleline")) - .IsEqualTo("RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.Singleline"); + using (Assert.Multiple()) + { + _ = await Assert + .That(Suffixes(mutations)) + .IsEqualTo( + "remove-ignore-case, remove-multiline, add-culture-invariant, add-singleline, " + + "add-explicit-capture, add-ignore-pattern-whitespace, add-right-to-left" + ); + _ = await Assert.That(Replacement(mutations, "remove-ignore-case")).IsEqualTo("RegexOptions.Multiline"); + _ = await Assert.That(Replacement(mutations, "remove-multiline")).IsEqualTo("RegexOptions.IgnoreCase"); + _ = await Assert + .That(Replacement(mutations, "add-singleline")) + .IsEqualTo("RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.Singleline"); + } } [Test] @@ -453,8 +471,11 @@ public async Task CreateMutations_TwoOperands_EveryMutantCompiles() .SelectMany(source => CompilationFactory.GetCompileErrors(CompilationFactory.Create(source))) .Select(diagnostic => diagnostic.Id); - _ = await Assert.That(mutations).Count().IsEqualTo(7); - _ = await Assert.That(errors).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(mutations).Count().IsEqualTo(7); + _ = await Assert.That(errors).IsEmpty(); + } } [Test] @@ -462,27 +483,30 @@ public async Task CreateMutations_ThreeOperands_RemovesEachOperandIndividually() { var (_, mutations) = Mutate(ThreeOperandSource); - _ = await Assert - .That(Suffixes(mutations)) - .IsEqualTo( - "remove-ignore-case, remove-multiline, remove-singleline, add-culture-invariant, " - + "add-explicit-capture, add-ignore-pattern-whitespace, add-right-to-left" - ); - _ = await Assert - .That(Replacement(mutations, "remove-ignore-case")) - .IsEqualTo("RegexOptions.Multiline | RegexOptions.Singleline"); - _ = await Assert - .That(Replacement(mutations, "remove-multiline")) - .IsEqualTo("RegexOptions.IgnoreCase | RegexOptions.Singleline"); - _ = await Assert - .That(Replacement(mutations, "remove-singleline")) - .IsEqualTo("RegexOptions.IgnoreCase | RegexOptions.Multiline"); - _ = await Assert - .That(Replacement(mutations, "add-culture-invariant")) - .IsEqualTo( - "RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.Singleline " - + "| RegexOptions.CultureInvariant" - ); + using (Assert.Multiple()) + { + _ = await Assert + .That(Suffixes(mutations)) + .IsEqualTo( + "remove-ignore-case, remove-multiline, remove-singleline, add-culture-invariant, " + + "add-explicit-capture, add-ignore-pattern-whitespace, add-right-to-left" + ); + _ = await Assert + .That(Replacement(mutations, "remove-ignore-case")) + .IsEqualTo("RegexOptions.Multiline | RegexOptions.Singleline"); + _ = await Assert + .That(Replacement(mutations, "remove-multiline")) + .IsEqualTo("RegexOptions.IgnoreCase | RegexOptions.Singleline"); + _ = await Assert + .That(Replacement(mutations, "remove-singleline")) + .IsEqualTo("RegexOptions.IgnoreCase | RegexOptions.Multiline"); + _ = await Assert + .That(Replacement(mutations, "add-culture-invariant")) + .IsEqualTo( + "RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.Singleline " + + "| RegexOptions.CultureInvariant" + ); + } } /// @@ -494,12 +518,17 @@ public async Task CreateMutations_None_AddsEveryFlagAndRemovesNothing() { var (tree, mutations) = Mutate(NoneSource); - _ = await Assert.That(Suffixes(mutations)).IsEqualTo(Join(_allAdditionSuffixes)); - _ = await Assert.That(Replacement(mutations, "add-ignore-case")).IsEqualTo("RegexOptions.IgnoreCase"); - _ = await Assert.That(Replacement(mutations, "add-right-to-left")).IsEqualTo("RegexOptions.RightToLeft"); - _ = await Assert - .That(Rewrite(tree, Single(mutations, "add-ignore-case"))) - .IsEqualTo(NoneSource.Replace("RegexOptions.None", "RegexOptions.IgnoreCase", StringComparison.Ordinal)); + using (Assert.Multiple()) + { + _ = await Assert.That(Suffixes(mutations)).IsEqualTo(Join(_allAdditionSuffixes)); + _ = await Assert.That(Replacement(mutations, "add-ignore-case")).IsEqualTo("RegexOptions.IgnoreCase"); + _ = await Assert.That(Replacement(mutations, "add-right-to-left")).IsEqualTo("RegexOptions.RightToLeft"); + _ = await Assert + .That(Rewrite(tree, Single(mutations, "add-ignore-case"))) + .IsEqualTo( + NoneSource.Replace("RegexOptions.None", "RegexOptions.IgnoreCase", StringComparison.Ordinal) + ); + } } /// @@ -511,16 +540,19 @@ public async Task CreateMutations_NoneCombinedWithFlags_DropsTheRedundantNone() { var (_, mutations) = Mutate(NoneCombinedSource); - _ = await Assert - .That(Suffixes(mutations)) - .IsEqualTo( - "remove-ignore-case, remove-multiline, add-culture-invariant, add-singleline, " - + "add-explicit-capture, add-ignore-pattern-whitespace, add-right-to-left" - ); - _ = await Assert.That(Replacement(mutations, "remove-ignore-case")).IsEqualTo("RegexOptions.Multiline"); - _ = await Assert - .That(Replacement(mutations, "add-singleline")) - .IsEqualTo("RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.Singleline"); + using (Assert.Multiple()) + { + _ = await Assert + .That(Suffixes(mutations)) + .IsEqualTo( + "remove-ignore-case, remove-multiline, add-culture-invariant, add-singleline, " + + "add-explicit-capture, add-ignore-pattern-whitespace, add-right-to-left" + ); + _ = await Assert.That(Replacement(mutations, "remove-ignore-case")).IsEqualTo("RegexOptions.Multiline"); + _ = await Assert + .That(Replacement(mutations, "add-singleline")) + .IsEqualTo("RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.Singleline"); + } } /// @@ -533,11 +565,14 @@ public async Task CreateMutations_CompiledFlag_IsNeitherAddedNorRemoved() var (_, mutations) = Mutate(CompiledSource); var offenders = Mentioning(mutations, "Compiled"); - _ = await Assert.That(offenders).IsEmpty(); - _ = await Assert.That(Suffixes(mutations)).IsEqualTo(Join(_allAdditionSuffixes)); - _ = await Assert - .That(Replacement(mutations, "add-ignore-case")) - .IsEqualTo("RegexOptions.Compiled | RegexOptions.IgnoreCase"); + using (Assert.Multiple()) + { + _ = await Assert.That(offenders).IsEmpty(); + _ = await Assert.That(Suffixes(mutations)).IsEqualTo(Join(_allAdditionSuffixes)); + _ = await Assert + .That(Replacement(mutations, "add-ignore-case")) + .IsEqualTo("RegexOptions.Compiled | RegexOptions.IgnoreCase"); + } } /// @@ -551,12 +586,15 @@ public async Task CreateMutations_EcmaScriptFlag_IsNeitherAddedNorRemoved() var (_, mutations) = Mutate(EcmaScriptSource); var offenders = Mentioning(mutations, "ECMAScript"); - _ = await Assert.That(offenders).IsEmpty(); - _ = await Assert.That(Suffixes(mutations)).IsEqualTo(Join(_singleFlagSuffixes)); - _ = await Assert.That(Replacement(mutations, "remove-ignore-case")).IsEqualTo("RegexOptions.ECMAScript"); - _ = await Assert - .That(Replacement(mutations, "add-multiline")) - .IsEqualTo("RegexOptions.ECMAScript | RegexOptions.IgnoreCase | RegexOptions.Multiline"); + using (Assert.Multiple()) + { + _ = await Assert.That(offenders).IsEmpty(); + _ = await Assert.That(Suffixes(mutations)).IsEqualTo(Join(_singleFlagSuffixes)); + _ = await Assert.That(Replacement(mutations, "remove-ignore-case")).IsEqualTo("RegexOptions.ECMAScript"); + _ = await Assert + .That(Replacement(mutations, "add-multiline")) + .IsEqualTo("RegexOptions.ECMAScript | RegexOptions.IgnoreCase | RegexOptions.Multiline"); + } } #if NET7_0_OR_GREATER @@ -578,12 +616,15 @@ public async Task CreateMutations_NonBacktrackingFlag_IsNeitherAddedNorRemoved() var (_, mutations) = Mutate(NonBacktrackingSource); var offenders = Mentioning(mutations, "NonBacktracking"); - _ = await Assert.That(CompilationFactory.GetCompileErrors(compilation)).IsEmpty(); - _ = await Assert.That(offenders).IsEmpty(); - _ = await Assert.That(Suffixes(mutations)).IsEqualTo(Join(_allAdditionSuffixes)); - _ = await Assert - .That(Replacement(mutations, "add-ignore-case")) - .IsEqualTo("RegexOptions.NonBacktracking | RegexOptions.IgnoreCase"); + using (Assert.Multiple()) + { + _ = await Assert.That(CompilationFactory.GetCompileErrors(compilation)).IsEmpty(); + _ = await Assert.That(offenders).IsEmpty(); + _ = await Assert.That(Suffixes(mutations)).IsEqualTo(Join(_allAdditionSuffixes)); + _ = await Assert + .That(Replacement(mutations, "add-ignore-case")) + .IsEqualTo("RegexOptions.NonBacktracking | RegexOptions.IgnoreCase"); + } } /// @@ -602,16 +643,19 @@ public async Task CreateMutations_GeneratedRegexAttributeArgument_IsMutated() { var (tree, mutations) = Mutate(GeneratedRegexSource); - _ = await Assert.That(Suffixes(mutations)).IsEqualTo(Join(_singleFlagSuffixes)); - _ = await Assert - .That(Rewrite(tree, Single(mutations, "add-culture-invariant"))) - .IsEqualTo( - GeneratedRegexSource.Replace( - "RegexOptions.IgnoreCase", - "RegexOptions.IgnoreCase | RegexOptions.CultureInvariant", - StringComparison.Ordinal - ) - ); + using (Assert.Multiple()) + { + _ = await Assert.That(Suffixes(mutations)).IsEqualTo(Join(_singleFlagSuffixes)); + _ = await Assert + .That(Rewrite(tree, Single(mutations, "add-culture-invariant"))) + .IsEqualTo( + GeneratedRegexSource.Replace( + "RegexOptions.IgnoreCase", + "RegexOptions.IgnoreCase | RegexOptions.CultureInvariant", + StringComparison.Ordinal + ) + ); + } } #endif @@ -624,10 +668,13 @@ public async Task CreateMutations_AttributeArgument_IsMutated() { var (_, mutations) = Mutate(CustomAttributeSource); - _ = await Assert.That(Suffixes(mutations)).IsEqualTo(Join(_singleFlagSuffixes)); - _ = await Assert - .That(Replacement(mutations, "add-multiline")) - .IsEqualTo("RegexOptions.IgnoreCase | RegexOptions.Multiline"); + using (Assert.Multiple()) + { + _ = await Assert.That(Suffixes(mutations)).IsEqualTo(Join(_singleFlagSuffixes)); + _ = await Assert + .That(Replacement(mutations, "add-multiline")) + .IsEqualTo("RegexOptions.IgnoreCase | RegexOptions.Multiline"); + } } /// @@ -640,8 +687,11 @@ public async Task CreateMutations_ConstantFieldInitializer_IsMutated() var (tree, mutations) = Mutate(ConstantFieldSource); var mutated = Rewrite(tree, Single(mutations, "add-multiline")); - _ = await Assert.That(Suffixes(mutations)).IsEqualTo(Join(_singleFlagSuffixes)); - _ = await Assert.That(CompilationFactory.GetCompileErrors(CompilationFactory.Create(mutated))).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(Suffixes(mutations)).IsEqualTo(Join(_singleFlagSuffixes)); + _ = await Assert.That(CompilationFactory.GetCompileErrors(CompilationFactory.Create(mutated))).IsEmpty(); + } } /// @@ -653,16 +703,19 @@ public async Task CreateMutations_FullyQualifiedFlag_KeepsTheQualifier() { var (_, mutations) = Mutate(QualifiedSource); - _ = await Assert.That(Suffixes(mutations)).IsEqualTo(Join(_singleFlagSuffixes)); - _ = await Assert - .That(Replacement(mutations, "remove-ignore-case")) - .IsEqualTo("System.Text.RegularExpressions.RegexOptions.None"); - _ = await Assert - .That(Replacement(mutations, "add-multiline")) - .IsEqualTo( - "System.Text.RegularExpressions.RegexOptions.IgnoreCase " - + "| System.Text.RegularExpressions.RegexOptions.Multiline" - ); + using (Assert.Multiple()) + { + _ = await Assert.That(Suffixes(mutations)).IsEqualTo(Join(_singleFlagSuffixes)); + _ = await Assert + .That(Replacement(mutations, "remove-ignore-case")) + .IsEqualTo("System.Text.RegularExpressions.RegexOptions.None"); + _ = await Assert + .That(Replacement(mutations, "add-multiline")) + .IsEqualTo( + "System.Text.RegularExpressions.RegexOptions.IgnoreCase " + + "| System.Text.RegularExpressions.RegexOptions.Multiline" + ); + } } /// @@ -693,16 +746,19 @@ public async Task CreateMutations_BareFlagNames_KeepTheBareSpelling() { var (_, mutations) = Mutate(UsingStaticSource); - _ = await Assert - .That(Suffixes(mutations)) - .IsEqualTo( - "remove-ignore-case, remove-multiline, add-culture-invariant, add-singleline, " - + "add-explicit-capture, add-ignore-pattern-whitespace, add-right-to-left" - ); - _ = await Assert.That(Replacement(mutations, "remove-ignore-case")).IsEqualTo("Multiline"); - _ = await Assert - .That(Replacement(mutations, "add-singleline")) - .IsEqualTo("IgnoreCase | Multiline | Singleline"); + using (Assert.Multiple()) + { + _ = await Assert + .That(Suffixes(mutations)) + .IsEqualTo( + "remove-ignore-case, remove-multiline, add-culture-invariant, add-singleline, " + + "add-explicit-capture, add-ignore-pattern-whitespace, add-right-to-left" + ); + _ = await Assert.That(Replacement(mutations, "remove-ignore-case")).IsEqualTo("Multiline"); + _ = await Assert + .That(Replacement(mutations, "add-singleline")) + .IsEqualTo("IgnoreCase | Multiline | Singleline"); + } } /// @@ -714,10 +770,13 @@ public async Task CreateMutations_ParenthesizedOperand_IsTreatedLikeTheBareOpera { var (_, mutations) = Mutate(ParenthesizedSource); - _ = await Assert.That(Replacement(mutations, "remove-multiline")).IsEqualTo("RegexOptions.IgnoreCase"); - _ = await Assert - .That(Replacement(mutations, "add-singleline")) - .IsEqualTo("RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.Singleline"); + using (Assert.Multiple()) + { + _ = await Assert.That(Replacement(mutations, "remove-multiline")).IsEqualTo("RegexOptions.IgnoreCase"); + _ = await Assert + .That(Replacement(mutations, "add-singleline")) + .IsEqualTo("RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.Singleline"); + } } /// @@ -757,11 +816,14 @@ public async Task CreateMutations_SameNamedEnumOfAnotherNamespace_ReturnsEmpty() var mutations = mutator.CreateMutations(node, semanticModel, CancellationToken.None).ToArray(); var bound = semanticModel.GetTypeInfo(node).Type; - _ = await Assert.That(bound?.ToDisplayString()).IsEqualTo("Fixtures.RegexOptions"); - _ = await Assert - .That(compilation.GetTypeByMetadataName("System.Text.RegularExpressions.RegexOptions")) - .IsNotNull(); - _ = await Assert.That(mutations).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(bound?.ToDisplayString()).IsEqualTo("Fixtures.RegexOptions"); + _ = await Assert + .That(compilation.GetTypeByMetadataName("System.Text.RegularExpressions.RegexOptions")) + .IsNotNull(); + _ = await Assert.That(mutations).IsEmpty(); + } } [Test] @@ -818,10 +880,13 @@ public async Task CreateMutations_MultiLineCombination_IsRebuiltOnASingleLine() var (tree, mutations) = Mutate(MultiLineCombinationSource); var mutated = Rewrite(tree, Single(mutations, "add-singleline")); - _ = await Assert.That(Replacement(mutations, "add-singleline")).IsEqualTo(collapsed); - _ = await Assert.That(Mentions(mutated, "/*!*/" + collapsed)).IsTrue(); - _ = await Assert.That(Mentions(mutated, "internal static Regex Create() =>")).IsTrue(); - _ = await Assert.That(CompilationFactory.GetCompileErrors(CompilationFactory.Create(mutated))).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(Replacement(mutations, "add-singleline")).IsEqualTo(collapsed); + _ = await Assert.That(Mentions(mutated, "/*!*/" + collapsed)).IsTrue(); + _ = await Assert.That(Mentions(mutated, "internal static Regex Create() =>")).IsTrue(); + _ = await Assert.That(CompilationFactory.GetCompileErrors(CompilationFactory.Create(mutated))).IsEmpty(); + } } [Test] diff --git a/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/RelationalOperatorMutatorTests.cs b/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/RelationalOperatorMutatorTests.cs index 00bde5f..8423394 100644 --- a/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/RelationalOperatorMutatorTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/RelationalOperatorMutatorTests.cs @@ -64,8 +64,11 @@ public async Task SupportedSyntaxKinds_Always_AreTheFourRelationalKinds() [Test] public async Task Metadata_Always_IdentifiesTheRelationalFamily() { - _ = await Assert.That(_mutator.Id).IsEqualTo("relational"); - _ = await Assert.That(_mutator.Kind).IsEqualTo(MutationKind.RelationalOperator); + using (Assert.Multiple()) + { + _ = await Assert.That(_mutator.Id).IsEqualTo("relational"); + _ = await Assert.That(_mutator.Kind).IsEqualTo(MutationKind.RelationalOperator); + } } [Test] @@ -83,8 +86,11 @@ string third string[] expected = [first, second, third]; var (mutations, _, _, errors) = Mutate(CreateSource(source)); - _ = await Assert.That(errors).IsEqualTo(string.Empty); - _ = await Assert.That(DisplayNames(mutations)).IsEquivalentTo(expected); + using (Assert.Multiple()) + { + _ = await Assert.That(errors).IsEqualTo(string.Empty); + _ = await Assert.That(DisplayNames(mutations)).IsEquivalentTo(expected); + } } [Test] @@ -109,8 +115,11 @@ string expectedId var (mutations, _, _, _) = Mutate(CreateSource(source)); var mutation = Single(mutations, $"{source} => {target}"); - _ = await Assert.That(mutation.OperatorId).IsEqualTo(expectedId); - _ = await Assert.That(mutation.Kind).IsEqualTo(MutationKind.RelationalOperator); + using (Assert.Multiple()) + { + _ = await Assert.That(mutation.OperatorId).IsEqualTo(expectedId); + _ = await Assert.That(mutation.Kind).IsEqualTo(MutationKind.RelationalOperator); + } } [Test] @@ -121,9 +130,12 @@ public async Task CreateMutations_RelationalExpression_ReplacesTheWholeCompariso foreach (var mutation in mutations) { - _ = await Assert.That(mutation.Original.Span).IsEqualTo(binary.Span); - _ = await Assert.That(mutation.Original.ToString()).IsEqualTo("left < right"); - _ = await Assert.That(mutation.Location.GetLineSpan().StartLinePosition.Line).IsEqualTo(2); + using (Assert.Multiple()) + { + _ = await Assert.That(mutation.Original.Span).IsEqualTo(binary.Span); + _ = await Assert.That(mutation.Original.ToString()).IsEqualTo("left < right"); + _ = await Assert.That(mutation.Location.GetLineSpan().StartLinePosition.Line).IsEqualTo(2); + } } } @@ -137,8 +149,11 @@ public async Task ApplyTo_BoundaryFlip_KeepsTheSurroundingTrivia(string target, var (mutations, tree, _, errors) = Mutate(TriviaSource); var mutation = Single(mutations, $"< => {target}"); - _ = await Assert.That(errors).IsEqualTo(string.Empty); - _ = await Assert.That(mutation.ApplyTo(tree).ToString()).IsEqualTo(expected); + using (Assert.Multiple()) + { + _ = await Assert.That(errors).IsEqualTo(string.Empty); + _ = await Assert.That(mutation.ApplyTo(tree).ToString()).IsEqualTo(expected); + } } [Test] @@ -160,8 +175,11 @@ public async Task CreateMutations_EqualityExpression_ReturnsEmpty() { var (mutations, _, _, errors) = Mutate(EqualitySource); - _ = await Assert.That(errors).IsEqualTo(string.Empty); - _ = await Assert.That(mutations.ToArray()).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(errors).IsEqualTo(string.Empty); + _ = await Assert.That(mutations.ToArray()).IsEmpty(); + } } private static string CreateSource(string source) => diff --git a/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/StringComparerMutatorTests.cs b/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/StringComparerMutatorTests.cs index 870572b..c8fd793 100644 --- a/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/StringComparerMutatorTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/StringComparerMutatorTests.cs @@ -362,9 +362,12 @@ public async Task CreateMutations_EveryComparer_ProducesTheFiveOtherComparers(st { var (_, mutations) = Run(Fixture(member)); - _ = await Assert.That(Ids(mutations)).IsEqualTo(expected); - _ = await Assert.That(Targets(mutations)).IsEqualTo(Others(member)); - _ = await Assert.That(mutations.All(mutation => mutation.Kind == MutationKind.StringComparer)).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(Ids(mutations)).IsEqualTo(expected); + _ = await Assert.That(Targets(mutations)).IsEqualTo(Others(member)); + _ = await Assert.That(mutations.All(mutation => mutation.Kind == MutationKind.StringComparer)).IsTrue(); + } } /// @@ -417,8 +420,11 @@ public async Task CreateMutations_VariableInitialiser_IsMutated() var expected = Swap(VariableInitialiserSource, "StringComparer.Ordinal", "StringComparer.OrdinalIgnoreCase"); var (tree, mutations) = Run(VariableInitialiserSource); - _ = await Assert.That(Targets(mutations)).IsEqualTo(Others("Ordinal")); - _ = await Assert.That(Rewrite(tree, MutationTo(mutations, "OrdinalIgnoreCase"))).IsEqualTo(expected); + using (Assert.Multiple()) + { + _ = await Assert.That(Targets(mutations)).IsEqualTo(Others("Ordinal")); + _ = await Assert.That(Rewrite(tree, MutationTo(mutations, "OrdinalIgnoreCase"))).IsEqualTo(expected); + } } [Test] @@ -427,8 +433,11 @@ public async Task CreateMutations_SwitchExpressionArmResult_IsMutated() var expected = Swap(SwitchArmSource, "/*!*/StringComparer.Ordinal", "/*!*/StringComparer.InvariantCulture"); var (tree, mutations) = Run(SwitchArmSource, SyntaxNodeLocator.FindMarked); - _ = await Assert.That(Targets(mutations)).IsEqualTo(Others("Ordinal")); - _ = await Assert.That(Rewrite(tree, MutationTo(mutations, "InvariantCulture"))).IsEqualTo(expected); + using (Assert.Multiple()) + { + _ = await Assert.That(Targets(mutations)).IsEqualTo(Others("Ordinal")); + _ = await Assert.That(Rewrite(tree, MutationTo(mutations, "InvariantCulture"))).IsEqualTo(expected); + } } [Test] @@ -437,8 +446,11 @@ public async Task CreateMutations_NullableContext_IsMutated() var expected = Swap(NullableSource, "StringComparer.Ordinal", "StringComparer.CurrentCulture"); var (tree, mutations) = Run(NullableSource); - _ = await Assert.That(Targets(mutations)).IsEqualTo(Others("Ordinal")); - _ = await Assert.That(Rewrite(tree, MutationTo(mutations, "CurrentCulture"))).IsEqualTo(expected); + using (Assert.Multiple()) + { + _ = await Assert.That(Targets(mutations)).IsEqualTo(Others("Ordinal")); + _ = await Assert.That(Rewrite(tree, MutationTo(mutations, "CurrentCulture"))).IsEqualTo(expected); + } } [Test] @@ -451,8 +463,11 @@ public async Task CreateMutations_FullyQualifiedName_KeepsTheQualification() ); var (tree, mutations) = Run(FullyQualifiedSource); - _ = await Assert.That(Targets(mutations)).IsEqualTo(Others("Ordinal")); - _ = await Assert.That(Rewrite(tree, MutationTo(mutations, "CurrentCulture"))).IsEqualTo(expected); + using (Assert.Multiple()) + { + _ = await Assert.That(Targets(mutations)).IsEqualTo(Others("Ordinal")); + _ = await Assert.That(Rewrite(tree, MutationTo(mutations, "CurrentCulture"))).IsEqualTo(expected); + } } /// @@ -478,9 +493,12 @@ public async Task CreateMutations_AliasedTypeName_IsMutatedAndKeepsTheAlias() var (tree, mutations) = Run(AliasSource); var rewritten = Rewrite(tree, MutationTo(mutations, "CurrentCulture")); - _ = await Assert.That(Targets(mutations)).IsEqualTo(Others("Ordinal")); - _ = await Assert.That(rewritten).Contains("Comparer.CurrentCulture"); - _ = await Assert.That(rewritten).IsEqualTo(expected); + using (Assert.Multiple()) + { + _ = await Assert.That(Targets(mutations)).IsEqualTo(Others("Ordinal")); + _ = await Assert.That(rewritten).Contains("Comparer.CurrentCulture"); + _ = await Assert.That(rewritten).IsEqualTo(expected); + } } /// @@ -495,8 +513,11 @@ public async Task CreateMutations_PropertyImportedByUsingStatic_ReturnsEmpty() var mutator = new StringComparerMutator(); var (_, mutations) = Run(UsingStaticSource, FindImportedMember); - _ = await Assert.That(mutator.SupportedSyntaxKinds.Contains(SyntaxKind.IdentifierName)).IsFalse(); - _ = await Assert.That(mutations).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(mutator.SupportedSyntaxKinds.Contains(SyntaxKind.IdentifierName)).IsFalse(); + _ = await Assert.That(mutations).IsEmpty(); + } } /// @@ -509,8 +530,11 @@ public async Task CreateMutations_CommentInsideTheAccess_KeepsTheTrivia() var (tree, mutations) = Run(TriviaInsideAccessSource); var rewritten = Rewrite(tree, MutationTo(mutations, "CurrentCulture")); - _ = await Assert.That(rewritten).Contains("StringComparer. /* pinned */ CurrentCulture"); - _ = await Assert.That(rewritten).IsEqualTo(expected); + using (Assert.Multiple()) + { + _ = await Assert.That(rewritten).Contains("StringComparer. /* pinned */ CurrentCulture"); + _ = await Assert.That(rewritten).IsEqualTo(expected); + } } [Test] @@ -531,8 +555,11 @@ public async Task CreateMutations_AccessUsedAsReceiver_IsMutated() var expected = Swap(ReceiverSource, "StringComparer.Ordinal.", "StringComparer.CurrentCulture."); var (tree, mutations) = Run(ReceiverSource); - _ = await Assert.That(Targets(mutations)).IsEqualTo(Others("Ordinal")); - _ = await Assert.That(Rewrite(tree, MutationTo(mutations, "CurrentCulture"))).IsEqualTo(expected); + using (Assert.Multiple()) + { + _ = await Assert.That(Targets(mutations)).IsEqualTo(Others("Ordinal")); + _ = await Assert.That(Rewrite(tree, MutationTo(mutations, "CurrentCulture"))).IsEqualTo(expected); + } } /// diff --git a/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/StringComparisonMutatorTests.cs b/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/StringComparisonMutatorTests.cs index f1955a3..64c4d4d 100644 --- a/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/StringComparisonMutatorTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/StringComparisonMutatorTests.cs @@ -367,9 +367,12 @@ public async Task CreateMutations_EveryMember_ProducesTheFiveOtherMembers(string { var (_, mutations) = Run(Fixture(member)); - _ = await Assert.That(Ids(mutations)).IsEqualTo(expected); - _ = await Assert.That(Targets(mutations)).IsEqualTo(Others(member)); - _ = await Assert.That(mutations.All(mutation => mutation.Kind == MutationKind.StringComparison)).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(Ids(mutations)).IsEqualTo(expected); + _ = await Assert.That(Targets(mutations)).IsEqualTo(Others(member)); + _ = await Assert.That(mutations.All(mutation => mutation.Kind == MutationKind.StringComparison)).IsTrue(); + } } /// @@ -426,8 +429,11 @@ public async Task CreateMutations_VariableInitialiser_IsMutated() ); var (tree, mutations) = Run(VariableInitialiserSource); - _ = await Assert.That(Targets(mutations)).IsEqualTo(Others("Ordinal")); - _ = await Assert.That(Rewrite(tree, MutationTo(mutations, "OrdinalIgnoreCase"))).IsEqualTo(expected); + using (Assert.Multiple()) + { + _ = await Assert.That(Targets(mutations)).IsEqualTo(Others("Ordinal")); + _ = await Assert.That(Rewrite(tree, MutationTo(mutations, "OrdinalIgnoreCase"))).IsEqualTo(expected); + } } /// @@ -440,8 +446,11 @@ public async Task CreateMutations_SwitchExpressionArmResult_IsMutated() var expected = Swap(SwitchArmSource, "/*!*/StringComparison.Ordinal", "/*!*/StringComparison.InvariantCulture"); var (tree, mutations) = Run(SwitchArmSource, SyntaxNodeLocator.FindMarked); - _ = await Assert.That(Targets(mutations)).IsEqualTo(Others("Ordinal")); - _ = await Assert.That(Rewrite(tree, MutationTo(mutations, "InvariantCulture"))).IsEqualTo(expected); + using (Assert.Multiple()) + { + _ = await Assert.That(Targets(mutations)).IsEqualTo(Others("Ordinal")); + _ = await Assert.That(Rewrite(tree, MutationTo(mutations, "InvariantCulture"))).IsEqualTo(expected); + } } [Test] @@ -450,8 +459,11 @@ public async Task CreateMutations_NullableContext_IsMutated() var expected = Swap(NullableSource, "StringComparison.Ordinal", "StringComparison.CurrentCulture"); var (tree, mutations) = Run(NullableSource); - _ = await Assert.That(Targets(mutations)).IsEqualTo(Others("Ordinal")); - _ = await Assert.That(Rewrite(tree, MutationTo(mutations, "CurrentCulture"))).IsEqualTo(expected); + using (Assert.Multiple()) + { + _ = await Assert.That(Targets(mutations)).IsEqualTo(Others("Ordinal")); + _ = await Assert.That(Rewrite(tree, MutationTo(mutations, "CurrentCulture"))).IsEqualTo(expected); + } } [Test] @@ -464,8 +476,11 @@ public async Task CreateMutations_FullyQualifiedName_KeepsTheQualification() ); var (tree, mutations) = Run(FullyQualifiedSource); - _ = await Assert.That(Targets(mutations)).IsEqualTo(Others("Ordinal")); - _ = await Assert.That(Rewrite(tree, MutationTo(mutations, "CurrentCulture"))).IsEqualTo(expected); + using (Assert.Multiple()) + { + _ = await Assert.That(Targets(mutations)).IsEqualTo(Others("Ordinal")); + _ = await Assert.That(Rewrite(tree, MutationTo(mutations, "CurrentCulture"))).IsEqualTo(expected); + } } /// @@ -491,9 +506,12 @@ public async Task CreateMutations_AliasedTypeName_IsMutatedAndKeepsTheAlias() var (tree, mutations) = Run(AliasSource); var rewritten = Rewrite(tree, MutationTo(mutations, "CurrentCulture")); - _ = await Assert.That(Targets(mutations)).IsEqualTo(Others("Ordinal")); - _ = await Assert.That(rewritten).Contains("Comparison.CurrentCulture"); - _ = await Assert.That(rewritten).IsEqualTo(expected); + using (Assert.Multiple()) + { + _ = await Assert.That(Targets(mutations)).IsEqualTo(Others("Ordinal")); + _ = await Assert.That(rewritten).Contains("Comparison.CurrentCulture"); + _ = await Assert.That(rewritten).IsEqualTo(expected); + } } /// @@ -508,8 +526,11 @@ public async Task CreateMutations_MemberImportedByUsingStatic_ReturnsEmpty() var mutator = new StringComparisonMutator(); var (_, mutations) = Run(UsingStaticSource, FindImportedMember); - _ = await Assert.That(mutator.SupportedSyntaxKinds.Contains(SyntaxKind.IdentifierName)).IsFalse(); - _ = await Assert.That(mutations).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(mutator.SupportedSyntaxKinds.Contains(SyntaxKind.IdentifierName)).IsFalse(); + _ = await Assert.That(mutations).IsEmpty(); + } } /// @@ -522,8 +543,11 @@ public async Task CreateMutations_CommentInsideTheAccess_KeepsTheTrivia() var (tree, mutations) = Run(TriviaInsideAccessSource); var rewritten = Rewrite(tree, MutationTo(mutations, "CurrentCulture")); - _ = await Assert.That(rewritten).Contains("StringComparison. /* pinned */ CurrentCulture"); - _ = await Assert.That(rewritten).IsEqualTo(expected); + using (Assert.Multiple()) + { + _ = await Assert.That(rewritten).Contains("StringComparison. /* pinned */ CurrentCulture"); + _ = await Assert.That(rewritten).IsEqualTo(expected); + } } [Test] @@ -544,8 +568,11 @@ public async Task CreateMutations_AccessUsedAsReceiver_IsMutated() var expected = Swap(ReceiverSource, "StringComparison.Ordinal.", "StringComparison.CurrentCulture."); var (tree, mutations) = Run(ReceiverSource); - _ = await Assert.That(Targets(mutations)).IsEqualTo(Others("Ordinal")); - _ = await Assert.That(Rewrite(tree, MutationTo(mutations, "CurrentCulture"))).IsEqualTo(expected); + using (Assert.Multiple()) + { + _ = await Assert.That(Targets(mutations)).IsEqualTo(Others("Ordinal")); + _ = await Assert.That(Rewrite(tree, MutationTo(mutations, "CurrentCulture"))).IsEqualTo(expected); + } } /// diff --git a/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/StringLiteralMutatorTests.cs b/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/StringLiteralMutatorTests.cs index c4b77d3..83dd435 100644 --- a/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/StringLiteralMutatorTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/StringLiteralMutatorTests.cs @@ -86,10 +86,13 @@ public async Task Metadata_Operator_DescribesStringLiteralFamily() var mutator = new StringLiteralMutator(); SyntaxKind[] supported = [.. mutator.SupportedSyntaxKinds]; - _ = await Assert.That(mutator.Id).IsEqualTo("string-literal"); - _ = await Assert.That(mutator.Kind).IsEqualTo(MutationKind.StringLiteral); - _ = await Assert.That(supported).Count().IsEqualTo(1); - _ = await Assert.That(supported).Contains(SyntaxKind.StringLiteralExpression); + using (Assert.Multiple()) + { + _ = await Assert.That(mutator.Id).IsEqualTo("string-literal"); + _ = await Assert.That(mutator.Kind).IsEqualTo(MutationKind.StringLiteral); + _ = await Assert.That(supported).Count().IsEqualTo(1); + _ = await Assert.That(supported).Contains(SyntaxKind.StringLiteralExpression); + } } [Test] @@ -97,11 +100,14 @@ public async Task CreateMutations_NonEmptyLiteral_ReplacesItByTheEmptyString() { var (tree, mutations) = Run(NonEmptySource); - _ = await Assert.That(mutations).Count().IsEqualTo(1); - _ = await Assert.That(mutations[0].Kind).IsEqualTo(MutationKind.StringLiteral); - _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("string-literal.to-empty"); - _ = await Assert.That(mutations[0].DisplayName).IsEqualTo("\"...\" => \"\""); - _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(EmptySource); + using (Assert.Multiple()) + { + _ = await Assert.That(mutations).Count().IsEqualTo(1); + _ = await Assert.That(mutations[0].Kind).IsEqualTo(MutationKind.StringLiteral); + _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("string-literal.to-empty"); + _ = await Assert.That(mutations[0].DisplayName).IsEqualTo("\"...\" => \"\""); + _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(EmptySource); + } } [Test] @@ -109,12 +115,15 @@ public async Task CreateMutations_EmptyLiteral_ReplacesItByANonEmptyString() { var (tree, mutations) = Run(EmptySource); - _ = await Assert.That(mutations).Count().IsEqualTo(1); - _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("string-literal.empty-to-non-empty"); - _ = await Assert.That(mutations[0].DisplayName).IsEqualTo("\"\" => \"FrameShift\""); - _ = await Assert - .That(Rewrite(tree, mutations[0])) - .IsEqualTo("public class Sample { public string Get() => \"FrameShift\"; }"); + using (Assert.Multiple()) + { + _ = await Assert.That(mutations).Count().IsEqualTo(1); + _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("string-literal.empty-to-non-empty"); + _ = await Assert.That(mutations[0].DisplayName).IsEqualTo("\"\" => \"FrameShift\""); + _ = await Assert + .That(Rewrite(tree, mutations[0])) + .IsEqualTo("public class Sample { public string Get() => \"FrameShift\"; }"); + } } [Test] @@ -122,9 +131,12 @@ public async Task CreateMutations_VerbatimLiteral_ReplacesItByAPlainEmptyLiteral { var (tree, mutations) = Run(VerbatimSource); - _ = await Assert.That(mutations).Count().IsEqualTo(1); - _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("string-literal.to-empty"); - _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(EmptySource); + using (Assert.Multiple()) + { + _ = await Assert.That(mutations).Count().IsEqualTo(1); + _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("string-literal.to-empty"); + _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(EmptySource); + } } /// @@ -137,11 +149,14 @@ public async Task CreateMutations_SingleLineRawLiteral_ReplacesItByAPlainEmptyLi var (tree, mutations) = Run(RawSource); var literal = (LiteralExpressionSyntax)FindStringLiteral(tree); - _ = await Assert.That(literal.Token.IsKind(SyntaxKind.SingleLineRawStringLiteralToken)).IsTrue(); - _ = await Assert.That(literal.Token.ValueText).IsEqualTo("abc"); - _ = await Assert.That(mutations).Count().IsEqualTo(1); - _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("string-literal.to-empty"); - _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(EmptySource); + using (Assert.Multiple()) + { + _ = await Assert.That(literal.Token.IsKind(SyntaxKind.SingleLineRawStringLiteralToken)).IsTrue(); + _ = await Assert.That(literal.Token.ValueText).IsEqualTo("abc"); + _ = await Assert.That(mutations).Count().IsEqualTo(1); + _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("string-literal.to-empty"); + _ = await Assert.That(Rewrite(tree, mutations[0])).IsEqualTo(EmptySource); + } } /// @@ -155,11 +170,14 @@ public async Task CreateMutations_MultiLineRawLiteral_ReplacesItByAPlainEmptyLit var (tree, mutations) = Run(MultiLineRawSource); var literal = (LiteralExpressionSyntax)FindStringLiteral(tree); - _ = await Assert.That(literal.Token.IsKind(SyntaxKind.MultiLineRawStringLiteralToken)).IsTrue(); - _ = await Assert.That(literal.Token.ValueText).IsEqualTo("abc"); - _ = await Assert.That(mutations).Count().IsEqualTo(1); - _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("string-literal.to-empty"); - _ = await Assert.That(mutations[0].Replacement.ToString()).IsEqualTo("\"\""); + using (Assert.Multiple()) + { + _ = await Assert.That(literal.Token.IsKind(SyntaxKind.MultiLineRawStringLiteralToken)).IsTrue(); + _ = await Assert.That(literal.Token.ValueText).IsEqualTo("abc"); + _ = await Assert.That(mutations).Count().IsEqualTo(1); + _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("string-literal.to-empty"); + _ = await Assert.That(mutations[0].Replacement.ToString()).IsEqualTo("\"\""); + } } /// @@ -173,8 +191,11 @@ public async Task CreateMutations_Utf8Literal_ReturnsEmpty() var literal = SyntaxNodeLocator.FindFirst(tree); var mutations = Mutate(new StringLiteralMutator(), literal, semanticModel); - _ = await Assert.That(literal.Kind()).IsEqualTo(SyntaxKind.Utf8StringLiteralExpression); - _ = await Assert.That(mutations).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(literal.Kind()).IsEqualTo(SyntaxKind.Utf8StringLiteralExpression); + _ = await Assert.That(mutations).IsEmpty(); + } } [Test] @@ -182,11 +203,14 @@ public async Task CreateMutations_NonConstantFieldInitializer_IsMutated() { var (tree, mutations) = Run(InstanceFieldSource); - _ = await Assert.That(mutations).Count().IsEqualTo(1); - _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("string-literal.to-empty"); - _ = await Assert - .That(Rewrite(tree, mutations[0])) - .IsEqualTo(InstanceFieldSource.Replace("\"abc\"", "\"\"", StringComparison.Ordinal)); + using (Assert.Multiple()) + { + _ = await Assert.That(mutations).Count().IsEqualTo(1); + _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("string-literal.to-empty"); + _ = await Assert + .That(Rewrite(tree, mutations[0])) + .IsEqualTo(InstanceFieldSource.Replace("\"abc\"", "\"\"", StringComparison.Ordinal)); + } } [Test] @@ -194,11 +218,14 @@ public async Task CreateMutations_NonConstantLocalDeclaration_IsMutated() { var (tree, mutations) = Run(LocalDeclarationSource); - _ = await Assert.That(mutations).Count().IsEqualTo(1); - _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("string-literal.to-empty"); - _ = await Assert - .That(Rewrite(tree, mutations[0])) - .IsEqualTo(LocalDeclarationSource.Replace("\"abc\"", "\"\"", StringComparison.Ordinal)); + using (Assert.Multiple()) + { + _ = await Assert.That(mutations).Count().IsEqualTo(1); + _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("string-literal.to-empty"); + _ = await Assert + .That(Rewrite(tree, mutations[0])) + .IsEqualTo(LocalDeclarationSource.Replace("\"abc\"", "\"\"", StringComparison.Ordinal)); + } } [Test] @@ -220,9 +247,12 @@ public async Task CreateMutations_InterpolatedString_ReturnsEmpty() .FindAll(tree) .Where(literal => literal.IsKind(SyntaxKind.StringLiteralExpression)); - _ = await Assert.That(literals).IsEmpty(); - _ = await Assert.That(Mutate(mutator, interpolated, semanticModel)).IsEmpty(); - _ = await Assert.That(Mutate(mutator, text, semanticModel)).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(literals).IsEmpty(); + _ = await Assert.That(Mutate(mutator, interpolated, semanticModel)).IsEmpty(); + _ = await Assert.That(Mutate(mutator, text, semanticModel)).IsEmpty(); + } } [Test] @@ -294,10 +324,13 @@ public async Task CreateMutations_DetachedLiteralWithoutParent_IsMutated() var literal = (LiteralExpressionSyntax)SyntaxFactory.ParseExpression("\"abc\""); var mutations = Mutate(new StringLiteralMutator(), literal, semanticModel); - _ = await Assert.That(literal.Parent).IsNull(); - _ = await Assert.That(literal.IsKind(SyntaxKind.StringLiteralExpression)).IsTrue(); - _ = await Assert.That(mutations.Length).IsEqualTo(1); - _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("string-literal.to-empty"); + using (Assert.Multiple()) + { + _ = await Assert.That(literal.Parent).IsNull(); + _ = await Assert.That(literal.IsKind(SyntaxKind.StringLiteralExpression)).IsTrue(); + _ = await Assert.That(mutations.Length).IsEqualTo(1); + _ = await Assert.That(mutations[0].OperatorId).IsEqualTo("string-literal.to-empty"); + } } private static (SyntaxTree Tree, Mutation[] Mutations) Run(string source) => Run(source, FindStringLiteral); diff --git a/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/UnaryOperatorMutatorTests.cs b/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/UnaryOperatorMutatorTests.cs index 03f0463..f8cc32f 100644 --- a/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/UnaryOperatorMutatorTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/Operators/UnaryOperatorMutatorTests.cs @@ -159,11 +159,14 @@ public async Task Metadata_Operator_ExposesIdKindAndSupportedKinds() { var mutator = new UnaryOperatorMutator(); - _ = await Assert.That(mutator.Id).IsEqualTo("unary"); - _ = await Assert.That(mutator.Kind).IsEqualTo(MutationKind.UnaryOperator); - _ = await Assert - .That(mutator.SupportedSyntaxKinds) - .IsEquivalentTo(new[] { SyntaxKind.UnaryMinusExpression, SyntaxKind.UnaryPlusExpression }); + using (Assert.Multiple()) + { + _ = await Assert.That(mutator.Id).IsEqualTo("unary"); + _ = await Assert.That(mutator.Kind).IsEqualTo(MutationKind.UnaryOperator); + _ = await Assert + .That(mutator.SupportedSyntaxKinds) + .IsEquivalentTo(new[] { SyntaxKind.UnaryMinusExpression, SyntaxKind.UnaryPlusExpression }); + } } [Test] @@ -188,15 +191,18 @@ string expectedDisplayNames var result = Mutate(Fixture(expression)); - _ = await Assert - .That(Sorted(result.Mutations.Select(mutation => mutation.OperatorId))) - .IsEquivalentTo(Sorted(SplitValues(expectedIds))); - _ = await Assert - .That(Sorted(result.Mutations.Select(mutation => mutation.DisplayName))) - .IsEquivalentTo(Sorted(SplitValues(expectedDisplayNames))); - _ = await Assert - .That(result.Mutations.Select(mutation => mutation.Kind).Distinct()) - .IsEquivalentTo(new[] { MutationKind.UnaryOperator }); + using (Assert.Multiple()) + { + _ = await Assert + .That(Sorted(result.Mutations.Select(mutation => mutation.OperatorId))) + .IsEquivalentTo(Sorted(SplitValues(expectedIds))); + _ = await Assert + .That(Sorted(result.Mutations.Select(mutation => mutation.DisplayName))) + .IsEquivalentTo(Sorted(SplitValues(expectedDisplayNames))); + _ = await Assert + .That(result.Mutations.Select(mutation => mutation.Kind).Distinct()) + .IsEquivalentTo(new[] { MutationKind.UnaryOperator }); + } } [Test] @@ -207,9 +213,12 @@ public async Task SupportedSyntaxKinds_EveryKind_IsHandledByCreateMutations(stri var mutator = new UnaryOperatorMutator(); var result = Mutate(Fixture(expression)); - _ = await Assert.That(result.Node.Kind()).IsEqualTo(kind); - _ = await Assert.That(mutator.SupportedSyntaxKinds).Contains(kind); - _ = await Assert.That(result.Mutations).Count().IsEqualTo(2); + using (Assert.Multiple()) + { + _ = await Assert.That(result.Node.Kind()).IsEqualTo(kind); + _ = await Assert.That(mutator.SupportedSyntaxKinds).Contains(kind); + _ = await Assert.That(result.Mutations).Count().IsEqualTo(2); + } } [Test] @@ -253,9 +262,12 @@ public async Task CreateMutations_Replacements_SwapTheSignAndDropTheOperator() var swap = Single(result.Mutations, "unary.negate-to-plus"); var removal = Single(result.Mutations, "unary.remove-negate"); - _ = await Assert.That(swap.Replacement.ToString()).IsEqualTo("+value"); - _ = await Assert.That(removal.Replacement.ToString()).IsEqualTo("value"); - _ = await Assert.That(removal.Original).IsEqualTo(result.Node); + using (Assert.Multiple()) + { + _ = await Assert.That(swap.Replacement.ToString()).IsEqualTo("+value"); + _ = await Assert.That(removal.Replacement.ToString()).IsEqualTo("value"); + _ = await Assert.That(removal.Original).IsEqualTo(result.Node); + } } [Test] @@ -266,12 +278,15 @@ public async Task ApplyTo_NegateToPlus_RewritesOperatorAndKeepsTrivia() var mutated = mutation.ApplyTo(result.Tree).ToString(); - _ = await Assert - .That(mutated) - .IsEqualTo(TriviaSource.Replace("- /* sign */", "+ /* sign */", StringComparison.Ordinal)); - _ = await Assert.That(mutated).Contains("// Inverts a value."); - _ = await Assert.That(mutated).Contains("/* leading */"); - _ = await Assert.That(mutated).Contains("return /*!*/+ /* sign */ value; // tail"); + using (Assert.Multiple()) + { + _ = await Assert + .That(mutated) + .IsEqualTo(TriviaSource.Replace("- /* sign */", "+ /* sign */", StringComparison.Ordinal)); + _ = await Assert.That(mutated).Contains("// Inverts a value."); + _ = await Assert.That(mutated).Contains("/* leading */"); + _ = await Assert.That(mutated).Contains("return /*!*/+ /* sign */ value; // tail"); + } } [Test] @@ -282,12 +297,15 @@ public async Task ApplyTo_RemoveNegate_DropsOperatorAndKeepsSurroundingComments( var mutated = mutation.ApplyTo(result.Tree).ToString(); - _ = await Assert - .That(mutated) - .IsEqualTo(TriviaSource.Replace("- /* sign */ value", "value", StringComparison.Ordinal)); - _ = await Assert.That(mutated).Contains("// Inverts a value."); - _ = await Assert.That(mutated).Contains("/* leading */"); - _ = await Assert.That(mutated).Contains("return /*!*/value; // tail"); + using (Assert.Multiple()) + { + _ = await Assert + .That(mutated) + .IsEqualTo(TriviaSource.Replace("- /* sign */ value", "value", StringComparison.Ordinal)); + _ = await Assert.That(mutated).Contains("// Inverts a value."); + _ = await Assert.That(mutated).Contains("/* leading */"); + _ = await Assert.That(mutated).Contains("return /*!*/value; // tail"); + } } [Test] @@ -297,12 +315,15 @@ public async Task CreateMutations_UserDefinedNegationWithoutUnaryPlus_ProducesOn string[] expectedDisplayNames = ["-x => x"]; var result = Mutate(NegateOnlyOperatorSource); - _ = await Assert - .That(Sorted(result.Mutations.Select(mutation => mutation.OperatorId))) - .IsEquivalentTo(expectedIds); - _ = await Assert - .That(Sorted(result.Mutations.Select(mutation => mutation.DisplayName))) - .IsEquivalentTo(expectedDisplayNames); + using (Assert.Multiple()) + { + _ = await Assert + .That(Sorted(result.Mutations.Select(mutation => mutation.OperatorId))) + .IsEquivalentTo(expectedIds); + _ = await Assert + .That(Sorted(result.Mutations.Select(mutation => mutation.DisplayName))) + .IsEquivalentTo(expectedDisplayNames); + } } [Test] @@ -323,12 +344,15 @@ public async Task CreateMutations_UserDefinedUnaryPlusWithoutNegation_ProducesOn string[] expectedDisplayNames = ["+x => x"]; var result = Mutate(PlusOnlyOperatorSource); - _ = await Assert - .That(Sorted(result.Mutations.Select(mutation => mutation.OperatorId))) - .IsEquivalentTo(expectedIds); - _ = await Assert - .That(Sorted(result.Mutations.Select(mutation => mutation.DisplayName))) - .IsEquivalentTo(expectedDisplayNames); + using (Assert.Multiple()) + { + _ = await Assert + .That(Sorted(result.Mutations.Select(mutation => mutation.OperatorId))) + .IsEquivalentTo(expectedIds); + _ = await Assert + .That(Sorted(result.Mutations.Select(mutation => mutation.DisplayName))) + .IsEquivalentTo(expectedDisplayNames); + } } [Test] @@ -354,12 +378,15 @@ public async Task CreateMutations_LiftedUserDefinedNegation_ProducesOnlyTheRemov var (_, semanticModel, tree) = CompilationFactory.CreateWithModel(NullableLiftedNegateOnlySource); var unary = SyntaxNodeLocator.FindMarked(tree); - _ = await Assert - .That(semanticModel.GetTypeInfo(unary.Operand).Type?.ToDisplayString()) - .IsEqualTo("Fixtures.Money?"); - _ = await Assert - .That(Sorted(result.Mutations.Select(mutation => mutation.OperatorId))) - .IsEquivalentTo(expectedIds); + using (Assert.Multiple()) + { + _ = await Assert + .That(semanticModel.GetTypeInfo(unary.Operand).Type?.ToDisplayString()) + .IsEqualTo("Fixtures.Money?"); + _ = await Assert + .That(Sorted(result.Mutations.Select(mutation => mutation.OperatorId))) + .IsEquivalentTo(expectedIds); + } } /// @@ -372,10 +399,13 @@ public async Task CreateMutations_MemberWithTheCounterpartNameThatIsNoOperator_P string[] expectedIds = ["unary.remove-negate"]; var result = Mutate(BorrowedOperatorNameSource); - _ = await Assert - .That(Sorted(result.Mutations.Select(mutation => mutation.OperatorId))) - .IsEquivalentTo(expectedIds); - _ = await Assert.That(result.Mutations[0].DisplayName).IsEqualTo("-x => x"); + using (Assert.Multiple()) + { + _ = await Assert + .That(Sorted(result.Mutations.Select(mutation => mutation.OperatorId))) + .IsEquivalentTo(expectedIds); + _ = await Assert.That(result.Mutations[0].DisplayName).IsEqualTo("-x => x"); + } } /// @@ -390,9 +420,14 @@ public async Task CreateMutations_LiteralOperandWithoutAConstantResult_ProducesB var (mutations, _, node, model) = MutateAllowingErrors(NonConstantLiteralSource); var unary = (PrefixUnaryExpressionSyntax)node; - _ = await Assert.That(model.GetConstantValue(unary).HasValue).IsFalse(); - _ = await Assert.That(model.GetConstantValue(unary.Operand).HasValue).IsTrue(); - _ = await Assert.That(Sorted(mutations.Select(mutation => mutation.OperatorId))).IsEquivalentTo(expectedIds); + using (Assert.Multiple()) + { + _ = await Assert.That(model.GetConstantValue(unary).HasValue).IsFalse(); + _ = await Assert.That(model.GetConstantValue(unary.Operand).HasValue).IsTrue(); + _ = await Assert + .That(Sorted(mutations.Select(mutation => mutation.OperatorId))) + .IsEquivalentTo(expectedIds); + } } [Test] diff --git a/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/RegularExpressions/RegexPatternLocatorTests.cs b/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/RegularExpressions/RegexPatternLocatorTests.cs index d2da215..d33c6fc 100644 --- a/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/RegularExpressions/RegexPatternLocatorTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/RegularExpressions/RegexPatternLocatorTests.cs @@ -418,13 +418,16 @@ public async Task TryLocate_RegexConstructorWithoutOptions_ReportsTheConstructor { var site = LocateInCall("_ = new Regex(/*!*/\"a+\");"); - _ = await Assert.That(site.Origin).IsEqualTo(RegexPatternOrigin.RegexConstructor); - _ = await Assert.That(site.Pattern).IsEqualTo("a+"); - _ = await Assert.That(site.AreOptionsKnown).IsTrue(); - _ = await Assert.That(site.Options!.Value).IsEqualTo(RegexOptions.None); - _ = await Assert.That(site.OptionsExpression).IsNull(); - _ = await Assert.That(site.AttributeArgument).IsNull(); - _ = await Assert.That(site.PatternLiteral.Token.ValueText).IsEqualTo("a+"); + using (Assert.Multiple()) + { + _ = await Assert.That(site.Origin).IsEqualTo(RegexPatternOrigin.RegexConstructor); + _ = await Assert.That(site.Pattern).IsEqualTo("a+"); + _ = await Assert.That(site.AreOptionsKnown).IsTrue(); + _ = await Assert.That(site.Options!.Value).IsEqualTo(RegexOptions.None); + _ = await Assert.That(site.OptionsExpression).IsNull(); + _ = await Assert.That(site.AttributeArgument).IsNull(); + _ = await Assert.That(site.PatternLiteral.Token.ValueText).IsEqualTo("a+"); + } } [Test] @@ -432,11 +435,14 @@ public async Task TryLocate_RegexConstructorWithOptions_ResolvesTheOptions() { var site = LocateInCall("_ = new Regex(/*!*/\"a+\", RegexOptions.IgnoreCase);"); - _ = await Assert.That(site.Origin).IsEqualTo(RegexPatternOrigin.RegexConstructor); - _ = await Assert.That(site.AreOptionsKnown).IsTrue(); - _ = await Assert.That(site.Options!.Value).IsEqualTo(RegexOptions.IgnoreCase); - _ = await Assert.That(site.OptionsExpression).IsNotNull(); - _ = await Assert.That(site.OptionsExpression!.ToString()).IsEqualTo("RegexOptions.IgnoreCase"); + using (Assert.Multiple()) + { + _ = await Assert.That(site.Origin).IsEqualTo(RegexPatternOrigin.RegexConstructor); + _ = await Assert.That(site.AreOptionsKnown).IsTrue(); + _ = await Assert.That(site.Options!.Value).IsEqualTo(RegexOptions.IgnoreCase); + _ = await Assert.That(site.OptionsExpression).IsNotNull(); + _ = await Assert.That(site.OptionsExpression!.ToString()).IsEqualTo("RegexOptions.IgnoreCase"); + } } /// @@ -452,10 +458,13 @@ public async Task TryLocate_RegexConstructorWithComposedOptionsAndTimeout_Combin + "TimeSpan.FromSeconds(1));" ); - _ = await Assert.That(site.AreOptionsKnown).IsTrue(); - _ = await Assert - .That(site.Options!.Value) - .IsEqualTo(RegexOptions.IgnorePatternWhitespace | RegexOptions.Multiline); + using (Assert.Multiple()) + { + _ = await Assert.That(site.AreOptionsKnown).IsTrue(); + _ = await Assert + .That(site.Options!.Value) + .IsEqualTo(RegexOptions.IgnorePatternWhitespace | RegexOptions.Multiline); + } } [Test] @@ -463,10 +472,13 @@ public async Task TryLocate_RegexConstructorWithNamedArguments_ResolvesPatternAn { var site = LocateInCall("_ = new Regex(options: RegexOptions.Multiline, pattern: /*!*/\"a+\");"); - _ = await Assert.That(site.Origin).IsEqualTo(RegexPatternOrigin.RegexConstructor); - _ = await Assert.That(site.Pattern).IsEqualTo("a+"); - _ = await Assert.That(site.AreOptionsKnown).IsTrue(); - _ = await Assert.That(site.Options!.Value).IsEqualTo(RegexOptions.Multiline); + using (Assert.Multiple()) + { + _ = await Assert.That(site.Origin).IsEqualTo(RegexPatternOrigin.RegexConstructor); + _ = await Assert.That(site.Pattern).IsEqualTo("a+"); + _ = await Assert.That(site.AreOptionsKnown).IsTrue(); + _ = await Assert.That(site.Options!.Value).IsEqualTo(RegexOptions.Multiline); + } } /// @@ -479,12 +491,15 @@ public async Task TryLocate_RegexConstructorWithNonConstantOptions_ReportsTheOpt { var site = LocateInCall("_ = new Regex(/*!*/\"a+\", runtimeOptions);"); - _ = await Assert.That(site.Origin).IsEqualTo(RegexPatternOrigin.RegexConstructor); - _ = await Assert.That(site.Pattern).IsEqualTo("a+"); - _ = await Assert.That(site.AreOptionsKnown).IsFalse(); - _ = await Assert.That(site.Options.HasValue).IsFalse(); - _ = await Assert.That(site.OptionsExpression).IsNotNull(); - _ = await Assert.That(site.OptionsExpression!.ToString()).IsEqualTo("runtimeOptions"); + using (Assert.Multiple()) + { + _ = await Assert.That(site.Origin).IsEqualTo(RegexPatternOrigin.RegexConstructor); + _ = await Assert.That(site.Pattern).IsEqualTo("a+"); + _ = await Assert.That(site.AreOptionsKnown).IsFalse(); + _ = await Assert.That(site.Options.HasValue).IsFalse(); + _ = await Assert.That(site.OptionsExpression).IsNotNull(); + _ = await Assert.That(site.OptionsExpression!.ToString()).IsEqualTo("runtimeOptions"); + } } [Test] @@ -492,8 +507,11 @@ public async Task TryLocate_ConstantOptionsField_ResolvesTheOptions() { var site = LocateSite(ConstantOptionsSource); - _ = await Assert.That(site.AreOptionsKnown).IsTrue(); - _ = await Assert.That(site.Options!.Value).IsEqualTo(RegexOptions.IgnoreCase | RegexOptions.Multiline); + using (Assert.Multiple()) + { + _ = await Assert.That(site.AreOptionsKnown).IsTrue(); + _ = await Assert.That(site.Options!.Value).IsEqualTo(RegexOptions.IgnoreCase | RegexOptions.Multiline); + } } /// @@ -505,10 +523,13 @@ public async Task TryLocate_NamedPatternArgumentAtItsOwnPosition_ResolvesPattern { var site = LocateInCall("_ = new Regex(pattern: /*!*/\"a+\", RegexOptions.Multiline);"); - _ = await Assert.That(site.Origin).IsEqualTo(RegexPatternOrigin.RegexConstructor); - _ = await Assert.That(site.Pattern).IsEqualTo("a+"); - _ = await Assert.That(site.AreOptionsKnown).IsTrue(); - _ = await Assert.That(site.Options!.Value).IsEqualTo(RegexOptions.Multiline); + using (Assert.Multiple()) + { + _ = await Assert.That(site.Origin).IsEqualTo(RegexPatternOrigin.RegexConstructor); + _ = await Assert.That(site.Pattern).IsEqualTo("a+"); + _ = await Assert.That(site.AreOptionsKnown).IsTrue(); + _ = await Assert.That(site.Options!.Value).IsEqualTo(RegexOptions.Multiline); + } } /// @@ -523,10 +544,13 @@ public async Task TryLocate_AllConstructorArgumentsNamedAndReordered_ResolvesPat + "pattern: /*!*/\"a+\");" ); - _ = await Assert.That(site.Origin).IsEqualTo(RegexPatternOrigin.RegexConstructor); - _ = await Assert.That(site.Pattern).IsEqualTo("a+"); - _ = await Assert.That(site.AreOptionsKnown).IsTrue(); - _ = await Assert.That(site.Options!.Value).IsEqualTo(RegexOptions.Multiline); + using (Assert.Multiple()) + { + _ = await Assert.That(site.Origin).IsEqualTo(RegexPatternOrigin.RegexConstructor); + _ = await Assert.That(site.Pattern).IsEqualTo("a+"); + _ = await Assert.That(site.AreOptionsKnown).IsTrue(); + _ = await Assert.That(site.Options!.Value).IsEqualTo(RegexOptions.Multiline); + } } /// @@ -538,10 +562,13 @@ public async Task TryLocate_TargetTypedNew_ReportsTheConstructorOriginAndResolve { var site = LocateInCall("Regex regex = new(/*!*/\"a+\", RegexOptions.IgnoreCase);"); - _ = await Assert.That(site.Origin).IsEqualTo(RegexPatternOrigin.RegexConstructor); - _ = await Assert.That(site.Pattern).IsEqualTo("a+"); - _ = await Assert.That(site.AreOptionsKnown).IsTrue(); - _ = await Assert.That(site.Options!.Value).IsEqualTo(RegexOptions.IgnoreCase); + using (Assert.Multiple()) + { + _ = await Assert.That(site.Origin).IsEqualTo(RegexPatternOrigin.RegexConstructor); + _ = await Assert.That(site.Pattern).IsEqualTo("a+"); + _ = await Assert.That(site.AreOptionsKnown).IsTrue(); + _ = await Assert.That(site.Options!.Value).IsEqualTo(RegexOptions.IgnoreCase); + } } /// @@ -561,9 +588,12 @@ public async Task TryLocate_ConstantOptionsExpression_ResolvesTheFoldedValue(str { var site = LocateSite(CreateOptionsSource(options)); - _ = await Assert.That(site.AreOptionsKnown).IsTrue(); - _ = await Assert.That(site.Options!.Value).IsEqualTo(expected); - _ = await Assert.That(site.OptionsExpression!.ToString()).IsEqualTo(options); + using (Assert.Multiple()) + { + _ = await Assert.That(site.AreOptionsKnown).IsTrue(); + _ = await Assert.That(site.Options!.Value).IsEqualTo(expected); + _ = await Assert.That(site.OptionsExpression!.ToString()).IsEqualTo(options); + } } /// @@ -585,11 +615,14 @@ public async Task TryLocate_NonConstantOptionsExpression_ReportsTheOptionsAsUnkn { var site = LocateSite(CreateOptionsSource(options)); - _ = await Assert.That(site.Origin).IsEqualTo(RegexPatternOrigin.RegexConstructor); - _ = await Assert.That(site.Pattern).IsEqualTo("a+"); - _ = await Assert.That(site.AreOptionsKnown).IsFalse(); - _ = await Assert.That(site.Options.HasValue).IsFalse(); - _ = await Assert.That(site.OptionsExpression!.ToString()).IsEqualTo(options); + using (Assert.Multiple()) + { + _ = await Assert.That(site.Origin).IsEqualTo(RegexPatternOrigin.RegexConstructor); + _ = await Assert.That(site.Pattern).IsEqualTo("a+"); + _ = await Assert.That(site.AreOptionsKnown).IsFalse(); + _ = await Assert.That(site.Options.HasValue).IsFalse(); + _ = await Assert.That(site.OptionsExpression!.ToString()).IsEqualTo(options); + } } /// @@ -601,8 +634,11 @@ public async Task TryLocate_BaseConstructorInitializer_ReportsTheConstructorOrig { var site = LocateSite(BaseInitializerSource); - _ = await Assert.That(site.Origin).IsEqualTo(RegexPatternOrigin.RegexConstructor); - _ = await Assert.That(site.Pattern).IsEqualTo("a+"); + using (Assert.Multiple()) + { + _ = await Assert.That(site.Origin).IsEqualTo(RegexPatternOrigin.RegexConstructor); + _ = await Assert.That(site.Pattern).IsEqualTo("a+"); + } } [Test] @@ -620,11 +656,14 @@ public async Task TryLocate_StaticMethodSecondArgument_IsThePattern(string state { var site = LocateInCall(statement); - _ = await Assert.That(site.Origin).IsEqualTo(RegexPatternOrigin.RegexStaticMethod); - _ = await Assert.That(site.Pattern).IsEqualTo("a+"); - _ = await Assert.That(site.AreOptionsKnown).IsTrue(); - _ = await Assert.That(site.Options!.Value).IsEqualTo(RegexOptions.None); - _ = await Assert.That(site.OptionsExpression).IsNull(); + using (Assert.Multiple()) + { + _ = await Assert.That(site.Origin).IsEqualTo(RegexPatternOrigin.RegexStaticMethod); + _ = await Assert.That(site.Pattern).IsEqualTo("a+"); + _ = await Assert.That(site.AreOptionsKnown).IsTrue(); + _ = await Assert.That(site.Options!.Value).IsEqualTo(RegexOptions.None); + _ = await Assert.That(site.OptionsExpression).IsNull(); + } } [Test] @@ -645,9 +684,12 @@ public async Task TryLocate_StaticMethodWithOptions_ResolvesTheOptions(string st { var site = LocateInCall(statement); - _ = await Assert.That(site.Origin).IsEqualTo(RegexPatternOrigin.RegexStaticMethod); - _ = await Assert.That(site.AreOptionsKnown).IsTrue(); - _ = await Assert.That(site.Options!.Value).IsEqualTo(RegexOptions.Singleline); + using (Assert.Multiple()) + { + _ = await Assert.That(site.Origin).IsEqualTo(RegexPatternOrigin.RegexStaticMethod); + _ = await Assert.That(site.AreOptionsKnown).IsTrue(); + _ = await Assert.That(site.Options!.Value).IsEqualTo(RegexOptions.Singleline); + } } [Test] @@ -657,10 +699,13 @@ public async Task TryLocate_StaticMethodWithNamedArguments_ResolvesPatternAndOpt "_ = Regex.IsMatch(options: RegexOptions.RightToLeft, pattern: /*!*/\"a+\", input: input);" ); - _ = await Assert.That(site.Origin).IsEqualTo(RegexPatternOrigin.RegexStaticMethod); - _ = await Assert.That(site.Pattern).IsEqualTo("a+"); - _ = await Assert.That(site.AreOptionsKnown).IsTrue(); - _ = await Assert.That(site.Options!.Value).IsEqualTo(RegexOptions.RightToLeft); + using (Assert.Multiple()) + { + _ = await Assert.That(site.Origin).IsEqualTo(RegexPatternOrigin.RegexStaticMethod); + _ = await Assert.That(site.Pattern).IsEqualTo("a+"); + _ = await Assert.That(site.AreOptionsKnown).IsTrue(); + _ = await Assert.That(site.Options!.Value).IsEqualTo(RegexOptions.RightToLeft); + } } /// @@ -770,8 +815,11 @@ public async Task TryLocate_LateBoundInvocation_ReturnsNull() var site = RegexPatternLocator.TryLocate(node, semanticModel, CancellationToken.None); - _ = await Assert.That(semanticModel.GetSymbolInfo(invocation!).Symbol).IsNull(); - _ = await Assert.That(site).IsNull(); + using (Assert.Multiple()) + { + _ = await Assert.That(semanticModel.GetSymbolInfo(invocation!).Symbol).IsNull(); + _ = await Assert.That(site).IsNull(); + } } /// @@ -787,9 +835,12 @@ public async Task TryLocate_ArgumentThatBelongsToNoCall_ReturnsNull(string sourc var site = RegexPatternLocator.TryLocate(node, semanticModel, CancellationToken.None); - _ = await Assert.That(node.Parent is ArgumentSyntax).IsTrue(); - _ = await Assert.That(node.Parent!.Parent is ArgumentListSyntax).IsFalse(); - _ = await Assert.That(site).IsNull(); + using (Assert.Multiple()) + { + _ = await Assert.That(node.Parent is ArgumentSyntax).IsTrue(); + _ = await Assert.That(node.Parent!.Parent is ArgumentListSyntax).IsFalse(); + _ = await Assert.That(site).IsNull(); + } } /// @@ -807,9 +858,12 @@ public async Task TryLocate_DetachedArgumentList_ReturnsNull() var site = RegexPatternLocator.TryLocate(literal, semanticModel, CancellationToken.None); - _ = await Assert.That(literal.Parent is ArgumentSyntax).IsTrue(); - _ = await Assert.That(list.Parent).IsNull(); - _ = await Assert.That(site).IsNull(); + using (Assert.Multiple()) + { + _ = await Assert.That(literal.Parent is ArgumentSyntax).IsTrue(); + _ = await Assert.That(list.Parent).IsNull(); + _ = await Assert.That(site).IsNull(); + } } /// @@ -827,9 +881,12 @@ public async Task TryLocate_DetachedAttributeArgumentList_ReturnsNull() var site = RegexPatternLocator.TryLocate(literal, semanticModel, CancellationToken.None); - _ = await Assert.That(literal.Parent is AttributeArgumentSyntax).IsTrue(); - _ = await Assert.That(list.Parent).IsNull(); - _ = await Assert.That(site).IsNull(); + using (Assert.Multiple()) + { + _ = await Assert.That(literal.Parent is AttributeArgumentSyntax).IsTrue(); + _ = await Assert.That(list.Parent).IsNull(); + _ = await Assert.That(site).IsNull(); + } } /// @@ -864,9 +921,12 @@ public async Task TryLocate_VerbatimLiteral_ReportsTheTokenValueAndNotItsText() { var site = LocateSite(VerbatimPatternSource); - _ = await Assert.That(site.Pattern).IsEqualTo("\\d+\\s"); - _ = await Assert.That(site.PatternLiteral.Token.Text).IsEqualTo("@\"\\d+\\s\""); - _ = await Assert.That(site.PatternLiteral.Token.Text).IsNotEqualTo(site.Pattern); + using (Assert.Multiple()) + { + _ = await Assert.That(site.Pattern).IsEqualTo("\\d+\\s"); + _ = await Assert.That(site.PatternLiteral.Token.Text).IsEqualTo("@\"\\d+\\s\""); + _ = await Assert.That(site.PatternLiteral.Token.Text).IsNotEqualTo(site.Pattern); + } } [Test] @@ -874,9 +934,12 @@ public async Task TryLocate_RawStringLiteral_ReportsTheTokenValueAndNotItsText() { var site = LocateSite(RawStringPatternSource); - _ = await Assert.That(site.Pattern).IsEqualTo("\\d+\\s"); - _ = await Assert.That(site.PatternLiteral.Token.Text).IsEqualTo("\"\"\"\\d+\\s\"\"\""); - _ = await Assert.That(site.PatternLiteral.Token.Text).IsNotEqualTo(site.Pattern); + using (Assert.Multiple()) + { + _ = await Assert.That(site.Pattern).IsEqualTo("\\d+\\s"); + _ = await Assert.That(site.PatternLiteral.Token.Text).IsEqualTo("\"\"\"\\d+\\s\"\"\""); + _ = await Assert.That(site.PatternLiteral.Token.Text).IsNotEqualTo(site.Pattern); + } } #if NET7_0_OR_GREATER @@ -885,13 +948,16 @@ public async Task TryLocate_GeneratedRegexWithoutOptions_ReportsTheAttributeOrig { var site = LocateSite(CreateGeneratedRegexSource("[GeneratedRegex(/*!*/\"a+\")]")); - _ = await Assert.That(site.Origin).IsEqualTo(RegexPatternOrigin.GeneratedRegex); - _ = await Assert.That(site.Pattern).IsEqualTo("a+"); - _ = await Assert.That(site.AreOptionsKnown).IsTrue(); - _ = await Assert.That(site.Options!.Value).IsEqualTo(RegexOptions.None); - _ = await Assert.That(site.OptionsExpression).IsNull(); - _ = await Assert.That(site.AttributeArgument).IsNotNull(); - _ = await Assert.That(ReferenceEquals(site.AttributeArgument!.Expression, site.PatternLiteral)).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(site.Origin).IsEqualTo(RegexPatternOrigin.GeneratedRegex); + _ = await Assert.That(site.Pattern).IsEqualTo("a+"); + _ = await Assert.That(site.AreOptionsKnown).IsTrue(); + _ = await Assert.That(site.Options!.Value).IsEqualTo(RegexOptions.None); + _ = await Assert.That(site.OptionsExpression).IsNull(); + _ = await Assert.That(site.AttributeArgument).IsNotNull(); + _ = await Assert.That(ReferenceEquals(site.AttributeArgument!.Expression, site.PatternLiteral)).IsTrue(); + } } [Test] @@ -903,9 +969,14 @@ public async Task TryLocate_GeneratedRegexWithComposedOptions_CombinesTheFlags() ) ); - _ = await Assert.That(site.Origin).IsEqualTo(RegexPatternOrigin.GeneratedRegex); - _ = await Assert.That(site.AreOptionsKnown).IsTrue(); - _ = await Assert.That(site.Options!.Value).IsEqualTo(RegexOptions.IgnoreCase | RegexOptions.CultureInvariant); + using (Assert.Multiple()) + { + _ = await Assert.That(site.Origin).IsEqualTo(RegexPatternOrigin.GeneratedRegex); + _ = await Assert.That(site.AreOptionsKnown).IsTrue(); + _ = await Assert + .That(site.Options!.Value) + .IsEqualTo(RegexOptions.IgnoreCase | RegexOptions.CultureInvariant); + } } [Test] @@ -915,10 +986,13 @@ public async Task TryLocate_GeneratedRegexWithNamedArguments_ResolvesPatternAndO CreateGeneratedRegexSource("[GeneratedRegex(options: RegexOptions.Multiline, pattern: /*!*/\"a+\")]") ); - _ = await Assert.That(site.Origin).IsEqualTo(RegexPatternOrigin.GeneratedRegex); - _ = await Assert.That(site.Pattern).IsEqualTo("a+"); - _ = await Assert.That(site.AreOptionsKnown).IsTrue(); - _ = await Assert.That(site.Options!.Value).IsEqualTo(RegexOptions.Multiline); + using (Assert.Multiple()) + { + _ = await Assert.That(site.Origin).IsEqualTo(RegexPatternOrigin.GeneratedRegex); + _ = await Assert.That(site.Pattern).IsEqualTo("a+"); + _ = await Assert.That(site.AreOptionsKnown).IsTrue(); + _ = await Assert.That(site.Options!.Value).IsEqualTo(RegexOptions.Multiline); + } } [Test] @@ -928,8 +1002,11 @@ public async Task TryLocate_GeneratedRegexWithMatchTimeout_StillResolvesTheOptio CreateGeneratedRegexSource("[GeneratedRegex(/*!*/\"a+\", RegexOptions.Singleline, 250)]") ); - _ = await Assert.That(site.AreOptionsKnown).IsTrue(); - _ = await Assert.That(site.Options!.Value).IsEqualTo(RegexOptions.Singleline); + using (Assert.Multiple()) + { + _ = await Assert.That(site.AreOptionsKnown).IsTrue(); + _ = await Assert.That(site.Options!.Value).IsEqualTo(RegexOptions.Singleline); + } } /// @@ -962,10 +1039,13 @@ public async Task TryLocate_GeneratedRegexWithCultureName_ResolvesTheOptions() CreateGeneratedRegexSource("[GeneratedRegex(/*!*/\"a+\", RegexOptions.IgnoreCase, \"en-US\")]") ); - _ = await Assert.That(site.Origin).IsEqualTo(RegexPatternOrigin.GeneratedRegex); - _ = await Assert.That(site.Pattern).IsEqualTo("a+"); - _ = await Assert.That(site.AreOptionsKnown).IsTrue(); - _ = await Assert.That(site.Options!.Value).IsEqualTo(RegexOptions.IgnoreCase); + using (Assert.Multiple()) + { + _ = await Assert.That(site.Origin).IsEqualTo(RegexPatternOrigin.GeneratedRegex); + _ = await Assert.That(site.Pattern).IsEqualTo("a+"); + _ = await Assert.That(site.AreOptionsKnown).IsTrue(); + _ = await Assert.That(site.Options!.Value).IsEqualTo(RegexOptions.IgnoreCase); + } } /// @@ -984,8 +1064,11 @@ public async Task TryLocate_GeneratedRegexCultureName_ReturnsNull() var site = RegexPatternLocator.TryLocate(node, semanticModel, CancellationToken.None); - _ = await Assert.That(node.Token.Value is string).IsTrue(); - _ = await Assert.That(site).IsNull(); + using (Assert.Multiple()) + { + _ = await Assert.That(node.Token.Value is string).IsTrue(); + _ = await Assert.That(site).IsNull(); + } } #endif #endif @@ -1000,12 +1083,15 @@ public async Task TryLocate_DataAnnotationsRegularExpression_ReportsNoOptions() { var site = LocateSite(RegularExpressionSource); - _ = await Assert.That(site.Origin).IsEqualTo(RegexPatternOrigin.DataAnnotationsRegularExpression); - _ = await Assert.That(site.Pattern).IsEqualTo("a+"); - _ = await Assert.That(site.AreOptionsKnown).IsTrue(); - _ = await Assert.That(site.Options!.Value).IsEqualTo(RegexOptions.None); - _ = await Assert.That(site.OptionsExpression).IsNull(); - _ = await Assert.That(site.AttributeArgument).IsNotNull(); + using (Assert.Multiple()) + { + _ = await Assert.That(site.Origin).IsEqualTo(RegexPatternOrigin.DataAnnotationsRegularExpression); + _ = await Assert.That(site.Pattern).IsEqualTo("a+"); + _ = await Assert.That(site.AreOptionsKnown).IsTrue(); + _ = await Assert.That(site.Options!.Value).IsEqualTo(RegexOptions.None); + _ = await Assert.That(site.OptionsExpression).IsNull(); + _ = await Assert.That(site.AttributeArgument).IsNotNull(); + } } /// @@ -1018,10 +1104,13 @@ public async Task TryLocate_DataAnnotationsRegularExpressionWithErrorMessage_Rep { var site = LocateSite(RegularExpressionWithErrorMessageSource); - _ = await Assert.That(site.Origin).IsEqualTo(RegexPatternOrigin.DataAnnotationsRegularExpression); - _ = await Assert.That(site.Pattern).IsEqualTo("a+"); - _ = await Assert.That(site.AreOptionsKnown).IsTrue(); - _ = await Assert.That(site.Options!.Value).IsEqualTo(RegexOptions.None); + using (Assert.Multiple()) + { + _ = await Assert.That(site.Origin).IsEqualTo(RegexPatternOrigin.DataAnnotationsRegularExpression); + _ = await Assert.That(site.Pattern).IsEqualTo("a+"); + _ = await Assert.That(site.AreOptionsKnown).IsTrue(); + _ = await Assert.That(site.Options!.Value).IsEqualTo(RegexOptions.None); + } } /// diff --git a/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/RegularExpressions/RegexPatternTokenizerAdversarialTests.cs b/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/RegularExpressions/RegexPatternTokenizerAdversarialTests.cs index d97d2c7..bb32946 100644 --- a/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/RegularExpressions/RegexPatternTokenizerAdversarialTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/RegularExpressions/RegexPatternTokenizerAdversarialTests.cs @@ -225,10 +225,13 @@ public async Task Tokenize_PatternRealParserAccepts_TokensReconstructItExactly(s out var error ); - _ = await Assert.That(IsAcceptedByRegex(pattern, options)).IsTrue(); - _ = await Assert.That($"{tokenized}:{index}:{error}").IsEqualTo("True:-1:"); - _ = await Assert.That(Reconstruct(tokens)).IsEqualTo(pattern); - _ = await Assert.That(DescribeTiling(pattern, tokens)).IsEqualTo("tiles"); + using (Assert.Multiple()) + { + _ = await Assert.That(IsAcceptedByRegex(pattern, options)).IsTrue(); + _ = await Assert.That($"{tokenized}:{index}:{error}").IsEqualTo("True:-1:"); + _ = await Assert.That(Reconstruct(tokens)).IsEqualTo(pattern); + _ = await Assert.That(DescribeTiling(pattern, tokens)).IsEqualTo("tiles"); + } } /// @@ -276,11 +279,14 @@ RegexOptions options out var error ); - _ = await Assert.That(IsAcceptedByRegex(pattern, options)).IsFalse(); - _ = await Assert.That(tokenized).IsFalse(); - _ = await Assert.That(tokens.IsEmpty).IsTrue(); - _ = await Assert.That(index >= 0 && index < pattern.Length).IsTrue(); - _ = await Assert.That(string.IsNullOrWhiteSpace(error)).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(IsAcceptedByRegex(pattern, options)).IsFalse(); + _ = await Assert.That(tokenized).IsFalse(); + _ = await Assert.That(tokens.IsEmpty).IsTrue(); + _ = await Assert.That(index >= 0 && index < pattern.Length).IsTrue(); + _ = await Assert.That(string.IsNullOrWhiteSpace(error)).IsFalse(); + } } /// @@ -336,9 +342,12 @@ string expected { var tokens = RegexPatternTokenizer.Tokenize(pattern, options); - _ = await Assert.That(Describe(tokens)).IsEqualTo(expected); - _ = await Assert.That(Reconstruct(tokens)).IsEqualTo(pattern); - _ = await Assert.That(IsAcceptedByRegex(pattern, options)).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(Describe(tokens)).IsEqualTo(expected); + _ = await Assert.That(Reconstruct(tokens)).IsEqualTo(pattern); + _ = await Assert.That(IsAcceptedByRegex(pattern, options)).IsFalse(); + } } /// @@ -421,9 +430,12 @@ string expected { var tokens = RegexPatternTokenizer.Tokenize(pattern, options); - _ = await Assert.That(Describe(tokens)).IsEqualTo(expected); - _ = await Assert.That(Reconstruct(tokens)).IsEqualTo(pattern); - _ = await Assert.That(IsAcceptedByRegex(pattern, options)).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(Describe(tokens)).IsEqualTo(expected); + _ = await Assert.That(Reconstruct(tokens)).IsEqualTo(pattern); + _ = await Assert.That(IsAcceptedByRegex(pattern, options)).IsTrue(); + } } /// @@ -448,10 +460,13 @@ public async Task Tokenize_QuotingEscape_IsUnrecognizedByBothTheTokenizerAndTheR var tokenized = RegexPatternTokenizer.TryTokenize(pattern, Strict, out _, out var index, out var error); - _ = await Assert.That(IsAcceptedByRegex(pattern, Strict)).IsFalse(); - _ = await Assert.That(tokenized).IsFalse(); - _ = await Assert.That(error).Contains("is not recognized by .NET"); - _ = await Assert.That(pattern.Substring(index, 2)).IsEqualTo(expected); + using (Assert.Multiple()) + { + _ = await Assert.That(IsAcceptedByRegex(pattern, Strict)).IsFalse(); + _ = await Assert.That(tokenized).IsFalse(); + _ = await Assert.That(error).Contains("is not recognized by .NET"); + _ = await Assert.That(pattern.Substring(index, 2)).IsEqualTo(expected); + } } /// @@ -490,9 +505,12 @@ string expected { var tokens = RegexPatternTokenizer.Tokenize(pattern, Strict); - _ = await Assert.That(IsAcceptedByRegex(pattern, Strict)).IsTrue(); - _ = await Assert.That(Describe(tokens)).IsEqualTo(expected); - _ = await Assert.That(Reconstruct(tokens)).IsEqualTo(pattern); + using (Assert.Multiple()) + { + _ = await Assert.That(IsAcceptedByRegex(pattern, Strict)).IsTrue(); + _ = await Assert.That(Describe(tokens)).IsEqualTo(expected); + _ = await Assert.That(Reconstruct(tokens)).IsEqualTo(pattern); + } } /// @@ -516,9 +534,12 @@ string expectedLastToken var tokens = RegexPatternTokenizer.Tokenize(pattern, Strict); var last = tokens[tokens.Length - 1]; - _ = await Assert.That(IsAcceptedByRegex(pattern, Strict)).IsTrue(); - _ = await Assert.That($"{last.Kind}:{last.Start}:{last.Text}").IsEqualTo(expectedLastToken); - _ = await Assert.That(Reconstruct(tokens)).IsEqualTo(pattern); + using (Assert.Multiple()) + { + _ = await Assert.That(IsAcceptedByRegex(pattern, Strict)).IsTrue(); + _ = await Assert.That($"{last.Kind}:{last.Start}:{last.Text}").IsEqualTo(expectedLastToken); + _ = await Assert.That(Reconstruct(tokens)).IsEqualTo(pattern); + } } /// @@ -562,10 +583,13 @@ out var error var lazyMarker = tokenized ? tokens.FirstOrDefault(token => token.Start == lazyMarkerIndex) : null; var expectedMarker = $"Quantifier[{lazyMarkerIndex}..{lazyMarkerIndex + 1})='?'"; - _ = await Assert.That(IsAcceptedByRegex(pattern, options)).IsTrue(); - _ = await Assert.That($"{tokenized}:{index}:{error}").IsEqualTo("True:-1:"); - _ = await Assert.That(Reconstruct(tokens)).IsEqualTo(pattern); - _ = await Assert.That(lazyMarker?.ToString()).IsEqualTo(expectedMarker); + using (Assert.Multiple()) + { + _ = await Assert.That(IsAcceptedByRegex(pattern, options)).IsTrue(); + _ = await Assert.That($"{tokenized}:{index}:{error}").IsEqualTo("True:-1:"); + _ = await Assert.That(Reconstruct(tokens)).IsEqualTo(pattern); + _ = await Assert.That(lazyMarker?.ToString()).IsEqualTo(expectedMarker); + } } /// @@ -589,9 +613,12 @@ RegexOptions options { var tokenized = RegexPatternTokenizer.TryTokenize(pattern, options, out _, out _, out var error); - _ = await Assert.That(IsAcceptedByRegex(pattern, options)).IsFalse(); - _ = await Assert.That(tokenized).IsFalse(); - _ = await Assert.That(error).Contains("nested quantifier"); + using (Assert.Multiple()) + { + _ = await Assert.That(IsAcceptedByRegex(pattern, options)).IsFalse(); + _ = await Assert.That(tokenized).IsFalse(); + _ = await Assert.That(error).Contains("nested quantifier"); + } } /// @@ -621,11 +648,14 @@ public async Task TryTokenize_ClassSubtractionFollowedByAnotherMember_IsRejected out var error ); - _ = await Assert.That(IsAcceptedByRegex(pattern, Strict)).IsFalse(); - _ = await Assert.That(tokenized).IsFalse(); - _ = await Assert.That(tokens.IsEmpty).IsTrue(); - _ = await Assert.That(index >= 0 && index < pattern.Length).IsTrue(); - _ = await Assert.That(string.IsNullOrWhiteSpace(error)).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(IsAcceptedByRegex(pattern, Strict)).IsFalse(); + _ = await Assert.That(tokenized).IsFalse(); + _ = await Assert.That(tokens.IsEmpty).IsTrue(); + _ = await Assert.That(index >= 0 && index < pattern.Length).IsTrue(); + _ = await Assert.That(string.IsNullOrWhiteSpace(error)).IsFalse(); + } } /// @@ -679,10 +709,13 @@ string expected out var error ); - _ = await Assert.That(IsAcceptedByRegex(pattern, Strict)).IsTrue(); - _ = await Assert.That($"{tokenized}:{index}:{error}").IsEqualTo("True:-1:"); - _ = await Assert.That(Describe(tokens)).IsEqualTo(expected); - _ = await Assert.That(Reconstruct(tokens)).IsEqualTo(pattern); + using (Assert.Multiple()) + { + _ = await Assert.That(IsAcceptedByRegex(pattern, Strict)).IsTrue(); + _ = await Assert.That($"{tokenized}:{index}:{error}").IsEqualTo("True:-1:"); + _ = await Assert.That(Describe(tokens)).IsEqualTo(expected); + _ = await Assert.That(Reconstruct(tokens)).IsEqualTo(pattern); + } } /// @@ -704,10 +737,13 @@ public async Task Tokenize_DashBeforeANestedClassBehindAMember_IsASubtraction(st var tokens = RegexPatternTokenizer.Tokenize(pattern, Strict); var subtraction = tokens.Single(token => token.Start == subtractionIndex); - _ = await Assert.That(IsAcceptedByRegex(pattern, Strict)).IsTrue(); - _ = await Assert.That(subtraction.Kind).IsEqualTo(RegexTokenKind.CharacterClassSubtraction); - _ = await Assert.That(subtraction.Text).IsEqualTo("-"); - _ = await Assert.That(Reconstruct(tokens)).IsEqualTo(pattern); + using (Assert.Multiple()) + { + _ = await Assert.That(IsAcceptedByRegex(pattern, Strict)).IsTrue(); + _ = await Assert.That(subtraction.Kind).IsEqualTo(RegexTokenKind.CharacterClassSubtraction); + _ = await Assert.That(subtraction.Text).IsEqualTo("-"); + _ = await Assert.That(Reconstruct(tokens)).IsEqualTo(pattern); + } } /// @@ -744,10 +780,13 @@ string expected out var error ); - _ = await Assert.That(IsAcceptedByRegex(pattern, Strict)).IsTrue(); - _ = await Assert.That($"{tokenized}:{index}:{error}").IsEqualTo("True:-1:"); - _ = await Assert.That(Describe(tokens)).IsEqualTo(expected); - _ = await Assert.That(Reconstruct(tokens)).IsEqualTo(pattern); + using (Assert.Multiple()) + { + _ = await Assert.That(IsAcceptedByRegex(pattern, Strict)).IsTrue(); + _ = await Assert.That($"{tokenized}:{index}:{error}").IsEqualTo("True:-1:"); + _ = await Assert.That(Describe(tokens)).IsEqualTo(expected); + _ = await Assert.That(Reconstruct(tokens)).IsEqualTo(pattern); + } } /// @@ -778,9 +817,12 @@ RegexTokenKind expectedKind : RegexTokenKind.Comment; var oracle = Matches(pattern, Strict, "ab") ? RegexTokenKind.WhitespaceIgnored : RegexTokenKind.Literal; - _ = await Assert.That(oracle).IsEqualTo(expectedKind); - _ = await Assert.That(tokenized).IsTrue(); - _ = await Assert.That(space).IsEqualTo(expectedKind); + using (Assert.Multiple()) + { + _ = await Assert.That(oracle).IsEqualTo(expectedKind); + _ = await Assert.That(tokenized).IsTrue(); + _ = await Assert.That(space).IsEqualTo(expectedKind); + } } /// @@ -821,10 +863,13 @@ RegexTokenKind expectedKind var middle = tokens.Single(token => token.Start == 1); var oracle = Matches(pattern, Extended, "ab") ? RegexTokenKind.WhitespaceIgnored : RegexTokenKind.Literal; - _ = await Assert.That(oracle).IsEqualTo(expectedKind); - _ = await Assert.That(middle.Kind).IsEqualTo(expectedKind); - _ = await Assert.That(middle.Text).IsEqualTo(candidate); - _ = await Assert.That(Reconstruct(tokens)).IsEqualTo(pattern); + using (Assert.Multiple()) + { + _ = await Assert.That(oracle).IsEqualTo(expectedKind); + _ = await Assert.That(middle.Kind).IsEqualTo(expectedKind); + _ = await Assert.That(middle.Text).IsEqualTo(candidate); + _ = await Assert.That(Reconstruct(tokens)).IsEqualTo(pattern); + } } /// @@ -847,11 +892,14 @@ public async Task Tokenize_WhitespaceInsideACharacterClass_StaysAMember() var tokens = RegexPatternTokenizer.Tokenize(pattern, Extended); var kinds = tokens.Select(token => token.Kind).Distinct().OrderBy(kind => kind).ToArray(); - _ = await Assert.That(Matches(pattern, Extended, " ")).IsTrue(); - _ = await Assert.That(Matches(pattern, Extended, "#")).IsTrue(); - _ = await Assert.That(tokens.Length).IsEqualTo(8); - _ = await Assert.That(kinds).IsEquivalentTo(expectedKinds); - _ = await Assert.That(Reconstruct(tokens)).IsEqualTo(pattern); + using (Assert.Multiple()) + { + _ = await Assert.That(Matches(pattern, Extended, " ")).IsTrue(); + _ = await Assert.That(Matches(pattern, Extended, "#")).IsTrue(); + _ = await Assert.That(tokens.Length).IsEqualTo(8); + _ = await Assert.That(kinds).IsEquivalentTo(expectedKinds); + _ = await Assert.That(Reconstruct(tokens)).IsEqualTo(pattern); + } } /// @@ -867,11 +915,14 @@ public async Task Tokenize_SurrogatePair_ProducesOneTokenPerCodeUnit() var tokens = RegexPatternTokenizer.Tokenize(pattern, Strict); - _ = await Assert.That(Describe(tokens)).IsEqualTo("Literal:0:\uD83D|Literal:1:\uDE00|Quantifier:2:+"); - _ = await Assert.That(char.IsHighSurrogate(tokens[0].Text[0])).IsTrue(); - _ = await Assert.That(char.IsLowSurrogate(tokens[1].Text[0])).IsTrue(); - _ = await Assert.That(Matches(pattern, Strict, "\U0001F600\uDE00")).IsTrue(); - _ = await Assert.That(Reconstruct(tokens)).IsEqualTo(pattern); + using (Assert.Multiple()) + { + _ = await Assert.That(Describe(tokens)).IsEqualTo("Literal:0:\uD83D|Literal:1:\uDE00|Quantifier:2:+"); + _ = await Assert.That(char.IsHighSurrogate(tokens[0].Text[0])).IsTrue(); + _ = await Assert.That(char.IsLowSurrogate(tokens[1].Text[0])).IsTrue(); + _ = await Assert.That(Matches(pattern, Strict, "\U0001F600\uDE00")).IsTrue(); + _ = await Assert.That(Reconstruct(tokens)).IsEqualTo(pattern); + } } /// @@ -895,14 +946,17 @@ public async Task Tokenize_VeryLongPattern_ScalesLinearlyAndDoesNotRecurse() var alternationTokens = RegexPatternTokenizer.Tokenize(alternations, Strict); watch.Stop(); - _ = await Assert.That(literalTokens.Length).IsEqualTo(20000); - _ = await Assert.That(groupTokens.Length).IsEqualTo(6000); - _ = await Assert.That(classTokens.Length).IsEqualTo(20000); - _ = await Assert.That(alternationTokens.Length).IsEqualTo(10000); - _ = await Assert.That(Reconstruct(literalTokens)).IsEqualTo(literals); - _ = await Assert.That(Reconstruct(classTokens)).IsEqualTo(classes); - _ = await Assert.That(DescribeTiling(alternations, alternationTokens)).IsEqualTo("tiles"); - _ = await Assert.That(watch.ElapsedMilliseconds).IsLessThan(30_000L); + using (Assert.Multiple()) + { + _ = await Assert.That(literalTokens.Length).IsEqualTo(20000); + _ = await Assert.That(groupTokens.Length).IsEqualTo(6000); + _ = await Assert.That(classTokens.Length).IsEqualTo(20000); + _ = await Assert.That(alternationTokens.Length).IsEqualTo(10000); + _ = await Assert.That(Reconstruct(literalTokens)).IsEqualTo(literals); + _ = await Assert.That(Reconstruct(classTokens)).IsEqualTo(classes); + _ = await Assert.That(DescribeTiling(alternations, alternationTokens)).IsEqualTo("tiles"); + _ = await Assert.That(watch.ElapsedMilliseconds).IsLessThan(30_000L); + } } /// @@ -921,12 +975,15 @@ public async Task Tokenize_DeeplyNestedConstructs_DoesNotOverflowTheStack() var groupTokens = RegexPatternTokenizer.Tokenize(groups, Strict); var classTokens = RegexPatternTokenizer.Tokenize(classes, Strict); - _ = await Assert.That(IsAcceptedByRegex(groups, Strict)).IsTrue(); - _ = await Assert.That(IsAcceptedByRegex(classes, Strict)).IsTrue(); - _ = await Assert.That(groupTokens.Length).IsEqualTo(401); - _ = await Assert.That(Reconstruct(groupTokens)).IsEqualTo(groups); - _ = await Assert.That(Reconstruct(classTokens)).IsEqualTo(classes); - _ = await Assert.That(DescribeTiling(classes, classTokens)).IsEqualTo("tiles"); + using (Assert.Multiple()) + { + _ = await Assert.That(IsAcceptedByRegex(groups, Strict)).IsTrue(); + _ = await Assert.That(IsAcceptedByRegex(classes, Strict)).IsTrue(); + _ = await Assert.That(groupTokens.Length).IsEqualTo(401); + _ = await Assert.That(Reconstruct(groupTokens)).IsEqualTo(groups); + _ = await Assert.That(Reconstruct(classTokens)).IsEqualTo(classes); + _ = await Assert.That(DescribeTiling(classes, classTokens)).IsEqualTo("tiles"); + } } /// @@ -943,10 +1000,13 @@ public async Task Tokenize_ManyLongDigitRuns_StaysFast() var tokens = RegexPatternTokenizer.Tokenize(pattern, Strict); watch.Stop(); - _ = await Assert.That(tokens.Length).IsGreaterThan(300); - _ = await Assert.That(Reconstruct(tokens)).IsEqualTo(pattern); - _ = await Assert.That(DescribeTiling(pattern, tokens)).IsEqualTo("tiles"); - _ = await Assert.That(watch.ElapsedMilliseconds).IsLessThan(30_000L); + using (Assert.Multiple()) + { + _ = await Assert.That(tokens.Length).IsGreaterThan(300); + _ = await Assert.That(Reconstruct(tokens)).IsEqualTo(pattern); + _ = await Assert.That(DescribeTiling(pattern, tokens)).IsEqualTo("tiles"); + _ = await Assert.That(watch.ElapsedMilliseconds).IsLessThan(30_000L); + } } /// @@ -961,10 +1021,13 @@ public async Task Tokenize_DegeneratePattern_ProducesAConsistentResult() var whitespaceOnly = RegexPatternTokenizer.Tokenize(" \t\n", Extended); var commentOnly = RegexPatternTokenizer.Tokenize("(?#)", Strict); - _ = await Assert.That(empty.IsEmpty).IsTrue(); - _ = await Assert.That(Describe(whitespaceOnly)).IsEqualTo("WhitespaceIgnored:0: \t\n"); - _ = await Assert.That(Describe(commentOnly)).IsEqualTo("Comment:0:(?#)"); - _ = await Assert.That(Reconstruct(whitespaceOnly)).IsEqualTo(" \t\n"); + using (Assert.Multiple()) + { + _ = await Assert.That(empty.IsEmpty).IsTrue(); + _ = await Assert.That(Describe(whitespaceOnly)).IsEqualTo("WhitespaceIgnored:0: \t\n"); + _ = await Assert.That(Describe(commentOnly)).IsEqualTo("Comment:0:(?#)"); + _ = await Assert.That(Reconstruct(whitespaceOnly)).IsEqualTo(" \t\n"); + } } /// diff --git a/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/RegularExpressions/RegexPatternTokenizerTests.cs b/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/RegularExpressions/RegexPatternTokenizerTests.cs index 98a7009..5fed5c8 100644 --- a/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/RegularExpressions/RegexPatternTokenizerTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/RegularExpressions/RegexPatternTokenizerTests.cs @@ -343,9 +343,12 @@ string expected { var tokens = RegexPatternTokenizer.Tokenize(pattern, options); - _ = await Assert.That(Describe(tokens)).IsEqualTo(expected); - _ = await Assert.That(Covers(pattern, tokens)).IsTrue(); - _ = await Assert.That(IsAcceptedByRegex(pattern, options)).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(Describe(tokens)).IsEqualTo(expected); + _ = await Assert.That(Covers(pattern, tokens)).IsTrue(); + _ = await Assert.That(IsAcceptedByRegex(pattern, options)).IsTrue(); + } } [Test] @@ -468,11 +471,14 @@ string expectedError out var error ); - _ = await Assert.That(tokenized).IsFalse(); - _ = await Assert.That(tokens.IsEmpty).IsTrue(); - _ = await Assert.That(index).IsEqualTo(expectedIndex); - _ = await Assert.That(error).IsEqualTo(expectedError); - _ = await Assert.That(IsAcceptedByRegex(pattern, options)).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(tokenized).IsFalse(); + _ = await Assert.That(tokens.IsEmpty).IsTrue(); + _ = await Assert.That(index).IsEqualTo(expectedIndex); + _ = await Assert.That(error).IsEqualTo(expectedError); + _ = await Assert.That(IsAcceptedByRegex(pattern, options)).IsFalse(); + } } /// @@ -510,9 +516,12 @@ string expected { var tokens = RegexPatternTokenizer.Tokenize(pattern, RegexOptions.None); - _ = await Assert.That(Describe(tokens)).IsEqualTo(expected); - _ = await Assert.That(Covers(pattern, tokens)).IsTrue(); - _ = await Assert.That(IsAcceptedByRegex(pattern, RegexOptions.None)).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(Describe(tokens)).IsEqualTo(expected); + _ = await Assert.That(Covers(pattern, tokens)).IsTrue(); + _ = await Assert.That(IsAcceptedByRegex(pattern, RegexOptions.None)).IsFalse(); + } } [Test] @@ -520,8 +529,11 @@ public async Task Tokenize_EmptyPattern_ProducesNoTokens() { var tokens = RegexPatternTokenizer.Tokenize(string.Empty, RegexOptions.None); - _ = await Assert.That(tokens.IsEmpty).IsTrue(); - _ = await Assert.That(Describe(tokens)).IsEqualTo(string.Empty); + using (Assert.Multiple()) + { + _ = await Assert.That(tokens.IsEmpty).IsTrue(); + _ = await Assert.That(Describe(tokens)).IsEqualTo(string.Empty); + } } [Test] @@ -531,11 +543,14 @@ public async Task Tokenize_CommentOnlyPattern_ProducesASingleCommentToken() var tokens = RegexPatternTokenizer.Tokenize(pattern, RegexOptions.IgnorePatternWhitespace); - _ = await Assert.That(tokens.Length).IsEqualTo(1); - _ = await Assert.That(tokens[0].Kind).IsEqualTo(RegexTokenKind.Comment); - _ = await Assert.That(tokens[0].Text).IsEqualTo(pattern); - _ = await Assert.That(tokens[0].Start).IsEqualTo(0); - _ = await Assert.That(tokens[0].End).IsEqualTo(pattern.Length); + using (Assert.Multiple()) + { + _ = await Assert.That(tokens.Length).IsEqualTo(1); + _ = await Assert.That(tokens[0].Kind).IsEqualTo(RegexTokenKind.Comment); + _ = await Assert.That(tokens[0].Text).IsEqualTo(pattern); + _ = await Assert.That(tokens[0].Start).IsEqualTo(0); + _ = await Assert.That(tokens[0].End).IsEqualTo(pattern.Length); + } } /// @@ -552,15 +567,18 @@ public async Task Tokenize_IgnorePatternWhitespace_ChangesTheGrammarOfTheSamePat var strict = RegexPatternTokenizer.Tokenize(pattern, RegexOptions.None); var relaxed = RegexPatternTokenizer.Tokenize(pattern, RegexOptions.IgnorePatternWhitespace); - _ = await Assert - .That(Describe(strict)) - .IsEqualTo("Literal:0:a|Literal:1: |Literal:2:b|Literal:3:#|Literal:4:c"); - _ = await Assert - .That(Describe(relaxed)) - .IsEqualTo("Literal:0:a|WhitespaceIgnored:1: |Literal:2:b|Comment:3:#c"); - _ = await Assert.That(Describe(strict)).IsNotEqualTo(Describe(relaxed)); - _ = await Assert.That(IsAcceptedByRegex(pattern, RegexOptions.None)).IsTrue(); - _ = await Assert.That(IsAcceptedByRegex(pattern, RegexOptions.IgnorePatternWhitespace)).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert + .That(Describe(strict)) + .IsEqualTo("Literal:0:a|Literal:1: |Literal:2:b|Literal:3:#|Literal:4:c"); + _ = await Assert + .That(Describe(relaxed)) + .IsEqualTo("Literal:0:a|WhitespaceIgnored:1: |Literal:2:b|Comment:3:#c"); + _ = await Assert.That(Describe(strict)).IsNotEqualTo(Describe(relaxed)); + _ = await Assert.That(IsAcceptedByRegex(pattern, RegexOptions.None)).IsTrue(); + _ = await Assert.That(IsAcceptedByRegex(pattern, RegexOptions.IgnorePatternWhitespace)).IsTrue(); + } } /// @@ -575,13 +593,16 @@ public async Task Tokenize_ScopedIgnorePatternWhitespace_EndsWithItsGroup() var tokens = RegexPatternTokenizer.Tokenize(pattern, RegexOptions.None); - _ = await Assert - .That(Describe(tokens)) - .IsEqualTo( - "GroupOpen:0:(?x:|Literal:4:a|WhitespaceIgnored:5: |Literal:6:b|GroupClose:7:)" - + "|Literal:8:c|Literal:9: |Literal:10:d" - ); - _ = await Assert.That(IsAcceptedByRegex(pattern, RegexOptions.None)).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert + .That(Describe(tokens)) + .IsEqualTo( + "GroupOpen:0:(?x:|Literal:4:a|WhitespaceIgnored:5: |Literal:6:b|GroupClose:7:)" + + "|Literal:8:c|Literal:9: |Literal:10:d" + ); + _ = await Assert.That(IsAcceptedByRegex(pattern, RegexOptions.None)).IsTrue(); + } } /// @@ -597,8 +618,11 @@ public async Task Tokenize_DigitRunBeyondTheGroupCount_IsAnOctalEscape() var tokens = RegexPatternTokenizer.Tokenize(pattern, RegexOptions.None); - _ = await Assert.That(Describe(tokens)).IsEqualTo("GroupOpen:0:(|Literal:1:a|GroupClose:2:)|Escape:3:\\10"); - _ = await Assert.That(IsAcceptedByRegex(pattern, RegexOptions.None)).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(Describe(tokens)).IsEqualTo("GroupOpen:0:(|Literal:1:a|GroupClose:2:)|Escape:3:\\10"); + _ = await Assert.That(IsAcceptedByRegex(pattern, RegexOptions.None)).IsTrue(); + } } [Test] @@ -609,11 +633,14 @@ public async Task Tokenize_BackreferenceWithinTheGroupCount_KeepsEveryDigit() var tokens = RegexPatternTokenizer.Tokenize(pattern, RegexOptions.None); var last = tokens[tokens.Length - 1]; - _ = await Assert.That(last.Kind).IsEqualTo(RegexTokenKind.Backreference); - _ = await Assert.That(last.Text).IsEqualTo(@"\10"); - _ = await Assert.That(last.Start).IsEqualTo(30); - _ = await Assert.That(Covers(pattern, tokens)).IsTrue(); - _ = await Assert.That(IsAcceptedByRegex(pattern, RegexOptions.None)).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(last.Kind).IsEqualTo(RegexTokenKind.Backreference); + _ = await Assert.That(last.Text).IsEqualTo(@"\10"); + _ = await Assert.That(last.Start).IsEqualTo(30); + _ = await Assert.That(Covers(pattern, tokens)).IsTrue(); + _ = await Assert.That(IsAcceptedByRegex(pattern, RegexOptions.None)).IsTrue(); + } } /// @@ -629,9 +656,12 @@ public async Task Tokenize_NamedGroupCapture_CountsTowardsTheBackreferenceNumber var tokens = RegexPatternTokenizer.Tokenize(pattern, RegexOptions.None); var last = tokens[tokens.Length - 1]; - _ = await Assert.That(last.Kind).IsEqualTo(RegexTokenKind.Backreference); - _ = await Assert.That(last.Text).IsEqualTo(@"\2"); - _ = await Assert.That(IsAcceptedByRegex(pattern, RegexOptions.None)).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(last.Kind).IsEqualTo(RegexTokenKind.Backreference); + _ = await Assert.That(last.Text).IsEqualTo(@"\2"); + _ = await Assert.That(IsAcceptedByRegex(pattern, RegexOptions.None)).IsTrue(); + } } [Test] @@ -645,10 +675,13 @@ public async Task TryTokenize_WellFormedPattern_ReportsNoError() out var error ); - _ = await Assert.That(tokenized).IsTrue(); - _ = await Assert.That(Describe(tokens)).IsEqualTo(@"Anchor:0:^|Escape:1:\d|Quantifier:3:+|Anchor:4:$"); - _ = await Assert.That(index).IsEqualTo(-1); - _ = await Assert.That(error).IsNull(); + using (Assert.Multiple()) + { + _ = await Assert.That(tokenized).IsTrue(); + _ = await Assert.That(Describe(tokens)).IsEqualTo(@"Anchor:0:^|Escape:1:\d|Quantifier:3:+|Anchor:4:$"); + _ = await Assert.That(index).IsEqualTo(-1); + _ = await Assert.That(error).IsNull(); + } } [Test] @@ -658,9 +691,12 @@ public async Task Tokenize_MalformedPattern_ThrowsArgumentExceptionNamingTheInde RegexPatternTokenizer.Tokenize("a(b", RegexOptions.None) ); - _ = await Assert.That(exception.ParamName).IsEqualTo("pattern"); - _ = await Assert.That(exception.Message).Contains("malformed at index 1"); - _ = await Assert.That(exception.Message).Contains("never closed by ')'"); + using (Assert.Multiple()) + { + _ = await Assert.That(exception.ParamName).IsEqualTo("pattern"); + _ = await Assert.That(exception.Message).Contains("malformed at index 1"); + _ = await Assert.That(exception.Message).Contains("never closed by ')'"); + } } [Test] @@ -700,9 +736,12 @@ public async Task Tokenize_TwoPatterns_ProduceEveryTokenKind() .ToArray(); var all = AllKinds().OrderBy(kind => kind).ToArray(); - _ = await Assert.That(produced).IsEquivalentTo(all); - _ = await Assert.That(IsAcceptedByRegex(CoverageWithOptions, RegexOptions.None)).IsTrue(); - _ = await Assert.That(IsAcceptedByRegex(CoverageWithClass, RegexOptions.None)).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(produced).IsEquivalentTo(all); + _ = await Assert.That(IsAcceptedByRegex(CoverageWithOptions, RegexOptions.None)).IsTrue(); + _ = await Assert.That(IsAcceptedByRegex(CoverageWithClass, RegexOptions.None)).IsTrue(); + } } /// @@ -719,11 +758,14 @@ public async Task Tokenize_QuantifierSpan_IsEnoughToRewriteThePattern() var quantifier = tokens.Single(token => token.Kind == RegexTokenKind.Quantifier); var mutated = pattern.Remove(quantifier.Start, quantifier.Length).Insert(quantifier.Start, "{2,}"); - _ = await Assert.That(quantifier.Text).IsEqualTo("{2,4}"); - _ = await Assert.That(quantifier.Start).IsEqualTo(3); - _ = await Assert.That(quantifier.Length).IsEqualTo(5); - _ = await Assert.That(mutated).IsEqualTo(@"^\d{2,}$"); - _ = await Assert.That(IsAcceptedByRegex(mutated, RegexOptions.None)).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(quantifier.Text).IsEqualTo("{2,4}"); + _ = await Assert.That(quantifier.Start).IsEqualTo(3); + _ = await Assert.That(quantifier.Length).IsEqualTo(5); + _ = await Assert.That(mutated).IsEqualTo(@"^\d{2,}$"); + _ = await Assert.That(IsAcceptedByRegex(mutated, RegexOptions.None)).IsTrue(); + } } [Test] @@ -743,8 +785,11 @@ public async Task RegexToken_TextIsEmpty_ThrowsArgumentException() _ = new RegexToken(RegexTokenKind.Literal, 0, string.Empty) ); - _ = await Assert.That(exception.ParamName).IsEqualTo("text"); - _ = await Assert.That(exception.Message).Contains("at least one character"); + using (Assert.Multiple()) + { + _ = await Assert.That(exception.ParamName).IsEqualTo("text"); + _ = await Assert.That(exception.Message).Contains("at least one character"); + } } [Test] @@ -763,12 +808,15 @@ public async Task RegexToken_SameKindStartAndText_AreEqual() var token = new RegexToken(RegexTokenKind.Quantifier, 3, "{2,4}"); var same = new RegexToken(RegexTokenKind.Quantifier, 3, "{2,4}"); - _ = await Assert.That(token.Equals(same)).IsTrue(); - _ = await Assert.That(token.Equals((object)same)).IsTrue(); - _ = await Assert.That(token.GetHashCode()).IsEqualTo(same.GetHashCode()); - _ = await Assert.That(token.Length).IsEqualTo(5); - _ = await Assert.That(token.End).IsEqualTo(8); - _ = await Assert.That(token.ToString()).IsEqualTo("Quantifier[3..8)='{2,4}'"); + using (Assert.Multiple()) + { + _ = await Assert.That(token.Equals(same)).IsTrue(); + _ = await Assert.That(token.Equals((object)same)).IsTrue(); + _ = await Assert.That(token.GetHashCode()).IsEqualTo(same.GetHashCode()); + _ = await Assert.That(token.Length).IsEqualTo(5); + _ = await Assert.That(token.End).IsEqualTo(8); + _ = await Assert.That(token.ToString()).IsEqualTo("Quantifier[3..8)='{2,4}'"); + } } /// @@ -787,11 +835,14 @@ public async Task RegexToken_DifferentKindStartOrText_AreNotEqual() { var token = new RegexToken(RegexTokenKind.Quantifier, 3, "{2,4}"); - _ = await Assert.That(token.Equals(new RegexToken(RegexTokenKind.Literal, 3, "{2,4}"))).IsFalse(); - _ = await Assert.That(token.Equals(new RegexToken(RegexTokenKind.Quantifier, 4, "{2,4}"))).IsFalse(); - _ = await Assert.That(token.Equals(new RegexToken(RegexTokenKind.Quantifier, 3, "{2,3}"))).IsFalse(); - _ = await Assert.That(token.Equals((object)"{2,4}")).IsFalse(); - _ = await Assert.That(token.Equals(null)).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(token.Equals(new RegexToken(RegexTokenKind.Literal, 3, "{2,4}"))).IsFalse(); + _ = await Assert.That(token.Equals(new RegexToken(RegexTokenKind.Quantifier, 4, "{2,4}"))).IsFalse(); + _ = await Assert.That(token.Equals(new RegexToken(RegexTokenKind.Quantifier, 3, "{2,3}"))).IsFalse(); + _ = await Assert.That(token.Equals((object)"{2,4}")).IsFalse(); + _ = await Assert.That(token.Equals(null)).IsFalse(); + } } /// diff --git a/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/RegularExpressions/RegexPatternValidityTests.cs b/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/RegularExpressions/RegexPatternValidityTests.cs index b736096..7c8c2c7 100644 --- a/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/RegularExpressions/RegexPatternValidityTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Unit/Mutations/RegularExpressions/RegexPatternValidityTests.cs @@ -71,8 +71,11 @@ public async Task MalformedPatterns_DataSource_CoversEveryListedPattern() { var patterns = MalformedPatterns().Select(factory => factory()).ToArray(); - _ = await Assert.That(patterns).IsEquivalentTo(_malformedPatterns); - _ = await Assert.That(patterns.Length).IsEqualTo(13); + using (Assert.Multiple()) + { + _ = await Assert.That(patterns).IsEquivalentTo(_malformedPatterns); + _ = await Assert.That(patterns.Length).IsEqualTo(13); + } } [Test] @@ -90,8 +93,11 @@ public async Task IsValid_EmptyPattern_ReturnsTrue() { var valid = RegexPatternValidity.IsValid(string.Empty, RegexOptions.None, out var error); - _ = await Assert.That(valid).IsTrue(); - _ = await Assert.That(error).IsNull(); + using (Assert.Multiple()) + { + _ = await Assert.That(valid).IsTrue(); + _ = await Assert.That(error).IsNull(); + } } [Test] @@ -110,8 +116,11 @@ public async Task IsValid_WellFormedPattern_ReturnsTrueWithoutError(string patte { var valid = RegexPatternValidity.IsValid(pattern, RegexOptions.None, out var error); - _ = await Assert.That(valid).IsTrue(); - _ = await Assert.That(error).IsNull(); + using (Assert.Multiple()) + { + _ = await Assert.That(valid).IsTrue(); + _ = await Assert.That(error).IsNull(); + } } [Test] @@ -120,8 +129,11 @@ public async Task IsValid_MalformedPattern_ReturnsFalseWithError(string pattern) { var valid = RegexPatternValidity.IsValid(pattern, RegexOptions.None, out var error); - _ = await Assert.That(valid).IsFalse(); - _ = await Assert.That(string.IsNullOrWhiteSpace(error)).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(valid).IsFalse(); + _ = await Assert.That(string.IsNullOrWhiteSpace(error)).IsFalse(); + } } [Test] @@ -129,8 +141,11 @@ public async Task IsValid_MalformedPattern_ErrorNamesTheOffendingPattern() { var valid = RegexPatternValidity.IsValid(UnterminatedClass, RegexOptions.None, out var error); - _ = await Assert.That(valid).IsFalse(); - _ = await Assert.That(error!.Contains(UnterminatedClass, StringComparison.Ordinal)).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(valid).IsFalse(); + _ = await Assert.That(error!.Contains(UnterminatedClass, StringComparison.Ordinal)).IsTrue(); + } } [Test] @@ -156,8 +171,11 @@ public async Task IsValid_UndefinedOptionValue_ReturnsFalseWithError() // runtime that does not know it, and it must not escape as an exception. var valid = RegexPatternValidity.IsValid("abc", (RegexOptions)0x8000, out var error); - _ = await Assert.That(valid).IsFalse(); - _ = await Assert.That(string.IsNullOrWhiteSpace(error)).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(valid).IsFalse(); + _ = await Assert.That(string.IsNullOrWhiteSpace(error)).IsFalse(); + } } /// @@ -194,9 +212,12 @@ out var combinationError var fallbacks = errors.Where(error => _exceptionTypeNames.Contains(error, StringComparer.Ordinal)); - _ = await Assert.That(errors.Count).IsEqualTo(_malformedPatterns.Length + AdditionalFailureShapes); - _ = await Assert.That(errors.Count(error => string.IsNullOrWhiteSpace(error))).IsEqualTo(0); - _ = await Assert.That(string.Join(" / ", fallbacks)).IsEqualTo(string.Empty); + using (Assert.Multiple()) + { + _ = await Assert.That(errors.Count).IsEqualTo(_malformedPatterns.Length + AdditionalFailureShapes); + _ = await Assert.That(errors.Count(error => string.IsNullOrWhiteSpace(error))).IsEqualTo(0); + _ = await Assert.That(string.Join(" / ", fallbacks)).IsEqualTo(string.Empty); + } } [Test] @@ -208,11 +229,14 @@ public async Task IsValid_CalledRepeatedly_ReturnsTheSameAnswer(string pattern, var second = RegexPatternValidity.IsValid(pattern, RegexOptions.None, out var secondError); var third = RegexPatternValidity.IsValid(pattern, RegexOptions.None, out var thirdError); - _ = await Assert.That(first).IsEqualTo(expected); - _ = await Assert.That(second).IsEqualTo(expected); - _ = await Assert.That(third).IsEqualTo(expected); - _ = await Assert.That(secondError).IsEqualTo(firstError); - _ = await Assert.That(thirdError).IsEqualTo(firstError); + using (Assert.Multiple()) + { + _ = await Assert.That(first).IsEqualTo(expected); + _ = await Assert.That(second).IsEqualTo(expected); + _ = await Assert.That(third).IsEqualTo(expected); + _ = await Assert.That(secondError).IsEqualTo(firstError); + _ = await Assert.That(thirdError).IsEqualTo(firstError); + } } [Test] @@ -223,10 +247,13 @@ public async Task IsValid_IgnoreCaseOption_DoesNotChangeValidity(string pattern) var withoutOption = RegexPatternValidity.IsValid(pattern, RegexOptions.None, out var withoutError); var withOption = RegexPatternValidity.IsValid(pattern, RegexOptions.IgnoreCase, out var withError); - _ = await Assert.That(withoutOption).IsTrue(); - _ = await Assert.That(withOption).IsTrue(); - _ = await Assert.That(withoutError).IsNull(); - _ = await Assert.That(withError).IsNull(); + using (Assert.Multiple()) + { + _ = await Assert.That(withoutOption).IsTrue(); + _ = await Assert.That(withOption).IsTrue(); + _ = await Assert.That(withoutError).IsNull(); + _ = await Assert.That(withError).IsNull(); + } } #if NET7_0_OR_GREATER @@ -246,10 +273,13 @@ public async Task IsValid_UnsupportedUnderNonBacktracking_IsValidUnderNoneOnly(s out var nonBacktrackingError ); - _ = await Assert.That(underNone).IsTrue(); - _ = await Assert.That(noneError).IsNull(); - _ = await Assert.That(underNonBacktracking).IsFalse(); - _ = await Assert.That(string.IsNullOrWhiteSpace(nonBacktrackingError)).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(underNone).IsTrue(); + _ = await Assert.That(noneError).IsNull(); + _ = await Assert.That(underNonBacktracking).IsFalse(); + _ = await Assert.That(string.IsNullOrWhiteSpace(nonBacktrackingError)).IsFalse(); + } } [Test] @@ -260,8 +290,11 @@ public async Task IsValid_SupportedUnderNonBacktracking_ReturnsTrue(string patte { var valid = RegexPatternValidity.IsValid(pattern, RegexOptions.NonBacktracking, out var error); - _ = await Assert.That(valid).IsTrue(); - _ = await Assert.That(error).IsNull(); + using (Assert.Multiple()) + { + _ = await Assert.That(valid).IsTrue(); + _ = await Assert.That(error).IsNull(); + } } [Test] @@ -273,8 +306,11 @@ public async Task IsValid_NonBacktrackingCombinedWithRightToLeft_ReturnsFalseWit out var error ); - _ = await Assert.That(valid).IsFalse(); - _ = await Assert.That(string.IsNullOrWhiteSpace(error)).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(valid).IsFalse(); + _ = await Assert.That(string.IsNullOrWhiteSpace(error)).IsFalse(); + } } [Test] @@ -282,8 +318,11 @@ public async Task IsValid_MalformedPatternUnderNonBacktracking_ReturnsFalseWithE { var valid = RegexPatternValidity.IsValid(UnterminatedClass, RegexOptions.NonBacktracking, out var error); - _ = await Assert.That(valid).IsFalse(); - _ = await Assert.That(string.IsNullOrWhiteSpace(error)).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(valid).IsFalse(); + _ = await Assert.That(string.IsNullOrWhiteSpace(error)).IsFalse(); + } } #endif } diff --git a/tests/NetEvolve.FrameShift.Tests.Unit/Reachability/ReachabilityClosureMemberTests.cs b/tests/NetEvolve.FrameShift.Tests.Unit/Reachability/ReachabilityClosureMemberTests.cs index b0f63ec..4f1dda4 100644 --- a/tests/NetEvolve.FrameShift.Tests.Unit/Reachability/ReachabilityClosureMemberTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Unit/Reachability/ReachabilityClosureMemberTests.cs @@ -221,8 +221,11 @@ public async Task Compute_PropertyWithBlockAccessors_ReachesTheHelperOfEachAcces var reachable = ReachabilityClosure.Compute(compilation, manifest, CancellationToken.None); - _ = await Assert.That(reachable.Contains(Method(compilation, "Production.Properties", "Read"))).IsTrue(); - _ = await Assert.That(reachable.Contains(Method(compilation, "Production.Properties", "Write"))).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(reachable.Contains(Method(compilation, "Production.Properties", "Read"))).IsTrue(); + _ = await Assert.That(reachable.Contains(Method(compilation, "Production.Properties", "Write"))).IsTrue(); + } } [Test] @@ -244,12 +247,15 @@ public async Task Compute_UnseededProperty_KeepsItsHelperOutOfTheClosure() var reachable = ReachabilityClosure.Compute(compilation, manifest, CancellationToken.None); - _ = await Assert - .That(reachable.Contains(Property(compilation, "Production.Properties", "Untouched"))) - .IsFalse(); - _ = await Assert.That(reachable.Contains(Method(compilation, "Production.Properties", "Unused"))).IsFalse(); - _ = await Assert.That(reachable.Contains(Method(compilation, "Production.Properties", "Seed"))).IsFalse(); - _ = await Assert.That(reachable.Count).IsEqualTo(3); + using (Assert.Multiple()) + { + _ = await Assert + .That(reachable.Contains(Property(compilation, "Production.Properties", "Untouched"))) + .IsFalse(); + _ = await Assert.That(reachable.Contains(Method(compilation, "Production.Properties", "Unused"))).IsFalse(); + _ = await Assert.That(reachable.Contains(Method(compilation, "Production.Properties", "Seed"))).IsFalse(); + _ = await Assert.That(reachable.Count).IsEqualTo(3); + } } [Test] @@ -271,8 +277,11 @@ public async Task Compute_IndexerWithoutSetter_ReachesTheHelperOfItsGetter() var reachable = ReachabilityClosure.Compute(compilation, manifest, CancellationToken.None); - _ = await Assert.That(reachable.Contains(Method(compilation, "Production.Indexers", "Find"))).IsTrue(); - _ = await Assert.That(reachable.Contains(Method(compilation, "Production.Indexers", "Store"))).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(reachable.Contains(Method(compilation, "Production.Indexers", "Find"))).IsTrue(); + _ = await Assert.That(reachable.Contains(Method(compilation, "Production.Indexers", "Store"))).IsFalse(); + } } [Test] @@ -283,8 +292,11 @@ public async Task Compute_IndexerWithSetter_ReachesTheHelperOfBothAccessors() var reachable = ReachabilityClosure.Compute(compilation, manifest, CancellationToken.None); - _ = await Assert.That(reachable.Contains(Method(compilation, "Production.Indexers", "Read"))).IsTrue(); - _ = await Assert.That(reachable.Contains(Method(compilation, "Production.Indexers", "Store"))).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(reachable.Contains(Method(compilation, "Production.Indexers", "Read"))).IsTrue(); + _ = await Assert.That(reachable.Contains(Method(compilation, "Production.Indexers", "Store"))).IsTrue(); + } } [Test] @@ -295,8 +307,11 @@ public async Task Compute_ExplicitEventAccessors_ReachTheirHelpers() var reachable = ReachabilityClosure.Compute(compilation, manifest, CancellationToken.None); - _ = await Assert.That(reachable.Contains(Method(compilation, "Production.Events", "Attach"))).IsTrue(); - _ = await Assert.That(reachable.Contains(Method(compilation, "Production.Events", "Detach"))).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(reachable.Contains(Method(compilation, "Production.Events", "Attach"))).IsTrue(); + _ = await Assert.That(reachable.Contains(Method(compilation, "Production.Events", "Detach"))).IsTrue(); + } } [Test] @@ -307,8 +322,11 @@ public async Task Compute_StaticFieldInitializer_ReachesTheHelperItCalls() var reachable = ReachabilityClosure.Compute(compilation, manifest, CancellationToken.None); - _ = await Assert.That(reachable.Contains(Method(compilation, "Production.Statics", "MakeSeed"))).IsTrue(); - _ = await Assert.That(reachable.Contains(Method(compilation, "Production.Statics", "Configure"))).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(reachable.Contains(Method(compilation, "Production.Statics", "MakeSeed"))).IsTrue(); + _ = await Assert.That(reachable.Contains(Method(compilation, "Production.Statics", "Configure"))).IsFalse(); + } } [Test] @@ -319,8 +337,11 @@ public async Task Compute_StaticConstructor_ReachesTheHelperItCalls() var reachable = ReachabilityClosure.Compute(compilation, manifest, CancellationToken.None); - _ = await Assert.That(reachable.Contains(Method(compilation, "Production.Statics", "Configure"))).IsTrue(); - _ = await Assert.That(reachable.Contains(Field(compilation, "Production.Statics", "Configured"))).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(reachable.Contains(Method(compilation, "Production.Statics", "Configure"))).IsTrue(); + _ = await Assert.That(reachable.Contains(Field(compilation, "Production.Statics", "Configured"))).IsTrue(); + } } [Test] @@ -331,8 +352,11 @@ public async Task Compute_ThisConstructorInitializer_ReachesTheChainedConstructo var reachable = ReachabilityClosure.Compute(compilation, manifest, CancellationToken.None); - _ = await Assert.That(reachable.Contains(Constructor(compilation, "Production.Derived", 1))).IsTrue(); - _ = await Assert.That(reachable.Contains(Method(compilation, "Production.Derived", "Adjust"))).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(reachable.Contains(Constructor(compilation, "Production.Derived", 1))).IsTrue(); + _ = await Assert.That(reachable.Contains(Method(compilation, "Production.Derived", "Adjust"))).IsTrue(); + } } [Test] @@ -343,9 +367,12 @@ public async Task Compute_BaseConstructorInitializer_ReachesTheBaseConstructorAn var reachable = ReachabilityClosure.Compute(compilation, manifest, CancellationToken.None); - _ = await Assert.That(reachable.Contains(Constructor(compilation, "Production.Origin", 1))).IsTrue(); - _ = await Assert.That(reachable.Contains(Method(compilation, "Production.Origin", "Store"))).IsTrue(); - _ = await Assert.That(reachable.Contains(Constructor(compilation, "Production.Derived", 0))).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(reachable.Contains(Constructor(compilation, "Production.Origin", 1))).IsTrue(); + _ = await Assert.That(reachable.Contains(Method(compilation, "Production.Origin", "Store"))).IsTrue(); + _ = await Assert.That(reachable.Contains(Constructor(compilation, "Production.Derived", 0))).IsFalse(); + } } [Test] @@ -396,8 +423,11 @@ public async Task ContainsEnclosing_LocalFunctionInAPropertyAccessor_IsAttribute var property = Property(compilation, "Production.PropertyClosures", "WithLocalFunction"); var reachable = new ReachableSymbolSet([property]); - _ = await Assert.That(reachable.Contains(localFunctionSymbol)).IsFalse(); - _ = await Assert.That(reachable.ContainsEnclosing(localFunctionSymbol)).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(reachable.Contains(localFunctionSymbol)).IsFalse(); + _ = await Assert.That(reachable.ContainsEnclosing(localFunctionSymbol)).IsTrue(); + } } [Test] @@ -409,8 +439,11 @@ public async Task ContainsEnclosing_LocalFunctionInAnIndexerAccessor_IsAttribute var indexer = Indexer(compilation, "Production.PropertyClosures", "Int32"); var reachable = new ReachableSymbolSet([indexer]); - _ = await Assert.That(reachable.Contains(localFunctionSymbol)).IsFalse(); - _ = await Assert.That(reachable.ContainsEnclosing(localFunctionSymbol)).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(reachable.Contains(localFunctionSymbol)).IsFalse(); + _ = await Assert.That(reachable.ContainsEnclosing(localFunctionSymbol)).IsTrue(); + } } [Test] @@ -422,8 +455,11 @@ public async Task ContainsEnclosing_LambdaInAPropertyAccessor_IsAttributedToTheP var property = Property(compilation, "Production.PropertyClosures", "WithLambda"); var reachable = new ReachableSymbolSet([property]); - _ = await Assert.That(reachable.Contains(lambdaSymbol)).IsFalse(); - _ = await Assert.That(reachable.ContainsEnclosing(lambdaSymbol)).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(reachable.Contains(lambdaSymbol)).IsFalse(); + _ = await Assert.That(reachable.ContainsEnclosing(lambdaSymbol)).IsTrue(); + } } [Test] @@ -451,13 +487,16 @@ public async Task ComputeFromReferences_SeededProperty_AttributesItsAccessorsAnd var reachable = ReachabilityClosure.ComputeFromReferences(compilation, references, CancellationToken.None); - _ = await Assert.That(Describe(reachable, property.GetMethod!)).IsEqualTo(PropertyTestId); - _ = await Assert - .That(Describe(reachable, Method(compilation, "Production.Properties", "Read"))) - .IsEqualTo(PropertyTestId); - _ = await Assert - .That(Describe(reachable, Method(compilation, "Production.Properties", "Write"))) - .IsEqualTo(PropertyTestId); + using (Assert.Multiple()) + { + _ = await Assert.That(Describe(reachable, property.GetMethod!)).IsEqualTo(PropertyTestId); + _ = await Assert + .That(Describe(reachable, Method(compilation, "Production.Properties", "Read"))) + .IsEqualTo(PropertyTestId); + _ = await Assert + .That(Describe(reachable, Method(compilation, "Production.Properties", "Write"))) + .IsEqualTo(PropertyTestId); + } } [Test] diff --git a/tests/NetEvolve.FrameShift.Tests.Unit/Reachability/ReachabilityClosurePolymorphismTests.cs b/tests/NetEvolve.FrameShift.Tests.Unit/Reachability/ReachabilityClosurePolymorphismTests.cs index 0406219..8714ade 100644 --- a/tests/NetEvolve.FrameShift.Tests.Unit/Reachability/ReachabilityClosurePolymorphismTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Unit/Reachability/ReachabilityClosurePolymorphismTests.cs @@ -428,9 +428,16 @@ public async Task Compute_VirtualMethodWithOneOverride_ReachesTheOverrideAndItsH var reachable = ReachabilityClosure.Compute(compilation, manifest, CancellationToken.None); - _ = await Assert.That(reachable.Contains(Member(compilation, "Production.Renderer", "Render"))).IsTrue(); - _ = await Assert.That(reachable.Contains(Member(compilation, "Production.HtmlRenderer", "Render"))).IsTrue(); - _ = await Assert.That(reachable.Contains(Member(compilation, "Production.HtmlRenderer", "Decorate"))).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(reachable.Contains(Member(compilation, "Production.Renderer", "Render"))).IsTrue(); + _ = await Assert + .That(reachable.Contains(Member(compilation, "Production.HtmlRenderer", "Render"))) + .IsTrue(); + _ = await Assert + .That(reachable.Contains(Member(compilation, "Production.HtmlRenderer", "Decorate"))) + .IsTrue(); + } } [Test] @@ -441,8 +448,11 @@ public async Task Compute_MemberHidingTheVirtualMethodWithNew_StaysUnreachable() var reachable = ReachabilityClosure.Compute(compilation, manifest, CancellationToken.None); - _ = await Assert.That(reachable.Contains(Member(compilation, "Production.Shadowed", "Render"))).IsFalse(); - _ = await Assert.That(reachable.Contains(Member(compilation, "Production.Shadowed", "Hidden"))).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(reachable.Contains(Member(compilation, "Production.Shadowed", "Render"))).IsFalse(); + _ = await Assert.That(reachable.Contains(Member(compilation, "Production.Shadowed", "Hidden"))).IsFalse(); + } } [Test] @@ -464,13 +474,16 @@ public async Task Compute_OverrideOfAnUntouchedBase_StaysUnreachable() var reachable = ReachabilityClosure.Compute(compilation, manifest, CancellationToken.None); - _ = await Assert.That(reachable.Contains(Member(compilation, "Production.Untouched", "Idle"))).IsFalse(); - _ = await Assert - .That(reachable.Contains(Member(compilation, "Production.UntouchedOverride", "Idle"))) - .IsFalse(); - _ = await Assert - .That(reachable.Contains(Member(compilation, "Production.UntouchedOverride", "Never"))) - .IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(reachable.Contains(Member(compilation, "Production.Untouched", "Idle"))).IsFalse(); + _ = await Assert + .That(reachable.Contains(Member(compilation, "Production.UntouchedOverride", "Idle"))) + .IsFalse(); + _ = await Assert + .That(reachable.Contains(Member(compilation, "Production.UntouchedOverride", "Never"))) + .IsFalse(); + } } [Test] @@ -481,10 +494,15 @@ public async Task Compute_TwoLevelOverrideChainSeededAtTheBase_ReachesEveryLevel var reachable = ReachabilityClosure.Compute(compilation, manifest, CancellationToken.None); - _ = await Assert.That(reachable.Contains(Member(compilation, "Production.LayerBase", "Describe"))).IsTrue(); - _ = await Assert.That(reachable.Contains(Member(compilation, "Production.MiddleLayer", "Describe"))).IsTrue(); - _ = await Assert.That(reachable.Contains(Member(compilation, "Production.LeafLayer", "Describe"))).IsTrue(); - _ = await Assert.That(reachable.Contains(Member(compilation, "Production.LeafLayer", "Detail"))).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(reachable.Contains(Member(compilation, "Production.LayerBase", "Describe"))).IsTrue(); + _ = await Assert + .That(reachable.Contains(Member(compilation, "Production.MiddleLayer", "Describe"))) + .IsTrue(); + _ = await Assert.That(reachable.Contains(Member(compilation, "Production.LeafLayer", "Describe"))).IsTrue(); + _ = await Assert.That(reachable.Contains(Member(compilation, "Production.LeafLayer", "Detail"))).IsTrue(); + } } [Test] @@ -495,9 +513,16 @@ public async Task Compute_TwoLevelOverrideChainSeededInTheMiddle_ReachesDownward var reachable = ReachabilityClosure.Compute(compilation, manifest, CancellationToken.None); - _ = await Assert.That(reachable.Contains(Member(compilation, "Production.MiddleLayer", "Describe"))).IsTrue(); - _ = await Assert.That(reachable.Contains(Member(compilation, "Production.LeafLayer", "Describe"))).IsTrue(); - _ = await Assert.That(reachable.Contains(Member(compilation, "Production.LayerBase", "Describe"))).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert + .That(reachable.Contains(Member(compilation, "Production.MiddleLayer", "Describe"))) + .IsTrue(); + _ = await Assert.That(reachable.Contains(Member(compilation, "Production.LeafLayer", "Describe"))).IsTrue(); + _ = await Assert + .That(reachable.Contains(Member(compilation, "Production.LayerBase", "Describe"))) + .IsFalse(); + } } [Test] @@ -508,9 +533,12 @@ public async Task Compute_OverriddenProperty_ReachesTheOverridingAccessorBody() var reachable = ReachabilityClosure.Compute(compilation, manifest, CancellationToken.None); - _ = await Assert.That(reachable.Contains(Member(compilation, "Production.SettingsBase", "Name"))).IsTrue(); - _ = await Assert.That(reachable.Contains(Member(compilation, "Production.Settings", "Name"))).IsTrue(); - _ = await Assert.That(reachable.Contains(Member(compilation, "Production.Settings", "Compose"))).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(reachable.Contains(Member(compilation, "Production.SettingsBase", "Name"))).IsTrue(); + _ = await Assert.That(reachable.Contains(Member(compilation, "Production.Settings", "Name"))).IsTrue(); + _ = await Assert.That(reachable.Contains(Member(compilation, "Production.Settings", "Compose"))).IsTrue(); + } } [Test] @@ -521,9 +549,14 @@ public async Task Compute_OverriddenEvent_ReachesTheOverridingAccessorBody() var reachable = ReachabilityClosure.Compute(compilation, manifest, CancellationToken.None); - _ = await Assert.That(reachable.Contains(Member(compilation, "Production.SettingsBase", "Changed"))).IsTrue(); - _ = await Assert.That(reachable.Contains(Member(compilation, "Production.Settings", "Changed"))).IsTrue(); - _ = await Assert.That(reachable.Contains(Member(compilation, "Production.Settings", "Track"))).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert + .That(reachable.Contains(Member(compilation, "Production.SettingsBase", "Changed"))) + .IsTrue(); + _ = await Assert.That(reachable.Contains(Member(compilation, "Production.Settings", "Changed"))).IsTrue(); + _ = await Assert.That(reachable.Contains(Member(compilation, "Production.Settings", "Track"))).IsTrue(); + } } [Test] @@ -534,8 +567,11 @@ public async Task Compute_OverriddenEvent_DoesNotReachTheUnrelatedPropertyOverri var reachable = ReachabilityClosure.Compute(compilation, manifest, CancellationToken.None); - _ = await Assert.That(reachable.Contains(Member(compilation, "Production.Settings", "Name"))).IsFalse(); - _ = await Assert.That(reachable.Contains(Member(compilation, "Production.Settings", "Compose"))).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(reachable.Contains(Member(compilation, "Production.Settings", "Name"))).IsFalse(); + _ = await Assert.That(reachable.Contains(Member(compilation, "Production.Settings", "Compose"))).IsFalse(); + } } [Test] @@ -546,10 +582,15 @@ public async Task Compute_AbstractMemberWithTwoImplementations_ReachesBothOfThem var reachable = ReachabilityClosure.Compute(compilation, manifest, CancellationToken.None); - _ = await Assert.That(reachable.Contains(Member(compilation, "Production.AlwaysValid", "IsValid"))).IsTrue(); - _ = await Assert.That(reachable.Contains(Member(compilation, "Production.AlwaysValid", "Accept"))).IsTrue(); - _ = await Assert.That(reachable.Contains(Member(compilation, "Production.NeverValid", "IsValid"))).IsTrue(); - _ = await Assert.That(reachable.Contains(Member(compilation, "Production.NeverValid", "Reject"))).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert + .That(reachable.Contains(Member(compilation, "Production.AlwaysValid", "IsValid"))) + .IsTrue(); + _ = await Assert.That(reachable.Contains(Member(compilation, "Production.AlwaysValid", "Accept"))).IsTrue(); + _ = await Assert.That(reachable.Contains(Member(compilation, "Production.NeverValid", "IsValid"))).IsTrue(); + _ = await Assert.That(reachable.Contains(Member(compilation, "Production.NeverValid", "Reject"))).IsTrue(); + } } [Test] @@ -560,9 +601,12 @@ public async Task Compute_SealedOverride_IsReachedLikeAnyOtherOverride() var reachable = ReachabilityClosure.Compute(compilation, manifest, CancellationToken.None); - _ = await Assert.That(reachable.Contains(Member(compilation, "Production.TerminalBase", "Stop"))).IsTrue(); - _ = await Assert.That(reachable.Contains(Member(compilation, "Production.Terminal", "Stop"))).IsTrue(); - _ = await Assert.That(reachable.Contains(Member(compilation, "Production.Terminal", "Cleanup"))).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(reachable.Contains(Member(compilation, "Production.TerminalBase", "Stop"))).IsTrue(); + _ = await Assert.That(reachable.Contains(Member(compilation, "Production.Terminal", "Stop"))).IsTrue(); + _ = await Assert.That(reachable.Contains(Member(compilation, "Production.Terminal", "Cleanup"))).IsTrue(); + } } [Test] @@ -573,11 +617,20 @@ public async Task Compute_InterfaceMember_ReachesTheImplicitAndTheExplicitImplem var reachable = ReachabilityClosure.Compute(compilation, manifest, CancellationToken.None); - _ = await Assert.That(reachable.Contains(Member(compilation, "Production.IHandler", "Handle"))).IsTrue(); - _ = await Assert.That(reachable.Contains(Member(compilation, "Production.ImplicitHandler", "Handle"))).IsTrue(); - _ = await Assert.That(reachable.Contains(Member(compilation, "Production.ImplicitHandler", "Log"))).IsTrue(); - _ = await Assert.That(reachable.Contains(ExplicitImplementation(compilation, "Handle"))).IsTrue(); - _ = await Assert.That(reachable.Contains(Member(compilation, "Production.ExplicitHandler", "Trace"))).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(reachable.Contains(Member(compilation, "Production.IHandler", "Handle"))).IsTrue(); + _ = await Assert + .That(reachable.Contains(Member(compilation, "Production.ImplicitHandler", "Handle"))) + .IsTrue(); + _ = await Assert + .That(reachable.Contains(Member(compilation, "Production.ImplicitHandler", "Log"))) + .IsTrue(); + _ = await Assert.That(reachable.Contains(ExplicitImplementation(compilation, "Handle"))).IsTrue(); + _ = await Assert + .That(reachable.Contains(Member(compilation, "Production.ExplicitHandler", "Trace"))) + .IsTrue(); + } } [Test] @@ -588,9 +641,14 @@ public async Task Compute_InterfaceMemberThatIsNeverCalled_StaysUnreachableWithI var reachable = ReachabilityClosure.Compute(compilation, manifest, CancellationToken.None); - _ = await Assert.That(reachable.Contains(Member(compilation, "Production.IHandler", "Reset"))).IsFalse(); - _ = await Assert.That(reachable.Contains(Member(compilation, "Production.ImplicitHandler", "Reset"))).IsFalse(); - _ = await Assert.That(reachable.Contains(ExplicitImplementation(compilation, "Reset"))).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(reachable.Contains(Member(compilation, "Production.IHandler", "Reset"))).IsFalse(); + _ = await Assert + .That(reachable.Contains(Member(compilation, "Production.ImplicitHandler", "Reset"))) + .IsFalse(); + _ = await Assert.That(reachable.Contains(ExplicitImplementation(compilation, "Reset"))).IsFalse(); + } } [Test] @@ -601,9 +659,14 @@ public async Task Compute_InterfaceImplementedByABaseClass_ReachesTheInheritedIm var reachable = ReachabilityClosure.Compute(compilation, manifest, CancellationToken.None); - _ = await Assert.That(reachable.Contains(Member(compilation, "Production.IStarter", "Start"))).IsTrue(); - _ = await Assert.That(reachable.Contains(Member(compilation, "Production.StarterBase", "Start"))).IsTrue(); - _ = await Assert.That(reachable.Contains(Member(compilation, "Production.StarterBase", "Prepare"))).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(reachable.Contains(Member(compilation, "Production.IStarter", "Start"))).IsTrue(); + _ = await Assert.That(reachable.Contains(Member(compilation, "Production.StarterBase", "Start"))).IsTrue(); + _ = await Assert + .That(reachable.Contains(Member(compilation, "Production.StarterBase", "Prepare"))) + .IsTrue(); + } } #if !NETFRAMEWORK @@ -615,10 +678,13 @@ public async Task Compute_InterfaceMemberWithADefaultImplementation_ReachesTheDe var reachable = ReachabilityClosure.Compute(compilation, manifest, CancellationToken.None); - _ = await Assert.That(reachable.Contains(Member(compilation, "Production.IPinger", "Ping"))).IsTrue(); - _ = await Assert.That(reachable.Contains(Member(compilation, "Production.IPinger", "Pong"))).IsTrue(); - _ = await Assert.That(reachable.Contains(Member(compilation, "Production.Pinger", "Pong"))).IsTrue(); - _ = await Assert.That(reachable.Contains(Member(compilation, "Production.Pinger", "Track"))).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(reachable.Contains(Member(compilation, "Production.IPinger", "Ping"))).IsTrue(); + _ = await Assert.That(reachable.Contains(Member(compilation, "Production.IPinger", "Pong"))).IsTrue(); + _ = await Assert.That(reachable.Contains(Member(compilation, "Production.Pinger", "Pong"))).IsTrue(); + _ = await Assert.That(reachable.Contains(Member(compilation, "Production.Pinger", "Track"))).IsTrue(); + } } #endif @@ -630,9 +696,16 @@ public async Task Compute_ConstructedGenericInterface_ReachesTheMatchingImplemen var reachable = ReachabilityClosure.Compute(compilation, manifest, CancellationToken.None); - _ = await Assert.That(reachable.Contains(Member(compilation, "Production.IRepository`1", "Get"))).IsTrue(); - _ = await Assert.That(reachable.Contains(Member(compilation, "Production.StringRepository", "Get"))).IsTrue(); - _ = await Assert.That(reachable.Contains(Member(compilation, "Production.StringRepository", "Load"))).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(reachable.Contains(Member(compilation, "Production.IRepository`1", "Get"))).IsTrue(); + _ = await Assert + .That(reachable.Contains(Member(compilation, "Production.StringRepository", "Get"))) + .IsTrue(); + _ = await Assert + .That(reachable.Contains(Member(compilation, "Production.StringRepository", "Load"))) + .IsTrue(); + } } [Test] @@ -643,8 +716,15 @@ public async Task Compute_ConstructedGenericInterface_DoesNotReachAnotherConstru var reachable = ReachabilityClosure.Compute(compilation, manifest, CancellationToken.None); - _ = await Assert.That(reachable.Contains(Member(compilation, "Production.Int32Repository", "Get"))).IsFalse(); - _ = await Assert.That(reachable.Contains(Member(compilation, "Production.Int32Repository", "Count"))).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert + .That(reachable.Contains(Member(compilation, "Production.Int32Repository", "Get"))) + .IsFalse(); + _ = await Assert + .That(reachable.Contains(Member(compilation, "Production.Int32Repository", "Count"))) + .IsFalse(); + } } [Test] @@ -655,9 +735,12 @@ public async Task Compute_ConstructedGenericMethod_ReachesTheOverrideOfItsOrigin var reachable = ReachabilityClosure.Compute(compilation, manifest, CancellationToken.None); - _ = await Assert.That(reachable.Contains(Member(compilation, "Production.MapperBase", "Map"))).IsTrue(); - _ = await Assert.That(reachable.Contains(Member(compilation, "Production.Mapper", "Map"))).IsTrue(); - _ = await Assert.That(reachable.Contains(Member(compilation, "Production.Mapper", "Create"))).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(reachable.Contains(Member(compilation, "Production.MapperBase", "Map"))).IsTrue(); + _ = await Assert.That(reachable.Contains(Member(compilation, "Production.Mapper", "Map"))).IsTrue(); + _ = await Assert.That(reachable.Contains(Member(compilation, "Production.Mapper", "Create"))).IsTrue(); + } } [Test] @@ -696,10 +779,13 @@ public async Task Compute_ReferenceToASymbolWithoutAContainingAssembly_IsIgnored var reachable = ReachabilityClosure.Compute(compilation, manifest, CancellationToken.None); - _ = await Assert - .That(reachable.Contains(Member(compilation, "Production.TypeReferences", "ArrayType"))) - .IsTrue(); - _ = await Assert.That(reachable.Count).IsEqualTo(1); + using (Assert.Multiple()) + { + _ = await Assert + .That(reachable.Contains(Member(compilation, "Production.TypeReferences", "ArrayType"))) + .IsTrue(); + _ = await Assert.That(reachable.Count).IsEqualTo(1); + } } /// @@ -714,9 +800,18 @@ public async Task Compute_InterfaceImplementationFromAReferencedAssembly_IsSkipp var reachable = ReachabilityClosure.Compute(compilation, manifest, CancellationToken.None); - _ = await Assert.That(reachable.Contains(Member(compilation, "Production.ExternalConsumer", "Use"))).IsTrue(); - _ = await Assert.That(reachable.Contains(Member(compilation, "External.ExternalWorkerBase", "Work"))).IsFalse(); - _ = await Assert.That(reachable.Contains(Member(compilation, "External.IExternalWorker", "Work"))).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert + .That(reachable.Contains(Member(compilation, "Production.ExternalConsumer", "Use"))) + .IsTrue(); + _ = await Assert + .That(reachable.Contains(Member(compilation, "External.ExternalWorkerBase", "Work"))) + .IsFalse(); + _ = await Assert + .That(reachable.Contains(Member(compilation, "External.IExternalWorker", "Work"))) + .IsFalse(); + } } /// @@ -733,8 +828,13 @@ public async Task Compute_SeededInterfaceMember_AlsoReachesItsImplementations() var reachable = ReachabilityClosure.Compute(compilation, manifest, CancellationToken.None); - _ = await Assert.That(reachable.Contains(Member(compilation, "Production.ImplicitHandler", "Handle"))).IsTrue(); - _ = await Assert.That(reachable.Contains(ExplicitImplementation(compilation, "Handle"))).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert + .That(reachable.Contains(Member(compilation, "Production.ImplicitHandler", "Handle"))) + .IsTrue(); + _ = await Assert.That(reachable.Contains(ExplicitImplementation(compilation, "Handle"))).IsTrue(); + } } /// @@ -749,8 +849,15 @@ public async Task Compute_SeededVirtualMethod_AlsoReachesItsOverride() var reachable = ReachabilityClosure.Compute(compilation, manifest, CancellationToken.None); - _ = await Assert.That(reachable.Contains(Member(compilation, "Production.HtmlRenderer", "Render"))).IsTrue(); - _ = await Assert.That(reachable.Contains(Member(compilation, "Production.HtmlRenderer", "Decorate"))).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert + .That(reachable.Contains(Member(compilation, "Production.HtmlRenderer", "Render"))) + .IsTrue(); + _ = await Assert + .That(reachable.Contains(Member(compilation, "Production.HtmlRenderer", "Decorate"))) + .IsTrue(); + } } private static CSharpCompilation CreateExternalConsumerCompilation() => @@ -794,12 +901,15 @@ public async Task ComputeFromReferences_ChainEnteredAtTwoLevels_UnionsTheAttribu var reachable = ReachabilityClosure.ComputeFromReferences(compilation, references, CancellationToken.None); - _ = await Assert - .That(Describe(reachable, Member(compilation, "Production.LeafLayer", "Describe"))) - .IsEqualTo($"{BaseTestId}, {MiddleTestId}"); - _ = await Assert - .That(Describe(reachable, Member(compilation, "Production.MiddleLayer", "Describe"))) - .IsEqualTo($"{BaseTestId}, {MiddleTestId}"); + using (Assert.Multiple()) + { + _ = await Assert + .That(Describe(reachable, Member(compilation, "Production.LeafLayer", "Describe"))) + .IsEqualTo($"{BaseTestId}, {MiddleTestId}"); + _ = await Assert + .That(Describe(reachable, Member(compilation, "Production.MiddleLayer", "Describe"))) + .IsEqualTo($"{BaseTestId}, {MiddleTestId}"); + } } /// @@ -817,12 +927,15 @@ public async Task ComputeFromReferences_ChainEnteredAtTwoLevels_KeepsTheBaseDecl var reachable = ReachabilityClosure.ComputeFromReferences(compilation, references, CancellationToken.None); - _ = await Assert - .That(Describe(reachable, Member(compilation, "Production.LayerBase", "Describe"))) - .IsEqualTo(BaseTestId); - _ = await Assert - .That(Describe(reachable, Member(compilation, "Production.LeafLayer", "Detail"))) - .IsEqualTo($"{BaseTestId}, {MiddleTestId}"); + using (Assert.Multiple()) + { + _ = await Assert + .That(Describe(reachable, Member(compilation, "Production.LayerBase", "Describe"))) + .IsEqualTo(BaseTestId); + _ = await Assert + .That(Describe(reachable, Member(compilation, "Production.LeafLayer", "Detail"))) + .IsEqualTo($"{BaseTestId}, {MiddleTestId}"); + } } /// @@ -837,13 +950,18 @@ public async Task ComputeFromReferences_SeededInterfaceMember_AttributesTheImple var reachable = ReachabilityClosure.ComputeFromReferences(compilation, references, CancellationToken.None); - _ = await Assert - .That(Describe(reachable, Member(compilation, "Production.ImplicitHandler", "Handle"))) - .IsEqualTo(BaseTestId); - _ = await Assert.That(Describe(reachable, ExplicitImplementation(compilation, "Handle"))).IsEqualTo(BaseTestId); - _ = await Assert - .That(Describe(reachable, Member(compilation, "Production.ImplicitHandler", "Log"))) - .IsEqualTo(BaseTestId); + using (Assert.Multiple()) + { + _ = await Assert + .That(Describe(reachable, Member(compilation, "Production.ImplicitHandler", "Handle"))) + .IsEqualTo(BaseTestId); + _ = await Assert + .That(Describe(reachable, ExplicitImplementation(compilation, "Handle"))) + .IsEqualTo(BaseTestId); + _ = await Assert + .That(Describe(reachable, Member(compilation, "Production.ImplicitHandler", "Log"))) + .IsEqualTo(BaseTestId); + } } [Test] @@ -857,12 +975,15 @@ public async Task ComputeFromReferences_AbstractMemberReachedByTwoTests_Attribut var reachable = ReachabilityClosure.ComputeFromReferences(compilation, references, CancellationToken.None); - _ = await Assert - .That(Describe(reachable, Member(compilation, "Production.AlwaysValid", "Accept"))) - .IsEqualTo($"{BaseTestId}, {MiddleTestId}"); - _ = await Assert - .That(Describe(reachable, Member(compilation, "Production.NeverValid", "Reject"))) - .IsEqualTo($"{BaseTestId}, {MiddleTestId}"); + using (Assert.Multiple()) + { + _ = await Assert + .That(Describe(reachable, Member(compilation, "Production.AlwaysValid", "Accept"))) + .IsEqualTo($"{BaseTestId}, {MiddleTestId}"); + _ = await Assert + .That(Describe(reachable, Member(compilation, "Production.NeverValid", "Reject"))) + .IsEqualTo($"{BaseTestId}, {MiddleTestId}"); + } } private static TestSurfaceManifest Manifest(params string[] referencedMemberIds) => diff --git a/tests/NetEvolve.FrameShift.Tests.Unit/Reachability/ReachabilityClosureTests.cs b/tests/NetEvolve.FrameShift.Tests.Unit/Reachability/ReachabilityClosureTests.cs index f30e63c..25ba43d 100644 --- a/tests/NetEvolve.FrameShift.Tests.Unit/Reachability/ReachabilityClosureTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Unit/Reachability/ReachabilityClosureTests.cs @@ -179,9 +179,12 @@ public async Task Compute_CallChain_ContainsTheTransitivelyReachedMembers() CancellationToken.None ); - _ = await Assert.That(reachable.Contains(Method(compilation, "Production.Chain", "A"))).IsTrue(); - _ = await Assert.That(reachable.Contains(Method(compilation, "Production.Chain", "B"))).IsTrue(); - _ = await Assert.That(reachable.Contains(Method(compilation, "Production.Chain", "C"))).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(reachable.Contains(Method(compilation, "Production.Chain", "A"))).IsTrue(); + _ = await Assert.That(reachable.Contains(Method(compilation, "Production.Chain", "B"))).IsTrue(); + _ = await Assert.That(reachable.Contains(Method(compilation, "Production.Chain", "C"))).IsTrue(); + } } [Test] @@ -195,8 +198,11 @@ public async Task Compute_CallChain_DoesNotContainTheUntouchedMember() CancellationToken.None ); - _ = await Assert.That(reachable.Contains(Method(compilation, "Production.Chain", "D"))).IsFalse(); - _ = await Assert.That(reachable.Count).IsEqualTo(3); + using (Assert.Multiple()) + { + _ = await Assert.That(reachable.Contains(Method(compilation, "Production.Chain", "D"))).IsFalse(); + _ = await Assert.That(reachable.Count).IsEqualTo(3); + } } [Test] @@ -218,8 +224,11 @@ public async Task Compute_UnresolvableIdNextToAValidOne_KeepsTheValidSeed() var reachable = ReachabilityClosure.Compute(compilation, manifest, CancellationToken.None); - _ = await Assert.That(reachable.Contains(Method(compilation, "Production.Chain", "A"))).IsTrue(); - _ = await Assert.That(reachable.Count).IsEqualTo(3); + using (Assert.Multiple()) + { + _ = await Assert.That(reachable.Contains(Method(compilation, "Production.Chain", "A"))).IsTrue(); + _ = await Assert.That(reachable.Count).IsEqualTo(3); + } } [Test] @@ -229,8 +238,11 @@ public async Task Compute_EmptyManifest_ReturnsTheEmptySet() var reachable = ReachabilityClosure.Compute(compilation, TestSurfaceManifest.Empty, CancellationToken.None); - _ = await Assert.That(reachable.IsEmpty).IsTrue(); - _ = await Assert.That(reachable.Count).IsEqualTo(0); + using (Assert.Multiple()) + { + _ = await Assert.That(reachable.IsEmpty).IsTrue(); + _ = await Assert.That(reachable.Count).IsEqualTo(0); + } } [Test] @@ -244,9 +256,12 @@ public async Task Compute_CyclicCallGraph_Terminates() CancellationToken.None ); - _ = await Assert.That(reachable.Contains(Method(compilation, "Production.Cycle", "First"))).IsTrue(); - _ = await Assert.That(reachable.Contains(Method(compilation, "Production.Cycle", "Second"))).IsTrue(); - _ = await Assert.That(reachable.Count).IsEqualTo(2); + using (Assert.Multiple()) + { + _ = await Assert.That(reachable.Contains(Method(compilation, "Production.Cycle", "First"))).IsTrue(); + _ = await Assert.That(reachable.Contains(Method(compilation, "Production.Cycle", "Second"))).IsTrue(); + _ = await Assert.That(reachable.Count).IsEqualTo(2); + } } [Test] @@ -257,8 +272,11 @@ public async Task Compute_InterfaceMember_AlsoReachesItsImplementation() var reachable = ReachabilityClosure.Compute(compilation, manifest, CancellationToken.None); - _ = await Assert.That(reachable.Contains(Method(compilation, "Production.IGreeter", "Greet"))).IsTrue(); - _ = await Assert.That(reachable.Contains(Method(compilation, "Production.Greeter", "Greet"))).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(reachable.Contains(Method(compilation, "Production.IGreeter", "Greet"))).IsTrue(); + _ = await Assert.That(reachable.Contains(Method(compilation, "Production.Greeter", "Greet"))).IsTrue(); + } } [Test] @@ -269,8 +287,11 @@ public async Task Compute_AbstractMember_AlsoReachesItsOverride() var reachable = ReachabilityClosure.Compute(compilation, manifest, CancellationToken.None); - _ = await Assert.That(reachable.Contains(Method(compilation, "Production.ShapeBase", "Area"))).IsTrue(); - _ = await Assert.That(reachable.Contains(Method(compilation, "Production.Square", "Area"))).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(reachable.Contains(Method(compilation, "Production.ShapeBase", "Area"))).IsTrue(); + _ = await Assert.That(reachable.Contains(Method(compilation, "Production.Square", "Area"))).IsTrue(); + } } [Test] @@ -292,8 +313,11 @@ public async Task ContainsEnclosing_SymbolInsideALambda_IsAttributedToItsEnclosi var lambdaSymbol = semanticModel.GetSymbolInfo(lambda).Symbol!; var reachable = new ReachableSymbolSet([Method(compilation, "Production.Enclosing", "WithLambda")]); - _ = await Assert.That(reachable.Contains(lambdaSymbol)).IsFalse(); - _ = await Assert.That(reachable.ContainsEnclosing(lambdaSymbol)).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(reachable.Contains(lambdaSymbol)).IsFalse(); + _ = await Assert.That(reachable.ContainsEnclosing(lambdaSymbol)).IsTrue(); + } } [Test] @@ -304,8 +328,11 @@ public async Task ContainsEnclosing_SymbolInsideALocalFunction_IsAttributedToIts var localFunctionSymbol = semanticModel.GetDeclaredSymbol(localFunction)!; var reachable = new ReachableSymbolSet([Method(compilation, "Production.Enclosing", "WithLocalFunction")]); - _ = await Assert.That(reachable.Contains(localFunctionSymbol)).IsFalse(); - _ = await Assert.That(reachable.ContainsEnclosing(localFunctionSymbol)).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(reachable.Contains(localFunctionSymbol)).IsFalse(); + _ = await Assert.That(reachable.ContainsEnclosing(localFunctionSymbol)).IsTrue(); + } } [Test] @@ -373,9 +400,18 @@ public async Task ComputeFromReferences_CallChain_AttributesEveryTransitiveMembe var reachable = ReachabilityClosure.ComputeFromReferences(compilation, references, CancellationToken.None); - _ = await Assert.That(Describe(reachable, Method(compilation, "Production.Chain", "A"))).IsEqualTo(LeftTestId); - _ = await Assert.That(Describe(reachable, Method(compilation, "Production.Chain", "B"))).IsEqualTo(LeftTestId); - _ = await Assert.That(Describe(reachable, Method(compilation, "Production.Chain", "C"))).IsEqualTo(LeftTestId); + using (Assert.Multiple()) + { + _ = await Assert + .That(Describe(reachable, Method(compilation, "Production.Chain", "A"))) + .IsEqualTo(LeftTestId); + _ = await Assert + .That(Describe(reachable, Method(compilation, "Production.Chain", "B"))) + .IsEqualTo(LeftTestId); + _ = await Assert + .That(Describe(reachable, Method(compilation, "Production.Chain", "C"))) + .IsEqualTo(LeftTestId); + } } [Test] @@ -405,12 +441,15 @@ public async Task ComputeFromReferences_DiamondWithTwoSeededTests_UnionsTheAttri var reachable = ReachabilityClosure.ComputeFromReferences(compilation, references, CancellationToken.None); - _ = await Assert - .That(Describe(reachable, Method(compilation, "Production.Diamond", "Shared"))) - .IsEqualTo($"{LeftTestId}, {RightTestId}"); - _ = await Assert - .That(Describe(reachable, Method(compilation, "Production.Diamond", "Deep"))) - .IsEqualTo($"{LeftTestId}, {RightTestId}"); + using (Assert.Multiple()) + { + _ = await Assert + .That(Describe(reachable, Method(compilation, "Production.Diamond", "Shared"))) + .IsEqualTo($"{LeftTestId}, {RightTestId}"); + _ = await Assert + .That(Describe(reachable, Method(compilation, "Production.Diamond", "Deep"))) + .IsEqualTo($"{LeftTestId}, {RightTestId}"); + } } [Test] @@ -424,12 +463,15 @@ public async Task ComputeFromReferences_DiamondWithTwoSeededTests_KeepsTheBranch var reachable = ReachabilityClosure.ComputeFromReferences(compilation, references, CancellationToken.None); - _ = await Assert - .That(Describe(reachable, Method(compilation, "Production.Diamond", "ThroughLeft"))) - .IsEqualTo(LeftTestId); - _ = await Assert - .That(Describe(reachable, Method(compilation, "Production.Diamond", "ThroughRight"))) - .IsEqualTo(RightTestId); + using (Assert.Multiple()) + { + _ = await Assert + .That(Describe(reachable, Method(compilation, "Production.Diamond", "ThroughLeft"))) + .IsEqualTo(LeftTestId); + _ = await Assert + .That(Describe(reachable, Method(compilation, "Production.Diamond", "ThroughRight"))) + .IsEqualTo(RightTestId); + } } /// @@ -448,12 +490,15 @@ public async Task ComputeFromReferences_PathsOfDifferentLength_PropagateTheWiden var reachable = ReachabilityClosure.ComputeFromReferences(compilation, references, CancellationToken.None); - _ = await Assert - .That(Describe(reachable, Method(compilation, "Production.Lengths", "Target"))) - .IsEqualTo($"{LeftTestId}, {RightTestId}"); - _ = await Assert - .That(Describe(reachable, Method(compilation, "Production.Lengths", "Tail"))) - .IsEqualTo($"{LeftTestId}, {RightTestId}"); + using (Assert.Multiple()) + { + _ = await Assert + .That(Describe(reachable, Method(compilation, "Production.Lengths", "Target"))) + .IsEqualTo($"{LeftTestId}, {RightTestId}"); + _ = await Assert + .That(Describe(reachable, Method(compilation, "Production.Lengths", "Tail"))) + .IsEqualTo($"{LeftTestId}, {RightTestId}"); + } } [Test] @@ -464,12 +509,15 @@ public async Task ComputeFromReferences_TwoTestsSeedingTheSameMember_UnionTheAtt var reachable = ReachabilityClosure.ComputeFromReferences(compilation, references, CancellationToken.None); - _ = await Assert - .That(Describe(reachable, Method(compilation, "Production.Chain", "A"))) - .IsEqualTo($"{LeftTestId}, {RightTestId}"); - _ = await Assert - .That(Describe(reachable, Method(compilation, "Production.Chain", "C"))) - .IsEqualTo($"{LeftTestId}, {RightTestId}"); + using (Assert.Multiple()) + { + _ = await Assert + .That(Describe(reachable, Method(compilation, "Production.Chain", "A"))) + .IsEqualTo($"{LeftTestId}, {RightTestId}"); + _ = await Assert + .That(Describe(reachable, Method(compilation, "Production.Chain", "C"))) + .IsEqualTo($"{LeftTestId}, {RightTestId}"); + } } [Test] @@ -480,12 +528,15 @@ public async Task ComputeFromReferences_CyclicCallGraph_AttributesBothMembersAnd var reachable = ReachabilityClosure.ComputeFromReferences(compilation, references, CancellationToken.None); - _ = await Assert - .That(Describe(reachable, Method(compilation, "Production.Cycle", "First"))) - .IsEqualTo(LeftTestId); - _ = await Assert - .That(Describe(reachable, Method(compilation, "Production.Cycle", "Second"))) - .IsEqualTo(LeftTestId); + using (Assert.Multiple()) + { + _ = await Assert + .That(Describe(reachable, Method(compilation, "Production.Cycle", "First"))) + .IsEqualTo(LeftTestId); + _ = await Assert + .That(Describe(reachable, Method(compilation, "Production.Cycle", "Second"))) + .IsEqualTo(LeftTestId); + } } [Test] @@ -510,8 +561,11 @@ public async Task ComputeFromReferences_NoReferenceAtAll_ReturnsTheEmptySet() CancellationToken.None ); - _ = await Assert.That(reachable.IsEmpty).IsTrue(); - _ = await Assert.That(reachable.Count).IsEqualTo(0); + using (Assert.Multiple()) + { + _ = await Assert.That(reachable.IsEmpty).IsTrue(); + _ = await Assert.That(reachable.Count).IsEqualTo(0); + } } [Test] @@ -569,8 +623,13 @@ public async Task Compute_ManifestWithoutAttribution_KeepsTheMembersReachableAnd CancellationToken.None ); - _ = await Assert.That(reachable.Contains(Method(compilation, "Production.Chain", "C"))).IsTrue(); - _ = await Assert.That(Describe(reachable, Method(compilation, "Production.Chain", "C"))).IsEqualTo(NoTestIds); + using (Assert.Multiple()) + { + _ = await Assert.That(reachable.Contains(Method(compilation, "Production.Chain", "C"))).IsTrue(); + _ = await Assert + .That(Describe(reachable, Method(compilation, "Production.Chain", "C"))) + .IsEqualTo(NoTestIds); + } } [Test] @@ -605,10 +664,13 @@ public async Task GetEnclosingTestIds_SymbolInsideALambda_InheritsTheAttribution var reachable = ReachabilityClosure.ComputeFromReferences(compilation, references, CancellationToken.None); - _ = await Assert - .That(Describe(reachable, Method(compilation, "Production.Enclosing", "WithLambda"))) - .IsEqualTo(LeftTestId); - _ = await Assert.That(Describe(reachable.GetEnclosingTestIds(lambdaSymbol))).IsEqualTo(LeftTestId); + using (Assert.Multiple()) + { + _ = await Assert + .That(Describe(reachable, Method(compilation, "Production.Enclosing", "WithLambda"))) + .IsEqualTo(LeftTestId); + _ = await Assert.That(Describe(reachable.GetEnclosingTestIds(lambdaSymbol))).IsEqualTo(LeftTestId); + } } [Test] @@ -639,8 +701,11 @@ public async Task GetEnclosingTestIds_LocalFunction_MatchesTheAttributionOfItsEn var reachable = ReachabilityClosure.ComputeFromReferences(compilation, references, CancellationToken.None); - _ = await Assert.That(Describe(reachable, localFunctionSymbol)).IsEqualTo(LeftTestId); - _ = await Assert.That(Describe(reachable.GetEnclosingTestIds(localFunctionSymbol))).IsEqualTo(LeftTestId); + using (Assert.Multiple()) + { + _ = await Assert.That(Describe(reachable, localFunctionSymbol)).IsEqualTo(LeftTestId); + _ = await Assert.That(Describe(reachable.GetEnclosingTestIds(localFunctionSymbol))).IsEqualTo(LeftTestId); + } } private static TestSurfaceManifest Manifest(params string[] referencedMemberIds) => diff --git a/tests/NetEvolve.FrameShift.Tests.Unit/Reachability/ReachableSymbolSetTests.cs b/tests/NetEvolve.FrameShift.Tests.Unit/Reachability/ReachableSymbolSetTests.cs index 65cd2ef..1b38b1a 100644 --- a/tests/NetEvolve.FrameShift.Tests.Unit/Reachability/ReachableSymbolSetTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Unit/Reachability/ReachableSymbolSetTests.cs @@ -78,8 +78,11 @@ public async Task Constructor_NullEntriesAndRepetitions_AreDropped() var set = new ReachableSymbolSet([null!, untested, untested]); - _ = await Assert.That(set.Count).IsEqualTo(1); - _ = await Assert.That(set.Contains(untested)).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(set.Count).IsEqualTo(1); + _ = await Assert.That(set.Contains(untested)).IsTrue(); + } } [Test] @@ -87,8 +90,11 @@ public async Task Empty_TheSharedSet_HoldsNothing() { var set = ReachableSymbolSet.Empty; - _ = await Assert.That(set.IsEmpty).IsTrue(); - _ = await Assert.That(set.Count).IsEqualTo(0); + using (Assert.Multiple()) + { + _ = await Assert.That(set.IsEmpty).IsTrue(); + _ = await Assert.That(set.Count).IsEqualTo(0); + } } [Test] @@ -101,8 +107,11 @@ public async Task IsEmpty_PopulatedSet_ReturnsFalse() Method(compilation, "Production.Holder", "Nested"), ]); - _ = await Assert.That(set.IsEmpty).IsFalse(); - _ = await Assert.That(set.Count).IsEqualTo(2); + using (Assert.Multiple()) + { + _ = await Assert.That(set.IsEmpty).IsFalse(); + _ = await Assert.That(set.Count).IsEqualTo(2); + } } [Test] @@ -126,8 +135,11 @@ public async Task NormalizeDefinition_ReducedExtensionMethod_ReturnsTheDeclaredM var normalized = ReachableSymbolSet.NormalizeDefinition(reduced); - _ = await Assert.That(reduced.ReducedFrom).IsNotNull(); - _ = await Assert.That(SymbolEqualityComparer.Default.Equals(normalized, declared)).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(reduced.ReducedFrom).IsNotNull(); + _ = await Assert.That(SymbolEqualityComparer.Default.Equals(normalized, declared)).IsTrue(); + } } [Test] @@ -171,8 +183,11 @@ public async Task Contains_AccessorOfARecordedProperty_ReturnsTrue() var property = Property(compilation, "Production.Holder", "Value"); var set = new ReachableSymbolSet([property]); - _ = await Assert.That(set.Contains(property.GetMethod!)).IsTrue(); - _ = await Assert.That(set.Contains(property.SetMethod!)).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(set.Contains(property.GetMethod!)).IsTrue(); + _ = await Assert.That(set.Contains(property.SetMethod!)).IsTrue(); + } } [Test] @@ -191,8 +206,11 @@ public async Task ContainsEnclosing_SymbolIsNull_ReturnsFalseEvenForAPopulatedSe var compilation = CompilationFactory.Create(SetSource); var set = new ReachableSymbolSet([Method(compilation, "Production.Holder", "Nested")]); - _ = await Assert.That(set.IsEmpty).IsFalse(); - _ = await Assert.That(set.ContainsEnclosing(null)).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(set.IsEmpty).IsFalse(); + _ = await Assert.That(set.ContainsEnclosing(null)).IsFalse(); + } } [Test] @@ -216,8 +234,11 @@ public async Task ContainsEnclosing_NestedLocalFunction_IsAttributedToTheEnclosi var inner = LocalFunction(semanticModel, tree, "Inner"); var set = new ReachableSymbolSet([Method(compilation, "Production.Holder", "Nested")]); - _ = await Assert.That(set.Contains(inner)).IsFalse(); - _ = await Assert.That(set.ContainsEnclosing(inner)).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(set.Contains(inner)).IsFalse(); + _ = await Assert.That(set.ContainsEnclosing(inner)).IsTrue(); + } } [Test] diff --git a/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/MSTestFrameworkProbeTests.cs b/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/MSTestFrameworkProbeTests.cs index b473ba9..ea1ac5d 100644 --- a/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/MSTestFrameworkProbeTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/MSTestFrameworkProbeTests.cs @@ -159,8 +159,11 @@ public async Task TryCreateRecognizer_WithFrameworkReference_RecognisesOnlyTheDe var compilation = CreateMSTest(); var recognizer = MSTestTestFrameworkProbe.Instance.TryCreateRecognizer(compilation)!; - _ = await Assert.That(recognizer.IsTestMethod(FindMethod(compilation, DecoratedTestName))).IsTrue(); - _ = await Assert.That(recognizer.IsTestMethod(FindMethod(compilation, PlainMethodName))).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(recognizer.IsTestMethod(FindMethod(compilation, DecoratedTestName))).IsTrue(); + _ = await Assert.That(recognizer.IsTestMethod(FindMethod(compilation, PlainMethodName))).IsFalse(); + } } [Test] @@ -190,9 +193,12 @@ public async Task TryCreateRecognizer_AttributeTypeWithoutTheFrameworkAssembly_R var recognizer = MSTestTestFrameworkProbe.Instance.TryCreateRecognizer(compilation); - _ = await Assert.That(recognizer).IsNotNull(); - _ = await Assert.That(recognizer!.IsTestMethod(FindMethod(compilation, DecoratedTestName))).IsTrue(); - _ = await Assert.That(recognizer.IsTestMethod(FindMethod(compilation, PlainMethodName))).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(recognizer).IsNotNull(); + _ = await Assert.That(recognizer!.IsTestMethod(FindMethod(compilation, DecoratedTestName))).IsTrue(); + _ = await Assert.That(recognizer.IsTestMethod(FindMethod(compilation, PlainMethodName))).IsFalse(); + } } /// @@ -208,9 +214,12 @@ public async Task TryCreateRecognizer_FrameworkAssemblyWithoutTheAttributeType_F var recognizer = MSTestTestFrameworkProbe.Instance.TryCreateRecognizer(compilation); - _ = await Assert.That(MSTestTestFrameworkProbe.GetTestAttributeType(compilation)).IsNull(); - _ = await Assert.That(recognizer?.FrameworkName).IsEqualTo("MSTest"); - _ = await Assert.That(recognizer!.IsTestMethod(FindMethod(compilation, PlainMethodName))).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(MSTestTestFrameworkProbe.GetTestAttributeType(compilation)).IsNull(); + _ = await Assert.That(recognizer?.FrameworkName).IsEqualTo("MSTest"); + _ = await Assert.That(recognizer!.IsTestMethod(FindMethod(compilation, PlainMethodName))).IsFalse(); + } } /// @@ -227,10 +236,13 @@ public async Task TryCreateRecognizer_WithAnAmbiguousAttributeType_StillRecognis var recognizer = MSTestTestFrameworkProbe.Instance.TryCreateRecognizer(compilation); - _ = await Assert.That(MSTestTestFrameworkProbe.GetTestAttributeType(compilation)).IsNull(); - _ = await Assert.That(recognizer).IsNotNull(); - _ = await Assert.That(recognizer!.IsTestMethod(FindMethod(compilation, DecoratedTestName))).IsTrue(); - _ = await Assert.That(recognizer.IsTestMethod(FindMethod(compilation, PlainMethodName))).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(MSTestTestFrameworkProbe.GetTestAttributeType(compilation)).IsNull(); + _ = await Assert.That(recognizer).IsNotNull(); + _ = await Assert.That(recognizer!.IsTestMethod(FindMethod(compilation, DecoratedTestName))).IsTrue(); + _ = await Assert.That(recognizer.IsTestMethod(FindMethod(compilation, PlainMethodName))).IsFalse(); + } } [Test] @@ -252,8 +264,11 @@ public async Task IsFrameworkAssembly_AssemblyName_IsClassifiedByItsPrefix() var framework = SatelliteAssembly(frameworkConsumer, FrameworkAssemblyName); var foreign = SatelliteAssembly(foreignConsumer, ForeignAssemblyName); - _ = await Assert.That(MSTestTestFrameworkProbe.IsFrameworkAssembly(framework)).IsTrue(); - _ = await Assert.That(MSTestTestFrameworkProbe.IsFrameworkAssembly(foreign)).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(MSTestTestFrameworkProbe.IsFrameworkAssembly(framework)).IsTrue(); + _ = await Assert.That(MSTestTestFrameworkProbe.IsFrameworkAssembly(foreign)).IsFalse(); + } } /// diff --git a/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/MSTestMethodRecognizerTests.cs b/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/MSTestMethodRecognizerTests.cs index 9d01399..a7847c4 100644 --- a/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/MSTestMethodRecognizerTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/MSTestMethodRecognizerTests.cs @@ -453,8 +453,11 @@ public async Task IsTestMethod_WithoutTheWellKnownType_UsesTheNameRule() var compilation = CreateSatelliteConsumer(FrameworkAssemblyName); var recognizer = new MSTestTestMethodRecognizer(null); - _ = await Assert.That(recognizer.IsTestMethod(FindMethod(compilation, DecoratedTestName))).IsTrue(); - _ = await Assert.That(recognizer.IsTestMethod(FindMethod(compilation, PlainMethodName))).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(recognizer.IsTestMethod(FindMethod(compilation, DecoratedTestName))).IsTrue(); + _ = await Assert.That(recognizer.IsTestMethod(FindMethod(compilation, PlainMethodName))).IsFalse(); + } } /// @@ -489,8 +492,13 @@ bool expected var compilation = CreateSatelliteConsumer(SatelliteDerivedConsumerSource, satelliteAssemblyName); var recognizer = new MSTestTestMethodRecognizer(null); - _ = await Assert.That(recognizer.IsTestMethod(FindMethod(compilation, DecoratedTestName))).IsEqualTo(expected); - _ = await Assert.That(recognizer.IsTestMethod(FindMethod(compilation, PlainMethodName))).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert + .That(recognizer.IsTestMethod(FindMethod(compilation, DecoratedTestName))) + .IsEqualTo(expected); + _ = await Assert.That(recognizer.IsTestMethod(FindMethod(compilation, PlainMethodName))).IsFalse(); + } } /// @@ -573,8 +581,11 @@ public async Task GetTestCaseCount_ShapeThatIsWrittenDown_IsCountedExactly(strin var count = recognizer.GetTestCaseCount(method); - _ = await Assert.That(count.Value).IsEqualTo(expected); - _ = await Assert.That(count.IsExact).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(count.Value).IsEqualTo(expected); + _ = await Assert.That(count.IsExact).IsTrue(); + } } /// @@ -598,8 +609,11 @@ public async Task GetTestCaseCount_ShapeThatIsNotWrittenDown_IsALowerBound(strin var count = recognizer.GetTestCaseCount(method); - _ = await Assert.That(count.Value).IsEqualTo(expected); - _ = await Assert.That(count.IsExact).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(count.Value).IsEqualTo(expected); + _ = await Assert.That(count.IsExact).IsFalse(); + } } /// @@ -643,8 +657,11 @@ public async Task GetTestCaseCount_ForeignAttributesOnly_CountsOneHardcodedCase( var count = recognizer.GetTestCaseCount(method); - _ = await Assert.That(count.Value).IsEqualTo(1); - _ = await Assert.That(count.IsExact).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(count.Value).IsEqualTo(1); + _ = await Assert.That(count.IsExact).IsTrue(); + } } [Test] diff --git a/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/NUnitTestFrameworkProbeTests.cs b/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/NUnitTestFrameworkProbeTests.cs index b3d0cc2..c071241 100644 --- a/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/NUnitTestFrameworkProbeTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/NUnitTestFrameworkProbeTests.cs @@ -185,10 +185,13 @@ public async Task IsTestMethod_RecognizerWithoutTheWellKnownTypes_UsesTheNameRul var decorated = FindMethod(compilation, "DecoratedTest"); var plain = FindMethod(compilation, "PlainMethod"); - _ = await Assert.That(NUnitTestFrameworkProbe.GetTestAttributeTypes(compilation)).IsEmpty(); - _ = await Assert.That(NUnitTestFrameworkProbe.GetTestBuilderInterfaceTypes(compilation)).IsEmpty(); - _ = await Assert.That(recognizer.IsTestMethod(decorated)).IsTrue(); - _ = await Assert.That(recognizer.IsTestMethod(plain)).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(NUnitTestFrameworkProbe.GetTestAttributeTypes(compilation)).IsEmpty(); + _ = await Assert.That(NUnitTestFrameworkProbe.GetTestBuilderInterfaceTypes(compilation)).IsEmpty(); + _ = await Assert.That(recognizer.IsTestMethod(decorated)).IsTrue(); + _ = await Assert.That(recognizer.IsTestMethod(plain)).IsFalse(); + } } [Test] @@ -215,8 +218,11 @@ public async Task IsFrameworkAssembly_AssemblyName_IsClassifiedByItsPrefix() var frameworkAssembly = SatelliteAssembly(framework, FrameworkLikeAssemblyName); var foreignAssembly = SatelliteAssembly(foreign, ForeignAssemblyName); - _ = await Assert.That(NUnitTestFrameworkProbe.IsFrameworkAssembly(frameworkAssembly)).IsTrue(); - _ = await Assert.That(NUnitTestFrameworkProbe.IsFrameworkAssembly(foreignAssembly)).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(NUnitTestFrameworkProbe.IsFrameworkAssembly(frameworkAssembly)).IsTrue(); + _ = await Assert.That(NUnitTestFrameworkProbe.IsFrameworkAssembly(foreignAssembly)).IsFalse(); + } } [Test] diff --git a/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/NUnitTestMethodRecognizerTests.cs b/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/NUnitTestMethodRecognizerTests.cs index 95f9c7d..b648f55 100644 --- a/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/NUnitTestMethodRecognizerTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/NUnitTestMethodRecognizerTests.cs @@ -826,8 +826,11 @@ public async Task IsTestMethod_TestAttributeFromAnUnrelatedNamespace_IsNotClassi var recognizer = CreateRecognizer(compilation); var method = FindMethod(compilation, "Fixture.UnrelatedCases", "LooksLikeATest"); - _ = await Assert.That(recognizer.IsTestMethod(method)).IsFalse(); - _ = await Assert.That(new NUnitTestMethodRecognizer([]).IsTestMethod(method)).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(recognizer.IsTestMethod(method)).IsFalse(); + _ = await Assert.That(new NUnitTestMethodRecognizer([]).IsTestMethod(method)).IsFalse(); + } } /// @@ -853,9 +856,12 @@ bool expected var builder = FindMethod(compilation, LookAlikeCasesTypeName, "BuilderMarked"); var plain = FindMethod(compilation, LookAlikeCasesTypeName, "Undecorated"); - _ = await Assert.That(recognizer.IsTestMethod(simple)).IsEqualTo(expected); - _ = await Assert.That(recognizer.IsTestMethod(builder)).IsEqualTo(expected); - _ = await Assert.That(recognizer.IsTestMethod(plain)).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(recognizer.IsTestMethod(simple)).IsEqualTo(expected); + _ = await Assert.That(recognizer.IsTestMethod(builder)).IsEqualTo(expected); + _ = await Assert.That(recognizer.IsTestMethod(plain)).IsFalse(); + } } /// @@ -871,8 +877,11 @@ public async Task IsTestMethod_RecognizerBuiltFromADefaultArray_BehavesLikeAnEmp var test = FindMethod(compilation, CasesTypeName, "PlainTest"); var plain = FindMethod(compilation, CasesTypeName, "PlainMethod"); - _ = await Assert.That(recognizer.IsTestMethod(test)).IsTrue(); - _ = await Assert.That(recognizer.IsTestMethod(plain)).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(recognizer.IsTestMethod(test)).IsTrue(); + _ = await Assert.That(recognizer.IsTestMethod(plain)).IsFalse(); + } } /// @@ -955,8 +964,11 @@ public async Task GetTestCaseCount_ShapeThatIsWrittenDown_IsCountedExactly(strin var count = recognizer.GetTestCaseCount(method); - _ = await Assert.That(count.Value).IsEqualTo(expected); - _ = await Assert.That(count.IsExact).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(count.Value).IsEqualTo(expected); + _ = await Assert.That(count.IsExact).IsTrue(); + } } /// @@ -988,8 +1000,11 @@ public async Task GetTestCaseCount_ShapeThatIsNotWrittenDown_IsALowerBound(strin var count = recognizer.GetTestCaseCount(method); - _ = await Assert.That(count.Value).IsEqualTo(expected); - _ = await Assert.That(count.IsExact).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(count.Value).IsEqualTo(expected); + _ = await Assert.That(count.IsExact).IsFalse(); + } } /// @@ -1034,8 +1049,11 @@ public async Task GetTestCaseCount_TestAttributeFromAnUnrelatedNamespace_CountsO var count = recognizer.GetTestCaseCount(method); - _ = await Assert.That(count.Value).IsEqualTo(1); - _ = await Assert.That(count.IsExact).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(count.Value).IsEqualTo(1); + _ = await Assert.That(count.IsExact).IsTrue(); + } } [Test] diff --git a/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/TUnitTestFrameworkProbeTests.cs b/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/TUnitTestFrameworkProbeTests.cs index 321d510..7b33113 100644 --- a/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/TUnitTestFrameworkProbeTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/TUnitTestFrameworkProbeTests.cs @@ -187,8 +187,11 @@ public async Task IsTestMethod_RecognizerWithoutTheWellKnownType_UsesTheNameRule var decorated = FindMethod(compilation, "DecoratedTest"); var plain = FindMethod(compilation, "PlainMethod"); - _ = await Assert.That(recognizer.IsTestMethod(decorated)).IsTrue(); - _ = await Assert.That(recognizer.IsTestMethod(plain)).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(recognizer.IsTestMethod(decorated)).IsTrue(); + _ = await Assert.That(recognizer.IsTestMethod(plain)).IsFalse(); + } } [Test] @@ -223,8 +226,11 @@ public async Task IsFrameworkAssembly_AssemblyName_IsClassifiedByItsPrefix() var frameworkAssembly = SatelliteAssembly(framework, FrameworkLikeAssemblyName); var foreignAssembly = SatelliteAssembly(foreign, ForeignAssemblyName); - _ = await Assert.That(TUnitTestFrameworkProbe.IsFrameworkAssembly(frameworkAssembly)).IsTrue(); - _ = await Assert.That(TUnitTestFrameworkProbe.IsFrameworkAssembly(foreignAssembly)).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(TUnitTestFrameworkProbe.IsFrameworkAssembly(frameworkAssembly)).IsTrue(); + _ = await Assert.That(TUnitTestFrameworkProbe.IsFrameworkAssembly(foreignAssembly)).IsFalse(); + } } [Test] @@ -250,8 +256,11 @@ public async Task GetBaseTestAttributeType_WithFrameworkReference_ResolvesTheMar var resolved = TUnitTestFrameworkProbe.GetBaseTestAttributeType(compilation); - _ = await Assert.That(resolved?.ToDisplayString()).IsEqualTo("TUnit.Core.BaseTestAttribute"); - _ = await Assert.That(resolved!.IsAbstract).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(resolved?.ToDisplayString()).IsEqualTo("TUnit.Core.BaseTestAttribute"); + _ = await Assert.That(resolved!.IsAbstract).IsTrue(); + } } [Test] diff --git a/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/TUnitTestMethodRecognizerTests.cs b/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/TUnitTestMethodRecognizerTests.cs index 5b3384d..16e114c 100644 --- a/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/TUnitTestMethodRecognizerTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/TUnitTestMethodRecognizerTests.cs @@ -554,9 +554,12 @@ bool expected var markerBase = TUnitTestFrameworkProbe.GetBaseTestAttributeType(compilation); var attribute = compilation.GetTypeByMetadataName(metadataName); - _ = await Assert.That(markerBase?.ToDisplayString()).IsEqualTo("TUnit.Core.BaseTestAttribute"); - _ = await Assert.That(attribute?.ToDisplayString()).IsEqualTo(metadataName); - _ = await Assert.That(DerivesFrom(attribute, markerBase)).IsEqualTo(expected); + using (Assert.Multiple()) + { + _ = await Assert.That(markerBase?.ToDisplayString()).IsEqualTo("TUnit.Core.BaseTestAttribute"); + _ = await Assert.That(attribute?.ToDisplayString()).IsEqualTo(metadataName); + _ = await Assert.That(DerivesFrom(attribute, markerBase)).IsEqualTo(expected); + } } [Test] @@ -625,8 +628,11 @@ public async Task FindTestMethods_AttributeFromANonFrameworkAssembly_IsNotDiscov var found = FindTestMethods(compilation); - _ = await Assert.That(TUnitTestFrameworkProbe.Instance.TryCreateRecognizer(compilation)).IsNull(); - _ = await Assert.That(found.Length).IsEqualTo(0); + using (Assert.Multiple()) + { + _ = await Assert.That(TUnitTestFrameworkProbe.Instance.TryCreateRecognizer(compilation)).IsNull(); + _ = await Assert.That(found.Length).IsEqualTo(0); + } } /// @@ -642,8 +648,11 @@ public async Task IsTestMethod_MarkerBaseNameFromANonFrameworkAssembly_IsNotClas var derived = FindMethod(compilation, "Fixture.SatelliteCases", "UsesDerivedAttribute"); var recognizer = CreateRecognizer(compilation); - _ = await Assert.That(recognizer.IsTestMethod(direct)).IsFalse(); - _ = await Assert.That(recognizer.IsTestMethod(derived)).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(recognizer.IsTestMethod(direct)).IsFalse(); + _ = await Assert.That(recognizer.IsTestMethod(derived)).IsFalse(); + } } [Test] @@ -714,8 +723,11 @@ public async Task IsTestMethod_CompilationWithoutTheFramework_ReturnsFalse() var compilation = CompilationFactory.Create(UnrelatedFixtureSource); var method = FindMethod(compilation, UnrelatedTypeName, "LooksLikeATest"); - _ = await Assert.That(TUnitTestFrameworkProbe.Instance.TryCreateRecognizer(compilation)).IsNull(); - _ = await Assert.That(CreateRecognizer(compilation).IsTestMethod(method)).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(TUnitTestFrameworkProbe.Instance.TryCreateRecognizer(compilation)).IsNull(); + _ = await Assert.That(CreateRecognizer(compilation).IsTestMethod(method)).IsFalse(); + } } /// @@ -738,8 +750,11 @@ public async Task IsTestMethod_WithOnlyTheMarkerBaseType_ClassifiesByThatType(st var markerBase = TUnitTestFrameworkProbe.GetBaseTestAttributeType(compilation); var recognizer = new TUnitTestMethodRecognizer(testAttributeType: null, baseTestAttributeType: markerBase); - _ = await Assert.That(markerBase?.ToDisplayString()).IsEqualTo("TUnit.Core.BaseTestAttribute"); - _ = await Assert.That(recognizer.IsTestMethod(method)).IsEqualTo(expected); + using (Assert.Multiple()) + { + _ = await Assert.That(markerBase?.ToDisplayString()).IsEqualTo("TUnit.Core.BaseTestAttribute"); + _ = await Assert.That(recognizer.IsTestMethod(method)).IsEqualTo(expected); + } } /// @@ -758,8 +773,13 @@ public async Task IsTestMethod_WithAPreResolvedAttributeType_ClassifiesByThatTyp var method = FindMethod(compilation, CasesTypeName, methodName); var attributeType = TUnitTestFrameworkProbe.GetTestAttributeType(compilation); - _ = await Assert.That(attributeType?.ToDisplayString()).IsEqualTo("TUnit.Core.TestAttribute"); - _ = await Assert.That(new TUnitTestMethodRecognizer(attributeType).IsTestMethod(method)).IsEqualTo(expected); + using (Assert.Multiple()) + { + _ = await Assert.That(attributeType?.ToDisplayString()).IsEqualTo("TUnit.Core.TestAttribute"); + _ = await Assert + .That(new TUnitTestMethodRecognizer(attributeType).IsTestMethod(method)) + .IsEqualTo(expected); + } } /// @@ -778,10 +798,13 @@ public async Task IsTestMethod_WithoutAnyResolvedType_FallsBackToTheNameRule() var satelliteAttribute = FindMethod(satellite, "Fixture.SatelliteCases", "UsesFrameworkAttributeDirectly"); var satelliteDerived = FindMethod(satellite, "Fixture.SatelliteCases", "UsesDerivedAttribute"); - _ = await Assert.That(recognizer.IsTestMethod(frameworkAttribute)).IsTrue(); - _ = await Assert.That(recognizer.IsTestMethod(dynamicBuilder)).IsTrue(); - _ = await Assert.That(recognizer.IsTestMethod(satelliteAttribute)).IsTrue(); - _ = await Assert.That(recognizer.IsTestMethod(satelliteDerived)).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(recognizer.IsTestMethod(frameworkAttribute)).IsTrue(); + _ = await Assert.That(recognizer.IsTestMethod(dynamicBuilder)).IsTrue(); + _ = await Assert.That(recognizer.IsTestMethod(satelliteAttribute)).IsTrue(); + _ = await Assert.That(recognizer.IsTestMethod(satelliteDerived)).IsTrue(); + } } /// @@ -798,8 +821,13 @@ public async Task IsTestMethod_LookAlikeAttributeOfTheCompilation_IsNotClassifie var compilation = CompilationFactory.Create(UnrelatedFixtureSource, includeTUnit: true); var method = FindMethod(compilation, UnrelatedTypeName, methodName); - _ = await Assert.That(CreateRecognizer(compilation).IsTestMethod(method)).IsFalse(); - _ = await Assert.That(new TUnitTestMethodRecognizer(testAttributeType: null).IsTestMethod(method)).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(CreateRecognizer(compilation).IsTestMethod(method)).IsFalse(); + _ = await Assert + .That(new TUnitTestMethodRecognizer(testAttributeType: null).IsTestMethod(method)) + .IsFalse(); + } } [Test] @@ -884,8 +912,11 @@ public async Task GetTestCaseCount_ParameterlessTestMethod_IsExactlyOneCase() { var count = CountCases(CountsTypeName, "Parameterless"); - _ = await Assert.That(count.Value).IsEqualTo(1); - _ = await Assert.That(count.IsExact).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(count.Value).IsEqualTo(1); + _ = await Assert.That(count.IsExact).IsTrue(); + } } /// @@ -898,8 +929,11 @@ public async Task GetTestCaseCount_RepeatedTestMethod_IsStillExactlyOneCase() { var count = CountCases(CountsTypeName, "RepeatedParameterless"); - _ = await Assert.That(count.Value).IsEqualTo(1); - _ = await Assert.That(count.IsExact).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(count.Value).IsEqualTo(1); + _ = await Assert.That(count.IsExact).IsTrue(); + } } /// @@ -910,8 +944,11 @@ public async Task GetTestCaseCount_ThreeInlineRows_AreExactlyThreeCases() { var count = CountCases(CountsTypeName, "ThreeInlineRows"); - _ = await Assert.That(count.Value).IsEqualTo(3); - _ = await Assert.That(count.IsExact).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(count.Value).IsEqualTo(3); + _ = await Assert.That(count.IsExact).IsTrue(); + } } /// @@ -930,8 +967,11 @@ int expected { var count = CountCases(CountsTypeName, methodName); - _ = await Assert.That(count.Value).IsEqualTo(expected); - _ = await Assert.That(count.IsExact).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(count.Value).IsEqualTo(expected); + _ = await Assert.That(count.IsExact).IsTrue(); + } } /// @@ -951,8 +991,11 @@ public async Task GetTestCaseCount_MatrixThatIsNotWrittenOut_IsALowerBound(strin { var count = CountCases(CountsTypeName, methodName); - _ = await Assert.That(count.Value).IsEqualTo(expected); - _ = await Assert.That(count.IsExact).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(count.Value).IsEqualTo(expected); + _ = await Assert.That(count.IsExact).IsFalse(); + } } /// @@ -966,10 +1009,13 @@ public async Task GetTestCaseCount_InlineDataAndADataSource_AddUp() var lowerBound = CountCases(CountsTypeName, "InlineAndLowerBoundSource"); var exact = CountCases(CountsTypeName, "InlineAndExactSource"); - _ = await Assert.That(lowerBound.Value).IsEqualTo(2); - _ = await Assert.That(lowerBound.IsExact).IsFalse(); - _ = await Assert.That(exact.Value).IsEqualTo(5); - _ = await Assert.That(exact.IsExact).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(lowerBound.Value).IsEqualTo(2); + _ = await Assert.That(lowerBound.IsExact).IsFalse(); + _ = await Assert.That(exact.Value).IsEqualTo(5); + _ = await Assert.That(exact.IsExact).IsTrue(); + } } /// @@ -990,8 +1036,11 @@ public async Task GetTestCaseCount_DataSourceOnALiteralSequence_IsExactlyItsLeng { var count = CountCases(CountsTypeName, methodName); - _ = await Assert.That(count.Value).IsEqualTo(expected); - _ = await Assert.That(count.IsExact).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(count.Value).IsEqualTo(expected); + _ = await Assert.That(count.IsExact).IsTrue(); + } } /// @@ -1012,8 +1061,11 @@ public async Task GetTestCaseCount_DataSourceThatIsNotStaticallyEnumerable_IsALo { var count = CountCases(CountsTypeName, methodName); - _ = await Assert.That(count.Value).IsEqualTo(1); - _ = await Assert.That(count.IsExact).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(count.Value).IsEqualTo(1); + _ = await Assert.That(count.IsExact).IsFalse(); + } } /// @@ -1025,8 +1077,11 @@ public async Task GetTestCaseCount_MethodWithParametersAndNoDataSource_IsALowerB { var count = CountCases(CountsTypeName, "MissingSource"); - _ = await Assert.That(count.Value).IsEqualTo(1); - _ = await Assert.That(count.IsExact).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(count.Value).IsEqualTo(1); + _ = await Assert.That(count.IsExact).IsFalse(); + } } /// @@ -1046,8 +1101,11 @@ int expected { var count = CountCases(ClassDataTypeName, methodName); - _ = await Assert.That(count.Value).IsEqualTo(expected); - _ = await Assert.That(count.IsExact).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(count.Value).IsEqualTo(expected); + _ = await Assert.That(count.IsExact).IsFalse(); + } } /// @@ -1064,8 +1122,11 @@ public async Task GetTestCaseCount_LookAlikeInlineDataAttribute_ContributesNoCas var resolved = CreateRecognizer(compilation).GetTestCaseCount(method); var unresolved = new TUnitTestMethodRecognizer(testAttributeType: null).GetTestCaseCount(method); - _ = await Assert.That(resolved.ToString()).IsEqualTo("1+"); - _ = await Assert.That(unresolved.ToString()).IsEqualTo("1+"); + using (Assert.Multiple()) + { + _ = await Assert.That(resolved.ToString()).IsEqualTo("1+"); + _ = await Assert.That(unresolved.ToString()).IsEqualTo("1+"); + } } /// @@ -1082,8 +1143,11 @@ public async Task GetTestCaseCount_WithoutAnyResolvedType_CountsTheSameCases() var inline = recognizer.GetTestCaseCount(FindMethod(compilation, CountsTypeName, "ThreeInlineRows")); var matrix = recognizer.GetTestCaseCount(FindMethod(compilation, CountsTypeName, "MatrixOfTwoAndThree")); - _ = await Assert.That(inline.ToString()).IsEqualTo("3"); - _ = await Assert.That(matrix.ToString()).IsEqualTo("6"); + using (Assert.Multiple()) + { + _ = await Assert.That(inline.ToString()).IsEqualTo("3"); + _ = await Assert.That(matrix.ToString()).IsEqualTo("6"); + } } [Test] diff --git a/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/TestCaseCountTests.cs b/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/TestCaseCountTests.cs index 451ef2c..9e0733a 100644 --- a/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/TestCaseCountTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/TestCaseCountTests.cs @@ -21,8 +21,11 @@ public async Task Exact_NonNegativeValue_IsExact(int value) { var count = TestCaseCount.Exact(value); - _ = await Assert.That(count.Value).IsEqualTo(value); - _ = await Assert.That(count.IsExact).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(count.Value).IsEqualTo(value); + _ = await Assert.That(count.IsExact).IsTrue(); + } } [Test] @@ -34,8 +37,11 @@ public async Task AtLeast_NonNegativeValue_IsALowerBound(int value) { var count = TestCaseCount.AtLeast(value); - _ = await Assert.That(count.Value).IsEqualTo(value); - _ = await Assert.That(count.IsExact).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(count.Value).IsEqualTo(value); + _ = await Assert.That(count.IsExact).IsFalse(); + } } [Test] @@ -67,9 +73,12 @@ public async Task Default_TheUninitializedValue_IsTheZeroLowerBound() { var count = default(TestCaseCount); - _ = await Assert.That(count.Value).IsEqualTo(0); - _ = await Assert.That(count.IsExact).IsFalse(); - _ = await Assert.That(count.ToString()).IsEqualTo("0+"); + using (Assert.Multiple()) + { + _ = await Assert.That(count.Value).IsEqualTo(0); + _ = await Assert.That(count.IsExact).IsFalse(); + _ = await Assert.That(count.ToString()).IsEqualTo("0+"); + } } [Test] @@ -77,8 +86,11 @@ public async Task Add_BothOperandsAreExact_StaysExact() { var count = TestCaseCount.Exact(2).Add(TestCaseCount.Exact(3)); - _ = await Assert.That(count.Value).IsEqualTo(5); - _ = await Assert.That(count.IsExact).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(count.Value).IsEqualTo(5); + _ = await Assert.That(count.IsExact).IsTrue(); + } } [Test] @@ -86,8 +98,11 @@ public async Task Add_TheRightOperandIsALowerBound_BecomesALowerBound() { var count = TestCaseCount.Exact(2).Add(TestCaseCount.AtLeast(3)); - _ = await Assert.That(count.Value).IsEqualTo(5); - _ = await Assert.That(count.IsExact).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(count.Value).IsEqualTo(5); + _ = await Assert.That(count.IsExact).IsFalse(); + } } [Test] @@ -95,8 +110,11 @@ public async Task Add_TheLeftOperandIsALowerBound_BecomesALowerBound() { var count = TestCaseCount.AtLeast(2).Add(TestCaseCount.Exact(3)); - _ = await Assert.That(count.Value).IsEqualTo(5); - _ = await Assert.That(count.IsExact).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(count.Value).IsEqualTo(5); + _ = await Assert.That(count.IsExact).IsFalse(); + } } [Test] @@ -104,8 +122,11 @@ public async Task Add_BothOperandsAreLowerBounds_StaysALowerBound() { var count = TestCaseCount.AtLeast(2).Add(TestCaseCount.AtLeast(3)); - _ = await Assert.That(count.Value).IsEqualTo(5); - _ = await Assert.That(count.IsExact).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(count.Value).IsEqualTo(5); + _ = await Assert.That(count.IsExact).IsFalse(); + } } /// @@ -117,8 +138,11 @@ public async Task Add_TheSumExceedsTheValueRange_SaturatesAtTheMaximum() { var count = TestCaseCount.Exact(int.MaxValue).Add(TestCaseCount.Exact(2)); - _ = await Assert.That(count.Value).IsEqualTo(int.MaxValue); - _ = await Assert.That(count.IsExact).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(count.Value).IsEqualTo(int.MaxValue); + _ = await Assert.That(count.IsExact).IsTrue(); + } } [Test] @@ -147,9 +171,12 @@ public async Task TryParse_DigitsOnly_YieldsAnExactCount(string text, int expect { var parsed = TestCaseCount.TryParse(text, out var count); - _ = await Assert.That(parsed).IsTrue(); - _ = await Assert.That(count.Value).IsEqualTo(expected); - _ = await Assert.That(count.IsExact).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(parsed).IsTrue(); + _ = await Assert.That(count.Value).IsEqualTo(expected); + _ = await Assert.That(count.IsExact).IsTrue(); + } } [Test] @@ -161,9 +188,12 @@ public async Task TryParse_DigitsWithThePlusSuffix_YieldsALowerBound(string text { var parsed = TestCaseCount.TryParse(text, out var count); - _ = await Assert.That(parsed).IsTrue(); - _ = await Assert.That(count.Value).IsEqualTo(expected); - _ = await Assert.That(count.IsExact).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(parsed).IsTrue(); + _ = await Assert.That(count.Value).IsEqualTo(expected); + _ = await Assert.That(count.IsExact).IsFalse(); + } } /// @@ -194,8 +224,11 @@ public async Task TryParse_MalformedText_Fails(string text) { var parsed = TestCaseCount.TryParse(text, out var count); - _ = await Assert.That(parsed).IsFalse(); - _ = await Assert.That(count).IsEqualTo(default(TestCaseCount)); + using (Assert.Multiple()) + { + _ = await Assert.That(parsed).IsFalse(); + _ = await Assert.That(count).IsEqualTo(default(TestCaseCount)); + } } [Test] @@ -203,8 +236,11 @@ public async Task TryParse_TextIsNull_Fails() { var parsed = TestCaseCount.TryParse(null, out var count); - _ = await Assert.That(parsed).IsFalse(); - _ = await Assert.That(count).IsEqualTo(default(TestCaseCount)); + using (Assert.Multiple()) + { + _ = await Assert.That(parsed).IsFalse(); + _ = await Assert.That(count).IsEqualTo(default(TestCaseCount)); + } } [Test] @@ -218,8 +254,11 @@ public async Task TryParse_TheOutputOfToString_RoundTrips(string text) { var parsed = TestCaseCount.TryParse(text, out var count); - _ = await Assert.That(parsed).IsTrue(); - _ = await Assert.That(count.ToString()).IsEqualTo(text); + using (Assert.Multiple()) + { + _ = await Assert.That(parsed).IsTrue(); + _ = await Assert.That(count.ToString()).IsEqualTo(text); + } } [Test] @@ -228,10 +267,13 @@ public async Task Equals_SameValueAndSameExactness_AreEqual() var left = TestCaseCount.Exact(3); var right = TestCaseCount.Exact(3); - _ = await Assert.That(left.Equals(right)).IsTrue(); - _ = await Assert.That(left == right).IsTrue(); - _ = await Assert.That(left != right).IsFalse(); - _ = await Assert.That(left.GetHashCode()).IsEqualTo(right.GetHashCode()); + using (Assert.Multiple()) + { + _ = await Assert.That(left.Equals(right)).IsTrue(); + _ = await Assert.That(left == right).IsTrue(); + _ = await Assert.That(left != right).IsFalse(); + _ = await Assert.That(left.GetHashCode()).IsEqualTo(right.GetHashCode()); + } } /// @@ -244,18 +286,24 @@ public async Task Equals_SameValueButDifferentExactness_AreNotEqual() var exact = TestCaseCount.Exact(3); var lowerBound = TestCaseCount.AtLeast(3); - _ = await Assert.That(exact.Equals(lowerBound)).IsFalse(); - _ = await Assert.That(exact == lowerBound).IsFalse(); - _ = await Assert.That(exact != lowerBound).IsTrue(); - _ = await Assert.That(exact.GetHashCode()).IsNotEqualTo(lowerBound.GetHashCode()); + using (Assert.Multiple()) + { + _ = await Assert.That(exact.Equals(lowerBound)).IsFalse(); + _ = await Assert.That(exact == lowerBound).IsFalse(); + _ = await Assert.That(exact != lowerBound).IsTrue(); + _ = await Assert.That(exact.GetHashCode()).IsNotEqualTo(lowerBound.GetHashCode()); + } } [Test] public async Task Equals_DifferentValue_AreNotEqual() { - _ = await Assert.That(TestCaseCount.Exact(3).Equals(TestCaseCount.Exact(4))).IsFalse(); - _ = await Assert.That(TestCaseCount.Exact(3) == TestCaseCount.Exact(4)).IsFalse(); - _ = await Assert.That(TestCaseCount.Exact(3) != TestCaseCount.Exact(4)).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(TestCaseCount.Exact(3).Equals(TestCaseCount.Exact(4))).IsFalse(); + _ = await Assert.That(TestCaseCount.Exact(3) == TestCaseCount.Exact(4)).IsFalse(); + _ = await Assert.That(TestCaseCount.Exact(3) != TestCaseCount.Exact(4)).IsTrue(); + } } [Test] @@ -263,8 +311,11 @@ public async Task Equals_AnotherType_ReturnsFalse() { var count = TestCaseCount.Exact(3); - _ = await Assert.That(count.Equals("3")).IsFalse(); - _ = await Assert.That(count.Equals(null)).IsFalse(); - _ = await Assert.That(count.Equals((object)TestCaseCount.Exact(3))).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(count.Equals("3")).IsFalse(); + _ = await Assert.That(count.Equals(null)).IsFalse(); + _ = await Assert.That(count.Equals((object)TestCaseCount.Exact(3))).IsTrue(); + } } } diff --git a/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/TestMethodDiscoveryTests.cs b/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/TestMethodDiscoveryTests.cs index 10af79e..f3331b5 100644 --- a/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/TestMethodDiscoveryTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/TestMethodDiscoveryTests.cs @@ -228,9 +228,12 @@ public async Task FindTestMethods_DeclarationOutsideAnyType_IsSurvivedAndTheOthe CancellationToken.None ); - _ = await Assert.That(CompilationFactory.GetCompileErrors(compilation).Length).IsGreaterThan(0); - _ = await Assert.That(Describe(found)).Contains("FirstCases.Alpha"); - _ = await Assert.That(Describe(found)).Contains("SecondCases.Beta"); + using (Assert.Multiple()) + { + _ = await Assert.That(CompilationFactory.GetCompileErrors(compilation).Length).IsGreaterThan(0); + _ = await Assert.That(Describe(found)).Contains("FirstCases.Alpha"); + _ = await Assert.That(Describe(found)).Contains("SecondCases.Beta"); + } } /// @@ -253,9 +256,12 @@ public async Task FindTestMethods_DeclarationOutsideAnyType_IsBoundAndDiscovered CancellationToken.None ); - _ = await Assert.That(found.Length).IsEqualTo(3); - _ = await Assert.That(found[2].Name).IsEqualTo(OrphanedMethodName); - _ = await Assert.That(found[2].ContainingType).IsNotNull(); + using (Assert.Multiple()) + { + _ = await Assert.That(found.Length).IsEqualTo(3); + _ = await Assert.That(found[2].Name).IsEqualTo(OrphanedMethodName); + _ = await Assert.That(found[2].ContainingType).IsNotNull(); + } } /// @@ -272,8 +278,11 @@ public async Task FindTestMethods_EveryDiscoveredMethod_IsDeclaredByAMethodDecla CancellationToken.None ); - _ = await Assert.That(found.Length).IsEqualTo(3); - _ = await Assert.That(found.All(HasMethodDeclarationInSource)).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(found.Length).IsEqualTo(3); + _ = await Assert.That(found.All(HasMethodDeclarationInSource)).IsTrue(); + } } /// @@ -291,10 +300,13 @@ public async Task FindTestMethods_DecoratedLocalFunction_IsNotDiscovered() CancellationToken.None ); - _ = await Assert - .That(DiagnosticAssertions.Describe(CompilationFactory.GetCompileErrors(compilation))) - .IsEqualTo(DiagnosticAssertions.NoDiagnostics); - _ = await Assert.That(Describe(found)).IsEqualTo("LocalFunctionCases.Outer"); + using (Assert.Multiple()) + { + _ = await Assert + .That(DiagnosticAssertions.Describe(CompilationFactory.GetCompileErrors(compilation))) + .IsEqualTo(DiagnosticAssertions.NoDiagnostics); + _ = await Assert.That(Describe(found)).IsEqualTo("LocalFunctionCases.Outer"); + } } /// @@ -312,11 +324,14 @@ public async Task FindTestMethods_PartialTestMethod_IsDiscoveredOnceForBothDecla CancellationToken.None ); - _ = await Assert - .That(DiagnosticAssertions.Describe(CompilationFactory.GetCompileErrors(compilation))) - .IsEqualTo(DiagnosticAssertions.NoDiagnostics); - _ = await Assert.That(Describe(found)).IsEqualTo("PartialCases.Alpha"); - _ = await Assert.That(HasMethodDeclarationInSource(found[0])).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert + .That(DiagnosticAssertions.Describe(CompilationFactory.GetCompileErrors(compilation))) + .IsEqualTo(DiagnosticAssertions.NoDiagnostics); + _ = await Assert.That(Describe(found)).IsEqualTo("PartialCases.Alpha"); + _ = await Assert.That(HasMethodDeclarationInSource(found[0])).IsTrue(); + } } [Test] @@ -353,10 +368,13 @@ public async Task FindTestMethods_FileWithoutAnyDecoratedMethod_ContributesNothi CancellationToken.None ); - _ = await Assert - .That(DiagnosticAssertions.Describe(CompilationFactory.GetCompileErrors(compilation))) - .IsEqualTo(DiagnosticAssertions.NoDiagnostics); - _ = await Assert.That(Describe(found)).IsEqualTo("FirstCases.Alpha|SecondCases.Beta"); + using (Assert.Multiple()) + { + _ = await Assert + .That(DiagnosticAssertions.Describe(CompilationFactory.GetCompileErrors(compilation))) + .IsEqualTo(DiagnosticAssertions.NoDiagnostics); + _ = await Assert.That(Describe(found)).IsEqualTo("FirstCases.Alpha|SecondCases.Beta"); + } } [Test] @@ -421,10 +439,15 @@ public async Task FindTestMethodsWithCaseCounts_DiscoveredMethods_AreTheOnesOfFi CancellationToken.None ); - _ = await Assert.That(Describe(withCounts.Select(entry => entry.Method))).IsEqualTo(Describe(withoutCounts)); - _ = await Assert - .That(DescribeWithCounts(withCounts)) - .IsEqualTo("FirstCases.Alpha=3|SecondCases.Beta=1+|.Orphaned=1+"); + using (Assert.Multiple()) + { + _ = await Assert + .That(Describe(withCounts.Select(entry => entry.Method))) + .IsEqualTo(Describe(withoutCounts)); + _ = await Assert + .That(DescribeWithCounts(withCounts)) + .IsEqualTo("FirstCases.Alpha=3|SecondCases.Beta=1+|.Orphaned=1+"); + } } [Test] @@ -454,8 +477,11 @@ public async Task FindTestMethodsWithCaseCounts_EveryDiscoveredTest_IsCountedExa CancellationToken.None ); - _ = await Assert.That(DescribeWithCounts(found)).IsEqualTo("FirstCases.Alpha=3|SecondCases.Beta=1+"); - _ = await Assert.That(string.Join("|", recognizer.Counted)).IsEqualTo("Alpha|Beta"); + using (Assert.Multiple()) + { + _ = await Assert.That(DescribeWithCounts(found)).IsEqualTo("FirstCases.Alpha=3|SecondCases.Beta=1+"); + _ = await Assert.That(string.Join("|", recognizer.Counted)).IsEqualTo("Alpha|Beta"); + } } /// @@ -472,8 +498,11 @@ public async Task FindTestMethodsWithCaseCounts_PartialTestMethod_IsCountedOnce( CancellationToken.None ); - _ = await Assert.That(DescribeWithCounts(found)).IsEqualTo("PartialCases.Alpha=3"); - _ = await Assert.That(string.Join("|", recognizer.Counted)).IsEqualTo("Alpha"); + using (Assert.Multiple()) + { + _ = await Assert.That(DescribeWithCounts(found)).IsEqualTo("PartialCases.Alpha=3"); + _ = await Assert.That(string.Join("|", recognizer.Counted)).IsEqualTo("Alpha"); + } } [Test] diff --git a/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/TestSurfaceCollectorMemberTraversalTests.cs b/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/TestSurfaceCollectorMemberTraversalTests.cs index d8918e7..ba2d86e 100644 --- a/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/TestSurfaceCollectorMemberTraversalTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/TestSurfaceCollectorMemberTraversalTests.cs @@ -303,12 +303,15 @@ public async Task Fixtures_BothAssemblies_CompileWithoutErrors() var production = CreateProduction(); var test = CreateTest(production); - _ = await Assert - .That(DiagnosticAssertions.Describe(CompilationFactory.GetCompileErrors(production))) - .IsEqualTo(DiagnosticAssertions.NoDiagnostics); - _ = await Assert - .That(DiagnosticAssertions.Describe(CompilationFactory.GetCompileErrors(test))) - .IsEqualTo(DiagnosticAssertions.NoDiagnostics); + using (Assert.Multiple()) + { + _ = await Assert + .That(DiagnosticAssertions.Describe(CompilationFactory.GetCompileErrors(production))) + .IsEqualTo(DiagnosticAssertions.NoDiagnostics); + _ = await Assert + .That(DiagnosticAssertions.Describe(CompilationFactory.GetCompileErrors(test))) + .IsEqualTo(DiagnosticAssertions.NoDiagnostics); + } } [Test] @@ -409,8 +412,11 @@ public async Task Collect_ExtensionMethodCalledInReducedForm_RecordsTheUnreduced { var manifest = CollectSurface(CreateTest(CreateProduction())); - _ = await Assert.That(manifest.ReferencedMemberIds.Contains(UnreducedExtensionId)).IsTrue(); - _ = await Assert.That(manifest.ReferencedMemberIds.Contains(ReducedExtensionId)).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(manifest.ReferencedMemberIds.Contains(UnreducedExtensionId)).IsTrue(); + _ = await Assert.That(manifest.ReferencedMemberIds.Contains(ReducedExtensionId)).IsFalse(); + } } /// @@ -430,8 +436,13 @@ public async Task Collect_CallDoesNotBindButHasExactlyOneCandidate_RecordsTheCan var manifest = CollectSurface(test); - _ = await Assert.That(DiagnosticAssertions.Ids(CompilationFactory.GetCompileErrors(test))).Contains("CS0122"); - _ = await Assert.That(manifest.ReferencedMemberIds.Contains(InaccessibleMemberId)).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert + .That(DiagnosticAssertions.Ids(CompilationFactory.GetCompileErrors(test))) + .Contains("CS0122"); + _ = await Assert.That(manifest.ReferencedMemberIds.Contains(InaccessibleMemberId)).IsTrue(); + } } /// @@ -451,8 +462,11 @@ public async Task Collect_TestTouchingOnlyAutoProperties_HasNoProductionReferenc var names = withoutReference.Select(method => method.Name).ToList(); - _ = await Assert.That(names.Contains("OnlyTouchesAutoProperties", StringComparer.Ordinal)).IsTrue(); - _ = await Assert.That(names.Contains("ReadsBlockBodiedProperty", StringComparer.Ordinal)).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(names.Contains("OnlyTouchesAutoProperties", StringComparer.Ordinal)).IsTrue(); + _ = await Assert.That(names.Contains("ReadsBlockBodiedProperty", StringComparer.Ordinal)).IsFalse(); + } } /// @@ -521,8 +535,11 @@ public async Task Collect_MemberReachedByAnotherTest_IsNotAttributed() var references = ReferencesOf(manifest, "ReadsExpressionBodiedProperty"); - _ = await Assert.That(references.Contains("M:Production.Signals.FromBlockProperty~System.Int32")).IsFalse(); - _ = await Assert.That(references.Contains("M:Production.Signals.FromEventAdd~System.Int32")).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(references.Contains("M:Production.Signals.FromBlockProperty~System.Int32")).IsFalse(); + _ = await Assert.That(references.Contains("M:Production.Signals.FromEventAdd~System.Int32")).IsFalse(); + } } [Test] @@ -542,8 +559,11 @@ public async Task Collect_BothMaps_AreKeyedByEveryDiscoveredTest() { var manifest = CollectSurface(CreateTest(CreateProduction())); - _ = await Assert.That(Join(manifest.ReferencesByTest.Keys)).IsEqualTo(Join(manifest.TestMethodIds)); - _ = await Assert.That(Join(manifest.TestCaseCounts.Keys)).IsEqualTo(Join(manifest.TestMethodIds)); + using (Assert.Multiple()) + { + _ = await Assert.That(Join(manifest.ReferencesByTest.Keys)).IsEqualTo(Join(manifest.TestMethodIds)); + _ = await Assert.That(Join(manifest.TestCaseCounts.Keys)).IsEqualTo(Join(manifest.TestMethodIds)); + } } /// diff --git a/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/TestSurfaceCollectorTests.cs b/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/TestSurfaceCollectorTests.cs index 86093ae..1cf603c 100644 --- a/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/TestSurfaceCollectorTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/TestSurfaceCollectorTests.cs @@ -176,12 +176,15 @@ public async Task Fixtures_BothAssemblies_CompileWithoutErrors() var production = CreateProduction(); var test = CreateTest(production); - _ = await Assert - .That(DiagnosticAssertions.Describe(CompilationFactory.GetCompileErrors(production))) - .IsEqualTo(DiagnosticAssertions.NoDiagnostics); - _ = await Assert - .That(DiagnosticAssertions.Describe(CompilationFactory.GetCompileErrors(test))) - .IsEqualTo(DiagnosticAssertions.NoDiagnostics); + using (Assert.Multiple()) + { + _ = await Assert + .That(DiagnosticAssertions.Describe(CompilationFactory.GetCompileErrors(production))) + .IsEqualTo(DiagnosticAssertions.NoDiagnostics); + _ = await Assert + .That(DiagnosticAssertions.Describe(CompilationFactory.GetCompileErrors(test))) + .IsEqualTo(DiagnosticAssertions.NoDiagnostics); + } } [Test] @@ -344,8 +347,11 @@ public async Task Collect_HelperCalledByATestAndByANonTestMethod_IsAttributedToT { var manifest = CollectSurface(CreateTest(CreateProduction())); - _ = await Assert.That(ReferencesOf(manifest, CallsDualUseHelperId)).IsEqualTo(DualUseHelperSurface); - _ = await Assert.That(manifest.ReferencedMemberIds.Contains(OnlyFromNonTestId)).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(ReferencesOf(manifest, CallsDualUseHelperId)).IsEqualTo(DualUseHelperSurface); + _ = await Assert.That(manifest.ReferencedMemberIds.Contains(OnlyFromNonTestId)).IsFalse(); + } } [Test] @@ -379,8 +385,13 @@ public async Task Collect_MemberOfAnotherTest_IsNotAttributed() { var manifest = CollectSurface(CreateTest(CreateProduction())); - _ = await Assert.That(manifest.ReferencesByTest[SharesHelperFirstId].Contains(FromDualUseHelperId)).IsFalse(); - _ = await Assert.That(manifest.ReferencesByTest[CallsDualUseHelperId].Contains(TouchedId)).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert + .That(manifest.ReferencesByTest[SharesHelperFirstId].Contains(FromDualUseHelperId)) + .IsFalse(); + _ = await Assert.That(manifest.ReferencesByTest[CallsDualUseHelperId].Contains(TouchedId)).IsFalse(); + } } /// @@ -431,8 +442,11 @@ public async Task Collect_RecordedIds_ResolveBackToProductionSymbols() DocumentationCommentId.GetSymbolsForDeclarationId(id, production).IsEmpty ); - _ = await Assert.That(manifest.ReferencedMemberIds.Count).IsEqualTo(12); - _ = await Assert.That(Join(unresolved)).IsEqualTo(string.Empty); + using (Assert.Multiple()) + { + _ = await Assert.That(manifest.ReferencedMemberIds.Count).IsEqualTo(12); + _ = await Assert.That(Join(unresolved)).IsEqualTo(string.Empty); + } } [Test] @@ -473,9 +487,12 @@ public async Task Collect_CompilationWithoutTests_ReturnsAnEmptyManifest() var manifest = CollectSurface(production); - _ = await Assert.That(manifest.IsEmpty).IsTrue(); - _ = await Assert.That(manifest.ReferencesByTest.Count).IsEqualTo(0); - _ = await Assert.That(manifest.TestCaseCounts.Count).IsEqualTo(0); + using (Assert.Multiple()) + { + _ = await Assert.That(manifest.IsEmpty).IsTrue(); + _ = await Assert.That(manifest.ReferencesByTest.Count).IsEqualTo(0); + _ = await Assert.That(manifest.TestCaseCounts.Count).IsEqualTo(0); + } } /// diff --git a/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/TestSurfaceManifestReaderTests.cs b/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/TestSurfaceManifestReaderTests.cs index 84923c2..c1052fa 100644 --- a/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/TestSurfaceManifestReaderTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/TestSurfaceManifestReaderTests.cs @@ -31,12 +31,15 @@ public async Task TryRead_ValidManifest_ParsesTheBlockAndBothUnions() var parsed = TestSurfaceManifestReader.TryRead(text, out var manifest, out var error); - _ = await Assert.That(parsed).IsTrue(); - _ = await Assert.That(error).IsNull(); - _ = await Assert.That(Join(manifest.TestMethodIds)).IsEqualTo(TestId); - _ = await Assert.That(Join(manifest.ReferencedMemberIds)).IsEqualTo(ReferenceId); - _ = await Assert.That(manifest.TestCaseCounts[TestId]).IsEqualTo(TestCaseCount.Exact(3)); - _ = await Assert.That(Join(manifest.ReferencesByTest[TestId])).IsEqualTo(ReferenceId); + using (Assert.Multiple()) + { + _ = await Assert.That(parsed).IsTrue(); + _ = await Assert.That(error).IsNull(); + _ = await Assert.That(Join(manifest.TestMethodIds)).IsEqualTo(TestId); + _ = await Assert.That(Join(manifest.ReferencedMemberIds)).IsEqualTo(ReferenceId); + _ = await Assert.That(manifest.TestCaseCounts[TestId]).IsEqualTo(TestCaseCount.Exact(3)); + _ = await Assert.That(Join(manifest.ReferencesByTest[TestId])).IsEqualTo(ReferenceId); + } } [Test] @@ -46,9 +49,14 @@ public async Task TryRead_ATestWithSeveralReferences_AttributesThemAllToThatTest var parsed = TestSurfaceManifestReader.TryRead(text, out var manifest, out var error); - _ = await Assert.That(parsed).IsTrue(); - _ = await Assert.That(error).IsNull(); - _ = await Assert.That(Join(manifest.ReferencesByTest[TestId])).IsEqualTo(ReferenceId + "|" + OtherReferenceId); + using (Assert.Multiple()) + { + _ = await Assert.That(parsed).IsTrue(); + _ = await Assert.That(error).IsNull(); + _ = await Assert + .That(Join(manifest.ReferencesByTest[TestId])) + .IsEqualTo(ReferenceId + "|" + OtherReferenceId); + } } /// @@ -70,15 +78,18 @@ public async Task TryRead_TwoTestsSharingAReference_AttributesItToBoth() var parsed = TestSurfaceManifestReader.TryRead(text, out var manifest, out var error); - _ = await Assert.That(parsed).IsTrue(); - _ = await Assert.That(error).IsNull(); - _ = await Assert.That(Join(manifest.TestMethodIds)).IsEqualTo(TestId + "|" + OtherTestId); - _ = await Assert.That(Join(manifest.ReferencesByTest[TestId])).IsEqualTo(ReferenceId); - _ = await Assert - .That(Join(manifest.ReferencesByTest[OtherTestId])) - .IsEqualTo(ReferenceId + "|" + OtherReferenceId); - _ = await Assert.That(manifest.TestCaseCounts[TestId]).IsEqualTo(TestCaseCount.Exact(1)); - _ = await Assert.That(manifest.TestCaseCounts[OtherTestId]).IsEqualTo(TestCaseCount.Exact(2)); + using (Assert.Multiple()) + { + _ = await Assert.That(parsed).IsTrue(); + _ = await Assert.That(error).IsNull(); + _ = await Assert.That(Join(manifest.TestMethodIds)).IsEqualTo(TestId + "|" + OtherTestId); + _ = await Assert.That(Join(manifest.ReferencesByTest[TestId])).IsEqualTo(ReferenceId); + _ = await Assert + .That(Join(manifest.ReferencesByTest[OtherTestId])) + .IsEqualTo(ReferenceId + "|" + OtherReferenceId); + _ = await Assert.That(manifest.TestCaseCounts[TestId]).IsEqualTo(TestCaseCount.Exact(1)); + _ = await Assert.That(manifest.TestCaseCounts[OtherTestId]).IsEqualTo(TestCaseCount.Exact(2)); + } } [Test] @@ -88,11 +99,14 @@ public async Task TryRead_ATestWithoutAnyReference_ParsesToAnEmptyBlock() var parsed = TestSurfaceManifestReader.TryRead(text, out var manifest, out var error); - _ = await Assert.That(parsed).IsTrue(); - _ = await Assert.That(error).IsNull(); - _ = await Assert.That(Join(manifest.TestMethodIds)).IsEqualTo(TestId); - _ = await Assert.That(manifest.ReferencesByTest[TestId]).IsEmpty(); - _ = await Assert.That(manifest.ReferencedMemberIds).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(parsed).IsTrue(); + _ = await Assert.That(error).IsNull(); + _ = await Assert.That(Join(manifest.TestMethodIds)).IsEqualTo(TestId); + _ = await Assert.That(manifest.ReferencesByTest[TestId]).IsEmpty(); + _ = await Assert.That(manifest.ReferencedMemberIds).IsEmpty(); + } } [Test] @@ -102,9 +116,12 @@ public async Task TryRead_ALowerBoundCount_IsParsedAsALowerBound() var parsed = TestSurfaceManifestReader.TryRead(text, out var manifest, out var error); - _ = await Assert.That(parsed).IsTrue(); - _ = await Assert.That(error).IsNull(); - _ = await Assert.That(manifest.TestCaseCounts[TestId]).IsEqualTo(TestCaseCount.AtLeast(1)); + using (Assert.Multiple()) + { + _ = await Assert.That(parsed).IsTrue(); + _ = await Assert.That(error).IsNull(); + _ = await Assert.That(manifest.TestCaseCounts[TestId]).IsEqualTo(TestCaseCount.AtLeast(1)); + } } /// @@ -118,9 +135,12 @@ public async Task TryRead_ACountOfZero_IsAccepted() var parsed = TestSurfaceManifestReader.TryRead(text, out var manifest, out var error); - _ = await Assert.That(parsed).IsTrue(); - _ = await Assert.That(error).IsNull(); - _ = await Assert.That(manifest.TestCaseCounts[TestId]).IsEqualTo(TestCaseCount.Exact(0)); + using (Assert.Multiple()) + { + _ = await Assert.That(parsed).IsTrue(); + _ = await Assert.That(error).IsNull(); + _ = await Assert.That(manifest.TestCaseCounts[TestId]).IsEqualTo(TestCaseCount.Exact(0)); + } } [Test] @@ -128,9 +148,12 @@ public async Task TryRead_HeaderOnly_ParsesToEmptyManifest() { var parsed = TestSurfaceManifestReader.TryRead(Build("\n", Header), out var manifest, out var error); - _ = await Assert.That(parsed).IsTrue(); - _ = await Assert.That(error).IsNull(); - _ = await Assert.That(manifest.IsEmpty).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(parsed).IsTrue(); + _ = await Assert.That(error).IsNull(); + _ = await Assert.That(manifest.IsEmpty).IsTrue(); + } } [Test] @@ -155,11 +178,14 @@ public async Task TryRead_BlankAndCommentLines_AreIgnoredBetweenBlocksToo() var parsed = TestSurfaceManifestReader.TryRead(text, out var manifest, out var error); - _ = await Assert.That(parsed).IsTrue(); - _ = await Assert.That(error).IsNull(); - _ = await Assert.That(Join(manifest.TestMethodIds)).IsEqualTo(TestId + "|" + OtherTestId); - _ = await Assert.That(Join(manifest.ReferencesByTest[TestId])).IsEqualTo(ReferenceId); - _ = await Assert.That(manifest.ReferencesByTest[OtherTestId]).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(parsed).IsTrue(); + _ = await Assert.That(error).IsNull(); + _ = await Assert.That(Join(manifest.TestMethodIds)).IsEqualTo(TestId + "|" + OtherTestId); + _ = await Assert.That(Join(manifest.ReferencesByTest[TestId])).IsEqualTo(ReferenceId); + _ = await Assert.That(manifest.ReferencesByTest[OtherTestId]).IsEmpty(); + } } [Test] @@ -173,10 +199,13 @@ public async Task TryRead_UnknownLinePrefix_IsIgnored(string line) var parsed = TestSurfaceManifestReader.TryRead(text, out var manifest, out var error); - _ = await Assert.That(parsed).IsTrue(); - _ = await Assert.That(error).IsNull(); - _ = await Assert.That(Join(manifest.TestMethodIds)).IsEqualTo(TestId); - _ = await Assert.That(manifest.ReferencedMemberIds.IsEmpty).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(parsed).IsTrue(); + _ = await Assert.That(error).IsNull(); + _ = await Assert.That(Join(manifest.TestMethodIds)).IsEqualTo(TestId); + _ = await Assert.That(manifest.ReferencedMemberIds.IsEmpty).IsTrue(); + } } [Test] @@ -186,14 +215,17 @@ public async Task TryRead_HeaderMissing_ReportsTheFirstContentLine() var parsed = TestSurfaceManifestReader.TryRead(text, out var manifest, out var error); - _ = await Assert.That(parsed).IsFalse(); - _ = await Assert.That(manifest.IsEmpty).IsTrue(); - _ = await Assert - .That(error) - .IsEqualTo( - "Line 1: expected the test-surface manifest header 'frameshift-test-surface/1', " - + "but found 'T M:Tests.CalculatorTests.Add_TwoValues_ReturnsSum 1'." - ); + using (Assert.Multiple()) + { + _ = await Assert.That(parsed).IsFalse(); + _ = await Assert.That(manifest.IsEmpty).IsTrue(); + _ = await Assert + .That(error) + .IsEqualTo( + "Line 1: expected the test-surface manifest header 'frameshift-test-surface/1', " + + "but found 'T M:Tests.CalculatorTests.Add_TwoValues_ReturnsSum 1'." + ); + } } [Test] @@ -203,14 +235,17 @@ public async Task TryRead_WrongHeader_ReportsTheOneBasedLineNumber() var parsed = TestSurfaceManifestReader.TryRead(text, out var manifest, out var error); - _ = await Assert.That(parsed).IsFalse(); - _ = await Assert.That(manifest.IsEmpty).IsTrue(); - _ = await Assert - .That(error) - .IsEqualTo( - "Line 3: expected the test-surface manifest header 'frameshift-test-surface/1', " - + "but found 'frameshift-test-surface/0'." - ); + using (Assert.Multiple()) + { + _ = await Assert.That(parsed).IsFalse(); + _ = await Assert.That(manifest.IsEmpty).IsTrue(); + _ = await Assert + .That(error) + .IsEqualTo( + "Line 3: expected the test-surface manifest header 'frameshift-test-surface/1', " + + "but found 'frameshift-test-surface/0'." + ); + } } [Test] @@ -218,9 +253,12 @@ public async Task TryRead_EmptyFile_IsMalformed() { var parsed = TestSurfaceManifestReader.TryRead(SourceText.From(string.Empty), out var manifest, out var error); - _ = await Assert.That(parsed).IsFalse(); - _ = await Assert.That(manifest.IsEmpty).IsTrue(); - _ = await Assert.That(error).IsEqualTo(MissingHeaderError); + using (Assert.Multiple()) + { + _ = await Assert.That(parsed).IsFalse(); + _ = await Assert.That(manifest.IsEmpty).IsTrue(); + _ = await Assert.That(error).IsEqualTo(MissingHeaderError); + } } [Test] @@ -230,9 +268,12 @@ public async Task TryRead_OnlyCommentsAndBlankLines_IsMalformed() var parsed = TestSurfaceManifestReader.TryRead(text, out var manifest, out var error); - _ = await Assert.That(parsed).IsFalse(); - _ = await Assert.That(manifest.IsEmpty).IsTrue(); - _ = await Assert.That(error).IsEqualTo(MissingHeaderError); + using (Assert.Multiple()) + { + _ = await Assert.That(parsed).IsFalse(); + _ = await Assert.That(manifest.IsEmpty).IsTrue(); + _ = await Assert.That(error).IsEqualTo(MissingHeaderError); + } } [Test] @@ -246,11 +287,14 @@ public async Task TryRead_EntryWithoutId_IsMalformed(string entry, char marker) var parsed = TestSurfaceManifestReader.TryRead(text, out var manifest, out var error); - _ = await Assert.That(parsed).IsFalse(); - _ = await Assert.That(manifest.IsEmpty).IsTrue(); - _ = await Assert - .That(error) - .IsEqualTo($"Line 2: the '{marker}' entry does not specify a documentation comment id."); + using (Assert.Multiple()) + { + _ = await Assert.That(parsed).IsFalse(); + _ = await Assert.That(manifest.IsEmpty).IsTrue(); + _ = await Assert + .That(error) + .IsEqualTo($"Line 2: the '{marker}' entry does not specify a documentation comment id."); + } } /// @@ -264,14 +308,17 @@ public async Task TryRead_TestEntryWithoutACount_IsMalformed() var parsed = TestSurfaceManifestReader.TryRead(text, out var manifest, out var error); - _ = await Assert.That(parsed).IsFalse(); - _ = await Assert.That(manifest.IsEmpty).IsTrue(); - _ = await Assert - .That(error) - .IsEqualTo( - "Line 2: the 'T' entry for 'M:Tests.CalculatorTests.Add_TwoValues_ReturnsSum' does not " - + "specify a test case count." - ); + using (Assert.Multiple()) + { + _ = await Assert.That(parsed).IsFalse(); + _ = await Assert.That(manifest.IsEmpty).IsTrue(); + _ = await Assert + .That(error) + .IsEqualTo( + "Line 2: the 'T' entry for 'M:Tests.CalculatorTests.Add_TwoValues_ReturnsSum' does not " + + "specify a test case count." + ); + } } [Test] @@ -287,9 +334,12 @@ public async Task TryRead_TestEntryWithAMalformedCount_IsMalformed(string count, var parsed = TestSurfaceManifestReader.TryRead(text, out var manifest, out var error); - _ = await Assert.That(parsed).IsFalse(); - _ = await Assert.That(manifest.IsEmpty).IsTrue(); - _ = await Assert.That(error).IsEqualTo($"Line 2: '{reported}' is not a valid test case count."); + using (Assert.Multiple()) + { + _ = await Assert.That(parsed).IsFalse(); + _ = await Assert.That(manifest.IsEmpty).IsTrue(); + _ = await Assert.That(error).IsEqualTo($"Line 2: '{reported}' is not a valid test case count."); + } } /// @@ -303,9 +353,12 @@ public async Task TryRead_ReferenceBeforeAnyTest_IsMalformed() var parsed = TestSurfaceManifestReader.TryRead(text, out var manifest, out var error); - _ = await Assert.That(parsed).IsFalse(); - _ = await Assert.That(manifest.IsEmpty).IsTrue(); - _ = await Assert.That(error).IsEqualTo("Line 2: the 'R' entry appears before any 'T' entry."); + using (Assert.Multiple()) + { + _ = await Assert.That(parsed).IsFalse(); + _ = await Assert.That(manifest.IsEmpty).IsTrue(); + _ = await Assert.That(error).IsEqualTo("Line 2: the 'R' entry appears before any 'T' entry."); + } } [Test] @@ -315,9 +368,12 @@ public async Task TryRead_ReferenceAfterACommentButBeforeAnyTest_ReportsTheRefer var parsed = TestSurfaceManifestReader.TryRead(text, out var manifest, out var error); - _ = await Assert.That(parsed).IsFalse(); - _ = await Assert.That(manifest.IsEmpty).IsTrue(); - _ = await Assert.That(error).IsEqualTo("Line 4: the 'R' entry appears before any 'T' entry."); + using (Assert.Multiple()) + { + _ = await Assert.That(parsed).IsFalse(); + _ = await Assert.That(manifest.IsEmpty).IsTrue(); + _ = await Assert.That(error).IsEqualTo("Line 4: the 'R' entry appears before any 'T' entry."); + } } [Test] @@ -329,11 +385,14 @@ public async Task TryRead_LineEnding_IsAcceptedInBothForms(string newLine) var parsed = TestSurfaceManifestReader.TryRead(text, out var manifest, out var error); - _ = await Assert.That(parsed).IsTrue(); - _ = await Assert.That(error).IsNull(); - _ = await Assert.That(Join(manifest.TestMethodIds)).IsEqualTo(TestId); - _ = await Assert.That(Join(manifest.ReferencedMemberIds)).IsEqualTo(ReferenceId); - _ = await Assert.That(manifest.TestCaseCounts[TestId]).IsEqualTo(TestCaseCount.Exact(3)); + using (Assert.Multiple()) + { + _ = await Assert.That(parsed).IsTrue(); + _ = await Assert.That(error).IsNull(); + _ = await Assert.That(Join(manifest.TestMethodIds)).IsEqualTo(TestId); + _ = await Assert.That(Join(manifest.ReferencedMemberIds)).IsEqualTo(ReferenceId); + _ = await Assert.That(manifest.TestCaseCounts[TestId]).IsEqualTo(TestCaseCount.Exact(3)); + } } /// @@ -347,14 +406,17 @@ public async Task TryRead_TheSameTestDeclaredTwice_IsMalformed() var parsed = TestSurfaceManifestReader.TryRead(text, out var manifest, out var error); - _ = await Assert.That(parsed).IsFalse(); - _ = await Assert.That(manifest.IsEmpty).IsTrue(); - _ = await Assert - .That(error) - .IsEqualTo( - "Line 3: the 'T' entry for 'M:Tests.CalculatorTests.Add_TwoValues_ReturnsSum' is " - + "declared more than once." - ); + using (Assert.Multiple()) + { + _ = await Assert.That(parsed).IsFalse(); + _ = await Assert.That(manifest.IsEmpty).IsTrue(); + _ = await Assert + .That(error) + .IsEqualTo( + "Line 3: the 'T' entry for 'M:Tests.CalculatorTests.Add_TwoValues_ReturnsSum' is " + + "declared more than once." + ); + } } [Test] @@ -371,10 +433,13 @@ public async Task TryRead_DuplicateReferencesInOneBlock_CollapseIntoOneEntry() var parsed = TestSurfaceManifestReader.TryRead(text, out var manifest, out var error); - _ = await Assert.That(parsed).IsTrue(); - _ = await Assert.That(error).IsNull(); - _ = await Assert.That(manifest.ReferencesByTest[TestId].Count).IsEqualTo(2); - _ = await Assert.That(Join(manifest.ReferencedMemberIds)).IsEqualTo(ReferenceId + "|" + OtherReferenceId); + using (Assert.Multiple()) + { + _ = await Assert.That(parsed).IsTrue(); + _ = await Assert.That(error).IsNull(); + _ = await Assert.That(manifest.ReferencesByTest[TestId].Count).IsEqualTo(2); + _ = await Assert.That(Join(manifest.ReferencedMemberIds)).IsEqualTo(ReferenceId + "|" + OtherReferenceId); + } } [Test] @@ -390,11 +455,14 @@ public async Task TryRead_IdsDifferingOnlyInCase_AreKeptApart() var parsed = TestSurfaceManifestReader.TryRead(text, out var manifest, out var error); - _ = await Assert.That(parsed).IsTrue(); - _ = await Assert.That(error).IsNull(); - _ = await Assert - .That(Join(manifest.ReferencedMemberIds)) - .IsEqualTo("M:Production.Calculator.ADD|M:Production.Calculator.Add"); + using (Assert.Multiple()) + { + _ = await Assert.That(parsed).IsTrue(); + _ = await Assert.That(error).IsNull(); + _ = await Assert + .That(Join(manifest.ReferencedMemberIds)) + .IsEqualTo("M:Production.Calculator.ADD|M:Production.Calculator.Add"); + } } /// @@ -408,10 +476,13 @@ public async Task TryRead_ParsedManifest_KeysBothDictionariesByTheSameTests() var parsed = TestSurfaceManifestReader.TryRead(text, out var manifest, out var error); - _ = await Assert.That(parsed).IsTrue(); - _ = await Assert.That(error).IsNull(); - _ = await Assert.That(Keys(manifest.TestCaseCounts)).IsEqualTo(TestId + "|" + OtherTestId); - _ = await Assert.That(Keys(manifest.ReferencesByTest)).IsEqualTo(TestId + "|" + OtherTestId); + using (Assert.Multiple()) + { + _ = await Assert.That(parsed).IsTrue(); + _ = await Assert.That(error).IsNull(); + _ = await Assert.That(Keys(manifest.TestCaseCounts)).IsEqualTo(TestId + "|" + OtherTestId); + _ = await Assert.That(Keys(manifest.ReferencesByTest)).IsEqualTo(TestId + "|" + OtherTestId); + } } [Test] diff --git a/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/TestSurfaceManifestTests.cs b/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/TestSurfaceManifestTests.cs index ff05dae..0c7a5ea 100644 --- a/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/TestSurfaceManifestTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/TestSurfaceManifestTests.cs @@ -61,11 +61,14 @@ public async Task Empty_TheSharedManifest_HoldsNoIdAtAll() { var manifest = TestSurfaceManifest.Empty; - _ = await Assert.That(manifest.IsEmpty).IsTrue(); - _ = await Assert.That(manifest.TestMethodIds).IsEmpty(); - _ = await Assert.That(manifest.ReferencedMemberIds).IsEmpty(); - _ = await Assert.That(manifest.TestCaseCounts).IsEmpty(); - _ = await Assert.That(manifest.ReferencesByTest).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(manifest.IsEmpty).IsTrue(); + _ = await Assert.That(manifest.TestMethodIds).IsEmpty(); + _ = await Assert.That(manifest.ReferencedMemberIds).IsEmpty(); + _ = await Assert.That(manifest.TestCaseCounts).IsEmpty(); + _ = await Assert.That(manifest.ReferencesByTest).IsEmpty(); + } } [Test] @@ -93,9 +96,12 @@ public async Task IsEmpty_ManifestWithAReferencedMemberOnly_ReturnsFalse() { var manifest = new TestSurfaceManifest(Ids(), Ids(MemberId)); - _ = await Assert.That(manifest.IsEmpty).IsFalse(); - _ = await Assert.That(Join(manifest.ReferencedMemberIds)).IsEqualTo(MemberId); - _ = await Assert.That(manifest.TestMethodIds).IsEmpty(); + using (Assert.Multiple()) + { + _ = await Assert.That(manifest.IsEmpty).IsFalse(); + _ = await Assert.That(Join(manifest.ReferencedMemberIds)).IsEqualTo(MemberId); + _ = await Assert.That(manifest.TestMethodIds).IsEmpty(); + } } [Test] @@ -103,9 +109,12 @@ public async Task IsEmpty_ManifestWithBothKindsOfId_ReturnsFalse() { var manifest = new TestSurfaceManifest(Ids(TestId), Ids(MemberId)); - _ = await Assert.That(manifest.IsEmpty).IsFalse(); - _ = await Assert.That(manifest.TestMethodIds).Contains(TestId); - _ = await Assert.That(manifest.ReferencedMemberIds).Contains(MemberId); + using (Assert.Multiple()) + { + _ = await Assert.That(manifest.IsEmpty).IsFalse(); + _ = await Assert.That(manifest.TestMethodIds).Contains(TestId); + _ = await Assert.That(manifest.ReferencedMemberIds).Contains(MemberId); + } } /// @@ -122,10 +131,13 @@ public async Task Constructor_SetsWithALaxComparer_AreReComparedOrdinally() ImmutableHashSet.Create(StringComparer.OrdinalIgnoreCase, MemberId) ); - _ = await Assert.That(lax.Contains(TestId.ToUpperInvariant())).IsTrue(); - _ = await Assert.That(manifest.TestMethodIds.Contains(TestId.ToUpperInvariant())).IsFalse(); - _ = await Assert.That(manifest.ReferencedMemberIds.Contains(MemberId.ToUpperInvariant())).IsFalse(); - _ = await Assert.That(manifest.TestMethodIds.Contains(TestId)).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(lax.Contains(TestId.ToUpperInvariant())).IsTrue(); + _ = await Assert.That(manifest.TestMethodIds.Contains(TestId.ToUpperInvariant())).IsFalse(); + _ = await Assert.That(manifest.ReferencedMemberIds.Contains(MemberId.ToUpperInvariant())).IsFalse(); + _ = await Assert.That(manifest.TestMethodIds.Contains(TestId)).IsTrue(); + } } /// @@ -137,10 +149,15 @@ public async Task Constructor_TheFlatForm_RecordsEveryTestWithALowerBoundAndEver { var manifest = new TestSurfaceManifest(Ids(TestId, OtherTestId), Ids(MemberId, OtherMemberId)); - _ = await Assert.That(manifest.TestCaseCounts[TestId]).IsEqualTo(TestCaseCount.AtLeast(1)); - _ = await Assert.That(manifest.TestCaseCounts[OtherTestId]).IsEqualTo(TestCaseCount.AtLeast(1)); - _ = await Assert.That(Join(manifest.ReferencesByTest[TestId])).IsEqualTo(MemberId + "|" + OtherMemberId); - _ = await Assert.That(Join(manifest.ReferencesByTest[OtherTestId])).IsEqualTo(MemberId + "|" + OtherMemberId); + using (Assert.Multiple()) + { + _ = await Assert.That(manifest.TestCaseCounts[TestId]).IsEqualTo(TestCaseCount.AtLeast(1)); + _ = await Assert.That(manifest.TestCaseCounts[OtherTestId]).IsEqualTo(TestCaseCount.AtLeast(1)); + _ = await Assert.That(Join(manifest.ReferencesByTest[TestId])).IsEqualTo(MemberId + "|" + OtherMemberId); + _ = await Assert + .That(Join(manifest.ReferencesByTest[OtherTestId])) + .IsEqualTo(MemberId + "|" + OtherMemberId); + } } [Test] @@ -151,11 +168,14 @@ public async Task Constructor_TheBlockForm_DerivesBothUnionsFromTheBlocks() (OtherTestId, TestCaseCount.AtLeast(1), [MemberId, OtherMemberId]) ); - _ = await Assert.That(Join(manifest.TestMethodIds)).IsEqualTo(TestId + "|" + OtherTestId); - _ = await Assert.That(Join(manifest.ReferencedMemberIds)).IsEqualTo(MemberId + "|" + OtherMemberId); - _ = await Assert.That(manifest.TestCaseCounts[TestId]).IsEqualTo(TestCaseCount.Exact(3)); - _ = await Assert.That(manifest.TestCaseCounts[OtherTestId]).IsEqualTo(TestCaseCount.AtLeast(1)); - _ = await Assert.That(manifest.IsEmpty).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(Join(manifest.TestMethodIds)).IsEqualTo(TestId + "|" + OtherTestId); + _ = await Assert.That(Join(manifest.ReferencedMemberIds)).IsEqualTo(MemberId + "|" + OtherMemberId); + _ = await Assert.That(manifest.TestCaseCounts[TestId]).IsEqualTo(TestCaseCount.Exact(3)); + _ = await Assert.That(manifest.TestCaseCounts[OtherTestId]).IsEqualTo(TestCaseCount.AtLeast(1)); + _ = await Assert.That(manifest.IsEmpty).IsFalse(); + } } [Test] @@ -163,10 +183,13 @@ public async Task Constructor_ABlockWithoutAnyReference_KeepsTheTestWithAnEmptyR { var manifest = Blocks((TestId, TestCaseCount.Exact(1), [])); - _ = await Assert.That(Join(manifest.TestMethodIds)).IsEqualTo(TestId); - _ = await Assert.That(manifest.ReferencedMemberIds).IsEmpty(); - _ = await Assert.That(manifest.ReferencesByTest[TestId]).IsEmpty(); - _ = await Assert.That(manifest.IsEmpty).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(Join(manifest.TestMethodIds)).IsEqualTo(TestId); + _ = await Assert.That(manifest.ReferencedMemberIds).IsEmpty(); + _ = await Assert.That(manifest.ReferencesByTest[TestId]).IsEmpty(); + _ = await Assert.That(manifest.IsEmpty).IsFalse(); + } } /// @@ -184,8 +207,11 @@ public async Task Constructor_ATestMissingFromTheCounts_IsCompletedWithALowerBou references.ToImmutable() ); - _ = await Assert.That(Join(manifest.TestMethodIds)).IsEqualTo(TestId); - _ = await Assert.That(manifest.TestCaseCounts[TestId]).IsEqualTo(TestCaseCount.AtLeast(1)); + using (Assert.Multiple()) + { + _ = await Assert.That(Join(manifest.TestMethodIds)).IsEqualTo(TestId); + _ = await Assert.That(manifest.TestCaseCounts[TestId]).IsEqualTo(TestCaseCount.AtLeast(1)); + } } [Test] @@ -199,9 +225,12 @@ public async Task Constructor_ATestMissingFromTheReferences_IsCompletedWithAnEmp ImmutableDictionary>.Empty ); - _ = await Assert.That(Join(manifest.TestMethodIds)).IsEqualTo(TestId); - _ = await Assert.That(manifest.ReferencesByTest[TestId]).IsEmpty(); - _ = await Assert.That(manifest.TestCaseCounts[TestId]).IsEqualTo(TestCaseCount.Exact(2)); + using (Assert.Multiple()) + { + _ = await Assert.That(Join(manifest.TestMethodIds)).IsEqualTo(TestId); + _ = await Assert.That(manifest.ReferencesByTest[TestId]).IsEmpty(); + _ = await Assert.That(manifest.TestCaseCounts[TestId]).IsEqualTo(TestCaseCount.Exact(2)); + } } [Test] @@ -215,8 +244,11 @@ public async Task Constructor_TheBlockForm_ReComparesEveryReferenceSetOrdinally( references.ToImmutable() ); - _ = await Assert.That(manifest.ReferencesByTest[TestId].Contains(MemberId.ToUpperInvariant())).IsFalse(); - _ = await Assert.That(manifest.ReferencesByTest[TestId].Contains(MemberId)).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(manifest.ReferencesByTest[TestId].Contains(MemberId.ToUpperInvariant())).IsFalse(); + _ = await Assert.That(manifest.ReferencesByTest[TestId].Contains(MemberId)).IsTrue(); + } } /// @@ -232,12 +264,15 @@ public async Task Merge_ManifestsOfTwoFrameworks_KeepsTheBlocksApart() var merged = TestSurfaceManifest.Merge([first, second]); - _ = await Assert.That(Join(merged.TestMethodIds)).IsEqualTo(TestId + "|" + OtherTestId); - _ = await Assert.That(Join(merged.ReferencedMemberIds)).IsEqualTo(MemberId + "|" + OtherMemberId); - _ = await Assert.That(merged.TestCaseCounts[TestId]).IsEqualTo(TestCaseCount.Exact(3)); - _ = await Assert.That(merged.TestCaseCounts[OtherTestId]).IsEqualTo(TestCaseCount.Exact(1)); - _ = await Assert.That(Join(merged.ReferencesByTest[TestId])).IsEqualTo(MemberId); - _ = await Assert.That(Join(merged.ReferencesByTest[OtherTestId])).IsEqualTo(MemberId + "|" + OtherMemberId); + using (Assert.Multiple()) + { + _ = await Assert.That(Join(merged.TestMethodIds)).IsEqualTo(TestId + "|" + OtherTestId); + _ = await Assert.That(Join(merged.ReferencedMemberIds)).IsEqualTo(MemberId + "|" + OtherMemberId); + _ = await Assert.That(merged.TestCaseCounts[TestId]).IsEqualTo(TestCaseCount.Exact(3)); + _ = await Assert.That(merged.TestCaseCounts[OtherTestId]).IsEqualTo(TestCaseCount.Exact(1)); + _ = await Assert.That(Join(merged.ReferencesByTest[TestId])).IsEqualTo(MemberId); + _ = await Assert.That(Join(merged.ReferencesByTest[OtherTestId])).IsEqualTo(MemberId + "|" + OtherMemberId); + } } /// @@ -252,9 +287,12 @@ public async Task Merge_TheSameTestInTwoManifests_UnionsTheReferencesAndKeepsThe var merged = TestSurfaceManifest.Merge([first, second]); - _ = await Assert.That(Join(merged.TestMethodIds)).IsEqualTo(TestId); - _ = await Assert.That(merged.TestCaseCounts[TestId]).IsEqualTo(TestCaseCount.Exact(3)); - _ = await Assert.That(Join(merged.ReferencesByTest[TestId])).IsEqualTo(MemberId + "|" + OtherMemberId); + using (Assert.Multiple()) + { + _ = await Assert.That(Join(merged.TestMethodIds)).IsEqualTo(TestId); + _ = await Assert.That(merged.TestCaseCounts[TestId]).IsEqualTo(TestCaseCount.Exact(3)); + _ = await Assert.That(Join(merged.ReferencesByTest[TestId])).IsEqualTo(MemberId + "|" + OtherMemberId); + } } [Test] @@ -275,9 +313,12 @@ public async Task Merge_AFlatManifestWithoutAnyTest_KeepsItsReferences() var merged = TestSurfaceManifest.Merge([Blocks((TestId, TestCaseCount.Exact(1), [MemberId])), flat]); - _ = await Assert.That(Join(merged.TestMethodIds)).IsEqualTo(TestId); - _ = await Assert.That(Join(merged.ReferencedMemberIds)).IsEqualTo(MemberId + "|" + OtherMemberId); - _ = await Assert.That(Join(merged.ReferencesByTest[TestId])).IsEqualTo(MemberId); + using (Assert.Multiple()) + { + _ = await Assert.That(Join(merged.TestMethodIds)).IsEqualTo(TestId); + _ = await Assert.That(Join(merged.ReferencedMemberIds)).IsEqualTo(MemberId + "|" + OtherMemberId); + _ = await Assert.That(Join(merged.ReferencesByTest[TestId])).IsEqualTo(MemberId); + } } [Test] diff --git a/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/TestSurfaceManifestWriterTests.cs b/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/TestSurfaceManifestWriterTests.cs index e35baf1..62b6638 100644 --- a/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/TestSurfaceManifestWriterTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/TestSurfaceManifestWriterTests.cs @@ -103,9 +103,12 @@ public async Task Write_Manifest_UsesLineFeedOnlyAndEndsWithOne() var written = TestSurfaceManifestWriter.Write(manifest); - _ = await Assert.That(written.Contains('\r', StringComparison.Ordinal)).IsFalse(); - _ = await Assert.That(written[^1]).IsEqualTo('\n'); - _ = await Assert.That(written.Split('\n').Length).IsEqualTo(4); + using (Assert.Multiple()) + { + _ = await Assert.That(written.Contains('\r', StringComparison.Ordinal)).IsFalse(); + _ = await Assert.That(written[^1]).IsEqualTo('\n'); + _ = await Assert.That(written.Split('\n').Length).IsEqualTo(4); + } } /// @@ -178,8 +181,11 @@ public async Task RoundTrip_WrittenManifest_ParsesBackIntoAnEqualManifest() out var error ); - _ = await Assert.That(parsed).IsTrue(); - _ = await Assert.That(error).IsNull(); + using (Assert.Multiple()) + { + _ = await Assert.That(parsed).IsTrue(); + _ = await Assert.That(error).IsNull(); + } _ = await AssertSameSurface(manifest, roundTripped).ConfigureAwait(false); } @@ -194,8 +200,11 @@ public async Task RoundTrip_ATestWithoutAnyReference_SurvivesTheRoundTrip() out var error ); - _ = await Assert.That(parsed).IsTrue(); - _ = await Assert.That(error).IsNull(); + using (Assert.Multiple()) + { + _ = await Assert.That(parsed).IsTrue(); + _ = await Assert.That(error).IsNull(); + } _ = await AssertSameSurface(manifest, roundTripped).ConfigureAwait(false); _ = await Assert.That(roundTripped.ReferencesByTest["M:Tests.A.First"]).IsEmpty(); } @@ -207,9 +216,12 @@ public async Task RoundTrip_EmptyManifest_ParsesBackIntoAnEmptyManifest() var parsed = TestSurfaceManifestReader.TryRead(SourceText.From(written), out var roundTripped, out var error); - _ = await Assert.That(parsed).IsTrue(); - _ = await Assert.That(error).IsNull(); - _ = await Assert.That(roundTripped.IsEmpty).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(parsed).IsTrue(); + _ = await Assert.That(error).IsNull(); + _ = await Assert.That(roundTripped.IsEmpty).IsTrue(); + } _ = await AssertSameSurface(TestSurfaceManifest.Empty, roundTripped).ConfigureAwait(false); } @@ -233,9 +245,12 @@ public async Task RoundTrip_WritingTwice_ProducesTheSameText() private static async Task AssertSameSurface(TestSurfaceManifest expected, TestSurfaceManifest actual) { - _ = await Assert.That(Join(actual.TestMethodIds)).IsEqualTo(Join(expected.TestMethodIds)); - _ = await Assert.That(Join(actual.ReferencedMemberIds)).IsEqualTo(Join(expected.ReferencedMemberIds)); - _ = await Assert.That(Describe(actual)).IsEqualTo(Describe(expected)); + using (Assert.Multiple()) + { + _ = await Assert.That(Join(actual.TestMethodIds)).IsEqualTo(Join(expected.TestMethodIds)); + _ = await Assert.That(Join(actual.ReferencedMemberIds)).IsEqualTo(Join(expected.ReferencedMemberIds)); + _ = await Assert.That(Describe(actual)).IsEqualTo(Describe(expected)); + } return true; } diff --git a/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/XunitV2TestFrameworkProbeTests.cs b/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/XunitV2TestFrameworkProbeTests.cs index ea7f337..59c5ff3 100644 --- a/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/XunitV2TestFrameworkProbeTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/XunitV2TestFrameworkProbeTests.cs @@ -127,8 +127,11 @@ public async Task TryCreateRecognizer_ReferencingTheFrameworkAssemblyWithoutTheT var recognizer = XunitV2TestFrameworkProbe.Instance.TryCreateRecognizer(compilation); - _ = await Assert.That(XunitV2TestFrameworkProbe.GetTestAttributeType(compilation)).IsNull(); - _ = await Assert.That(recognizer).IsNotNull(); + using (Assert.Multiple()) + { + _ = await Assert.That(XunitV2TestFrameworkProbe.GetTestAttributeType(compilation)).IsNull(); + _ = await Assert.That(recognizer).IsNotNull(); + } } [Test] @@ -207,9 +210,12 @@ public async Task IsTestMethod_RecognizerWithoutTheWellKnownType_FindsNoTest() var decorated = FindMethod(compilation, "DecoratedTest"); var plain = FindMethod(compilation, "PlainMethod"); - _ = await Assert.That(XunitV2TestFrameworkProbe.GetTestAttributeType(compilation)).IsNull(); - _ = await Assert.That(recognizer.IsTestMethod(decorated)).IsFalse(); - _ = await Assert.That(recognizer.IsTestMethod(plain)).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(XunitV2TestFrameworkProbe.GetTestAttributeType(compilation)).IsNull(); + _ = await Assert.That(recognizer.IsTestMethod(decorated)).IsFalse(); + _ = await Assert.That(recognizer.IsTestMethod(plain)).IsFalse(); + } } [Test] @@ -238,9 +244,12 @@ public async Task IsFrameworkAssembly_AssemblyName_IsClassifiedByItsName() var xunitV3 = SatelliteAssembly(CreateSatelliteConsumer(PlainSource, XunitV3AssemblyName), XunitV3AssemblyName); var foreign = SatelliteAssembly(CreateSatelliteConsumer(PlainSource, ForeignAssemblyName), ForeignAssemblyName); - _ = await Assert.That(XunitV2TestFrameworkProbe.IsFrameworkAssembly(framework)).IsTrue(); - _ = await Assert.That(XunitV2TestFrameworkProbe.IsFrameworkAssembly(xunitV3)).IsFalse(); - _ = await Assert.That(XunitV2TestFrameworkProbe.IsFrameworkAssembly(foreign)).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(XunitV2TestFrameworkProbe.IsFrameworkAssembly(framework)).IsTrue(); + _ = await Assert.That(XunitV2TestFrameworkProbe.IsFrameworkAssembly(xunitV3)).IsFalse(); + _ = await Assert.That(XunitV2TestFrameworkProbe.IsFrameworkAssembly(foreign)).IsFalse(); + } } [Test] @@ -273,8 +282,11 @@ public async Task GetTestAttributeType_WithFrameworkReference_ResolvesTheAttribu { var resolved = XunitV2TestFrameworkProbe.GetTestAttributeType(CreateXunitV2Fixture()); - _ = await Assert.That(resolved?.ToDisplayString()).IsEqualTo("Xunit.FactAttribute"); - _ = await Assert.That(resolved?.ContainingAssembly.Name).IsEqualTo(FrameworkAssemblyName); + using (Assert.Multiple()) + { + _ = await Assert.That(resolved?.ToDisplayString()).IsEqualTo("Xunit.FactAttribute"); + _ = await Assert.That(resolved?.ContainingAssembly.Name).IsEqualTo(FrameworkAssemblyName); + } } [Test] @@ -295,8 +307,11 @@ public async Task GetTestAttributeType_FrameworkAssemblyWithoutTheType_ReturnsNu { var compilation = CreateSatelliteConsumer(CasesSource, FrameworkAssemblyName); - _ = await Assert.That(XunitV2TestFrameworkProbe.FindFrameworkAssembly(compilation)).IsNotNull(); - _ = await Assert.That(XunitV2TestFrameworkProbe.GetTestAttributeType(compilation)).IsNull(); + using (Assert.Multiple()) + { + _ = await Assert.That(XunitV2TestFrameworkProbe.FindFrameworkAssembly(compilation)).IsNotNull(); + _ = await Assert.That(XunitV2TestFrameworkProbe.GetTestAttributeType(compilation)).IsNull(); + } } [Test] @@ -336,14 +351,17 @@ public async Task GetTestAttributeType_ReferencingBothVersions_ResolvesTheAttrib var compilation = CompilationFactory.Create(PlainSource, TestFramework.All, filePath: "Cases.cs"); var resolved = XunitV2TestFrameworkProbe.GetTestAttributeType(compilation); - _ = await Assert.That(Describe(compilation)).IsEqualTo(DiagnosticAssertions.NoDiagnostics); - _ = await Assert.That(compilation.GetTypeByMetadataName("Xunit.FactAttribute")).IsNull(); - _ = await Assert.That(compilation.GetTypesByMetadataName("Xunit.FactAttribute").Length).IsEqualTo(2); - _ = await Assert.That(resolved?.ToDisplayString()).IsEqualTo("Xunit.FactAttribute"); - _ = await Assert.That(resolved?.ContainingAssembly.Name).IsEqualTo(FrameworkAssemblyName); - _ = await Assert - .That(XunitV2TestFrameworkProbe.Instance.TryCreateRecognizer(compilation)?.FrameworkName) - .IsEqualTo(FrameworkName); + using (Assert.Multiple()) + { + _ = await Assert.That(Describe(compilation)).IsEqualTo(DiagnosticAssertions.NoDiagnostics); + _ = await Assert.That(compilation.GetTypeByMetadataName("Xunit.FactAttribute")).IsNull(); + _ = await Assert.That(compilation.GetTypesByMetadataName("Xunit.FactAttribute").Length).IsEqualTo(2); + _ = await Assert.That(resolved?.ToDisplayString()).IsEqualTo("Xunit.FactAttribute"); + _ = await Assert.That(resolved?.ContainingAssembly.Name).IsEqualTo(FrameworkAssemblyName); + _ = await Assert + .That(XunitV2TestFrameworkProbe.Instance.TryCreateRecognizer(compilation)?.FrameworkName) + .IsEqualTo(FrameworkName); + } } #endif diff --git a/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/XunitV2TestMethodRecognizerTests.cs b/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/XunitV2TestMethodRecognizerTests.cs index 24ed056..be80f38 100644 --- a/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/XunitV2TestMethodRecognizerTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/XunitV2TestMethodRecognizerTests.cs @@ -491,8 +491,11 @@ public async Task IsTestMethod_FactAttributeFromAnUnrelatedNamespace_IsNotClassi var recognizer = CreateRecognizer(compilation); var method = FindMethod(compilation, "Fixture.UnrelatedCases", "LooksLikeATest"); - _ = await Assert.That(recognizer.IsTestMethod(method)).IsFalse(); - _ = await Assert.That(new XunitV2TestMethodRecognizer(null).IsTestMethod(method)).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(recognizer.IsTestMethod(method)).IsFalse(); + _ = await Assert.That(new XunitV2TestMethodRecognizer(null).IsTestMethod(method)).IsFalse(); + } } /// @@ -510,10 +513,13 @@ public async Task IsTestMethod_RecognizerWithoutAnAttributeType_FindsNoTest() var derived = FindMethod(compilation, CasesTypeName, "DerivedAttributeTest"); var plain = FindMethod(compilation, CasesTypeName, "PlainMethod"); - _ = await Assert.That(recognizer.FrameworkName).IsEqualTo(FrameworkName); - _ = await Assert.That(recognizer.IsTestMethod(fact)).IsFalse(); - _ = await Assert.That(recognizer.IsTestMethod(derived)).IsFalse(); - _ = await Assert.That(recognizer.IsTestMethod(plain)).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(recognizer.FrameworkName).IsEqualTo(FrameworkName); + _ = await Assert.That(recognizer.IsTestMethod(fact)).IsFalse(); + _ = await Assert.That(recognizer.IsTestMethod(derived)).IsFalse(); + _ = await Assert.That(recognizer.IsTestMethod(plain)).IsFalse(); + } } [Test] @@ -618,10 +624,13 @@ public async Task GetTestCaseCount_ExactCountAndLowerBound_AreDistinguishedByIsE var exact = recognizer.GetTestCaseCount(FindMethod(compilation, CountCasesTypeName, "ThreeInlineData")); var bound = recognizer.GetTestCaseCount(FindMethod(compilation, CountCasesTypeName, "ClassDataTheory")); - _ = await Assert.That(exact.Value).IsEqualTo(3); - _ = await Assert.That(exact.IsExact).IsTrue(); - _ = await Assert.That(bound.Value).IsEqualTo(1); - _ = await Assert.That(bound.IsExact).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(exact.Value).IsEqualTo(3); + _ = await Assert.That(exact.IsExact).IsTrue(); + _ = await Assert.That(bound.Value).IsEqualTo(1); + _ = await Assert.That(bound.IsExact).IsFalse(); + } } /// diff --git a/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/XunitV3TestFrameworkProbeTests.cs b/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/XunitV3TestFrameworkProbeTests.cs index 8d5d478..b87bea0 100644 --- a/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/XunitV3TestFrameworkProbeTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/XunitV3TestFrameworkProbeTests.cs @@ -139,8 +139,11 @@ public async Task TryCreateRecognizer_ReferencingOnlyVersionTwo_ReturnsNull() { var compilation = CreateXunitFixture(TestFramework.XunitV2); - _ = await Assert.That(XunitV3TestFrameworkProbe.GetTestAttributeType(compilation)).IsNull(); - _ = await Assert.That(XunitV3TestFrameworkProbe.Instance.TryCreateRecognizer(compilation)).IsNull(); + using (Assert.Multiple()) + { + _ = await Assert.That(XunitV3TestFrameworkProbe.GetTestAttributeType(compilation)).IsNull(); + _ = await Assert.That(XunitV3TestFrameworkProbe.Instance.TryCreateRecognizer(compilation)).IsNull(); + } } /// @@ -210,9 +213,12 @@ public async Task IsTestMethod_RecognizerWithoutTheWellKnownType_RecognizesNothi var decorated = FindMethod(compilation, "DecoratedTest"); var plain = FindMethod(compilation, "PlainMethod"); - _ = await Assert.That(XunitV3TestFrameworkProbe.GetTestAttributeType(compilation)).IsNull(); - _ = await Assert.That(recognizer.IsTestMethod(decorated)).IsFalse(); - _ = await Assert.That(recognizer.IsTestMethod(plain)).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(XunitV3TestFrameworkProbe.GetTestAttributeType(compilation)).IsNull(); + _ = await Assert.That(recognizer.IsTestMethod(decorated)).IsFalse(); + _ = await Assert.That(recognizer.IsTestMethod(plain)).IsFalse(); + } } [Test] @@ -231,8 +237,11 @@ public async Task GetTestAttributeType_WithFrameworkReference_ResolvesTheAttribu { var resolved = XunitV3TestFrameworkProbe.GetTestAttributeType(CreateXunitFixture(TestFramework.XunitV3)); - _ = await Assert.That(resolved?.ToDisplayString()).IsEqualTo(TestAttributeDisplayName); - _ = await Assert.That(resolved?.ContainingAssembly.Name).IsEqualTo(FrameworkAssemblyName); + using (Assert.Multiple()) + { + _ = await Assert.That(resolved?.ToDisplayString()).IsEqualTo(TestAttributeDisplayName); + _ = await Assert.That(resolved?.ContainingAssembly.Name).IsEqualTo(FrameworkAssemblyName); + } } [Test] @@ -257,10 +266,13 @@ public async Task GetTestAttributeType_ReferencingBothMajorVersions_ResolvesExac var resolved = XunitV3TestFrameworkProbe.GetTestAttributeType(compilation); var versionTwo = XunitV2TestFrameworkProbe.GetTestAttributeType(compilation); - _ = await Assert.That(compilation.GetTypeByMetadataName(TestAttributeDisplayName)).IsNull(); - _ = await Assert.That(resolved?.ContainingAssembly.Name).IsEqualTo(FrameworkAssemblyName); - _ = await Assert.That(versionTwo?.ContainingAssembly.Name).IsEqualTo(VersionTwoAssemblyName); - _ = await Assert.That(SymbolEqualityComparer.Default.Equals(resolved, versionTwo)).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(compilation.GetTypeByMetadataName(TestAttributeDisplayName)).IsNull(); + _ = await Assert.That(resolved?.ContainingAssembly.Name).IsEqualTo(FrameworkAssemblyName); + _ = await Assert.That(versionTwo?.ContainingAssembly.Name).IsEqualTo(VersionTwoAssemblyName); + _ = await Assert.That(SymbolEqualityComparer.Default.Equals(resolved, versionTwo)).IsFalse(); + } } /// @@ -275,8 +287,11 @@ public async Task TryCreateRecognizer_ReferencingBothMajorVersions_ReturnsARecog var versionThree = XunitV3TestFrameworkProbe.Instance.TryCreateRecognizer(compilation); var versionTwo = XunitV2TestFrameworkProbe.Instance.TryCreateRecognizer(compilation); - _ = await Assert.That(versionThree?.FrameworkName).IsEqualTo(FrameworkName); - _ = await Assert.That(versionTwo?.FrameworkName).IsEqualTo(XunitV2TestFrameworkProbe.Name); + using (Assert.Multiple()) + { + _ = await Assert.That(versionThree?.FrameworkName).IsEqualTo(FrameworkName); + _ = await Assert.That(versionTwo?.FrameworkName).IsEqualTo(XunitV2TestFrameworkProbe.Name); + } } [Test] @@ -314,10 +329,13 @@ public async Task IsFrameworkAssembly_AssemblyName_IsClassifiedByTheVersionPrefi var frameworkLike = ReferencedAssembly(satellite, FrameworkLikeAssemblyName); var unrelated = ReferencedAssembly(foreign, ForeignAssemblyName); - _ = await Assert.That(XunitV3TestFrameworkProbe.IsFrameworkAssembly(versionThree)).IsTrue(); - _ = await Assert.That(XunitV3TestFrameworkProbe.IsFrameworkAssembly(versionTwo)).IsFalse(); - _ = await Assert.That(XunitV3TestFrameworkProbe.IsFrameworkAssembly(frameworkLike)).IsTrue(); - _ = await Assert.That(XunitV3TestFrameworkProbe.IsFrameworkAssembly(unrelated)).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(XunitV3TestFrameworkProbe.IsFrameworkAssembly(versionThree)).IsTrue(); + _ = await Assert.That(XunitV3TestFrameworkProbe.IsFrameworkAssembly(versionTwo)).IsFalse(); + _ = await Assert.That(XunitV3TestFrameworkProbe.IsFrameworkAssembly(frameworkLike)).IsTrue(); + _ = await Assert.That(XunitV3TestFrameworkProbe.IsFrameworkAssembly(unrelated)).IsFalse(); + } } [Test] diff --git a/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/XunitV3TestMethodRecognizerTests.cs b/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/XunitV3TestMethodRecognizerTests.cs index 3f240d3..d994e35 100644 --- a/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/XunitV3TestMethodRecognizerTests.cs +++ b/tests/NetEvolve.FrameShift.Tests.Unit/TestSurface/XunitV3TestMethodRecognizerTests.cs @@ -674,9 +674,12 @@ public async Task IsTestMethod_AttributeImplementingTheMarkerInterfaceOnly_IsCla var attributeType = XunitV3TestFrameworkProbe.GetTestAttributeType(compilation); var markerInterface = XunitV3TestFrameworkProbe.GetTestMarkerInterfaceType(compilation); - _ = await Assert.That(CreateRecognizer(compilation).IsTestMethod(method)).IsTrue(); - _ = await Assert.That(new XunitV3TestMethodRecognizer(null, markerInterface).IsTestMethod(method)).IsTrue(); - _ = await Assert.That(new XunitV3TestMethodRecognizer(attributeType, null).IsTestMethod(method)).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(CreateRecognizer(compilation).IsTestMethod(method)).IsTrue(); + _ = await Assert.That(new XunitV3TestMethodRecognizer(null, markerInterface).IsTestMethod(method)).IsTrue(); + _ = await Assert.That(new XunitV3TestMethodRecognizer(attributeType, null).IsTestMethod(method)).IsFalse(); + } } /// @@ -697,8 +700,11 @@ public async Task IsTestMethod_ShippedMarker_IsClassifiedByEitherRuleAlone(strin var attributeType = XunitV3TestFrameworkProbe.GetTestAttributeType(compilation); var markerInterface = XunitV3TestFrameworkProbe.GetTestMarkerInterfaceType(compilation); - _ = await Assert.That(new XunitV3TestMethodRecognizer(attributeType, null).IsTestMethod(method)).IsTrue(); - _ = await Assert.That(new XunitV3TestMethodRecognizer(null, markerInterface).IsTestMethod(method)).IsTrue(); + using (Assert.Multiple()) + { + _ = await Assert.That(new XunitV3TestMethodRecognizer(attributeType, null).IsTestMethod(method)).IsTrue(); + _ = await Assert.That(new XunitV3TestMethodRecognizer(null, markerInterface).IsTestMethod(method)).IsTrue(); + } } /// @@ -733,8 +739,11 @@ public async Task IsTestMethod_FactAttributeFromAnUnrelatedNamespace_IsNotClassi var recognizer = CreateRecognizer(compilation); var method = FindMethod(compilation, "Fixture.UnrelatedCases", "LooksLikeATest"); - _ = await Assert.That(recognizer.IsTestMethod(method)).IsFalse(); - _ = await Assert.That(new XunitV3TestMethodRecognizer(null, null).IsTestMethod(method)).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(recognizer.IsTestMethod(method)).IsFalse(); + _ = await Assert.That(new XunitV3TestMethodRecognizer(null, null).IsTestMethod(method)).IsFalse(); + } } /// @@ -768,11 +777,14 @@ public async Task IsTestMethod_RecognizerWithoutAnAttributeType_RecognizesNothin var markerInterface = FindMethod(compilation, CasesTypeName, "MarkerInterfaceTest"); var plain = FindMethod(compilation, CasesTypeName, "PlainMethod"); - _ = await Assert.That(recognizer.IsTestMethod(fact)).IsFalse(); - _ = await Assert.That(recognizer.IsTestMethod(theory)).IsFalse(); - _ = await Assert.That(recognizer.IsTestMethod(derived)).IsFalse(); - _ = await Assert.That(recognizer.IsTestMethod(markerInterface)).IsFalse(); - _ = await Assert.That(recognizer.IsTestMethod(plain)).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(recognizer.IsTestMethod(fact)).IsFalse(); + _ = await Assert.That(recognizer.IsTestMethod(theory)).IsFalse(); + _ = await Assert.That(recognizer.IsTestMethod(derived)).IsFalse(); + _ = await Assert.That(recognizer.IsTestMethod(markerInterface)).IsFalse(); + _ = await Assert.That(recognizer.IsTestMethod(plain)).IsFalse(); + } } /// @@ -790,10 +802,13 @@ public async Task IsTestMethod_BothMajorVersionsReferenced_RecognizesOnlyTheOwnV var versionThreeTest = FindMethod(compilation, MixedCasesTypeName, "VersionThreeTest"); var versionTwoTest = FindMethod(compilation, MixedCasesTypeName, "VersionTwoTest"); - _ = await Assert.That(versionThree.IsTestMethod(versionThreeTest)).IsTrue(); - _ = await Assert.That(versionThree.IsTestMethod(versionTwoTest)).IsFalse(); - _ = await Assert.That(versionTwo.IsTestMethod(versionTwoTest)).IsTrue(); - _ = await Assert.That(versionTwo.IsTestMethod(versionThreeTest)).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(versionThree.IsTestMethod(versionThreeTest)).IsTrue(); + _ = await Assert.That(versionThree.IsTestMethod(versionTwoTest)).IsFalse(); + _ = await Assert.That(versionTwo.IsTestMethod(versionTwoTest)).IsTrue(); + _ = await Assert.That(versionTwo.IsTestMethod(versionThreeTest)).IsFalse(); + } } /// @@ -899,10 +914,13 @@ public async Task GetTestCaseCount_ExactCountAndLowerBound_AreDistinguishedByIsE var exact = recognizer.GetTestCaseCount(FindMethod(compilation, CountCasesTypeName, "ThreeInlineData")); var bound = recognizer.GetTestCaseCount(FindMethod(compilation, CountCasesTypeName, "CulturedTheory")); - _ = await Assert.That(exact.Value).IsEqualTo(3); - _ = await Assert.That(exact.IsExact).IsTrue(); - _ = await Assert.That(bound.Value).IsEqualTo(2); - _ = await Assert.That(bound.IsExact).IsFalse(); + using (Assert.Multiple()) + { + _ = await Assert.That(exact.Value).IsEqualTo(3); + _ = await Assert.That(exact.IsExact).IsTrue(); + _ = await Assert.That(bound.Value).IsEqualTo(2); + _ = await Assert.That(bound.IsExact).IsFalse(); + } } /// @@ -924,8 +942,11 @@ public async Task GetTestCaseCount_DataSourceImplementingTheMarkerInterfaceOnly_ FindMethod(compilation, CountCasesTypeName, "TheoryWithoutData") ); - _ = await Assert.That(withSource.ToString()).IsEqualTo("1+"); - _ = await Assert.That(withoutSource.ToString()).IsEqualTo("0"); + using (Assert.Multiple()) + { + _ = await Assert.That(withSource.ToString()).IsEqualTo("1+"); + _ = await Assert.That(withoutSource.ToString()).IsEqualTo("0"); + } } ///