@@ -9,30 +9,28 @@ namespace CodeOfChaos.Testing.TUnit.Conditions.Library;
99// ---------------------------------------------------------------------------------------------------------------------
1010// Code
1111// ---------------------------------------------------------------------------------------------------------------------
12- public class ContainsDiagnosticsExclusivelyAssertCondition < T > ( Func < T , ValueTask < ImmutableArray < Diagnostic > > > getDiagnosticsAction , string [ ] expectedIds )
13- : ExpectedValueAssertCondition < T , string [ ] > ( expectedIds ) {
12+ public class ContainsDiagnosticsExclusivelyAssertCondition < T > ( Func < T , ValueTask < ImmutableArray < Diagnostic > > > getDiagnosticsAction , string [ ] expectedIds ) : BaseAssertCondition < T > {
13+ private readonly HashSet < string > ExpectedValuesHashSet = expectedIds . ToHashSet ( ) ;
1414
1515 // -----------------------------------------------------------------------------------------------------------------
1616 // Methods
1717 // -----------------------------------------------------------------------------------------------------------------
18- protected override string GetExpectation ( ) => $ "to have a compilation output with the following Ids \" { ExpectedValue } \" ";
19- protected override async Task < AssertionResult > GetResult ( T ? actualValue , string [ ] ? expectedValues ) {
18+ protected override string GetExpectation ( ) => $ "to have a compilation output with the following Ids \" { expectedIds } \" ";
19+ protected override async Task < AssertionResult > GetResult ( T ? actualValue , Exception ? exception , AssertionMetadata assertionMetadata ) {
2020 if ( actualValue is null ) return AssertionResult . Fail ( $ "{ nameof ( T ) } is null") ;
21- if ( expectedValues is null ) return AssertionResult . Fail ( "Expected value is null" ) ;
2221
2322 ImmutableArray < Diagnostic > diagnostics = await getDiagnosticsAction ( actualValue ) ;
24- if ( ! diagnostics . Any ( ) && expectedValues . Length == 0 ) return AssertionResult . Passed ;
23+ if ( ! diagnostics . Any ( ) && expectedIds . Length == 0 ) return AssertionResult . Passed ;
2524 if ( ! diagnostics . Any ( ) ) return FailWithMessage ( "No diagnostics" ) ;
26- if ( expectedValues . Length != diagnostics . Length ) return FailWithMessage ( "Wrong number of diagnostics" ) ;
25+ if ( expectedIds . Length != diagnostics . Length ) return FailWithMessage ( "Wrong number of diagnostics" ) ;
2726
2827 HashSet < string > diagnosticsHashSet = diagnostics . Select ( d => d . Id ) . ToHashSet ( ) ;
29- HashSet < string > expectedValuesHashSet = expectedValues . ToHashSet ( ) ;
3028
31- if ( diagnosticsHashSet . SetEquals ( expectedValuesHashSet ) ) return AssertionResult . Passed ;
29+ if ( diagnosticsHashSet . SetEquals ( ExpectedValuesHashSet ) ) return AssertionResult . Passed ;
3230
3331 // Find which diagnostics are missing or unexpected
34- string [ ] missingDiagnostics = expectedValuesHashSet . Except ( diagnosticsHashSet ) . ToArray ( ) ;
35- string [ ] unexpectedDiagnostics = diagnosticsHashSet . Except ( expectedValuesHashSet ) . ToArray ( ) ;
32+ string [ ] missingDiagnostics = ExpectedValuesHashSet . Except ( diagnosticsHashSet ) . ToArray ( ) ;
33+ string [ ] unexpectedDiagnostics = diagnosticsHashSet . Except ( ExpectedValuesHashSet ) . ToArray ( ) ;
3634
3735 string errorMessage = "Diagnostics do not match:" ;
3836
0 commit comments