-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cbb87d4
commit 2a2be5e
Showing
8 changed files
with
66 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
src/CodeOfChaos.Testing.TUnit/Extensions/TUnitExtensionsCompilationWithAnalyzers.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// --------------------------------------------------------------------------------------------------------------------- | ||
// Imports | ||
// --------------------------------------------------------------------------------------------------------------------- | ||
using CodeOfChaos.Testing.TUnit.Conditions.Library; | ||
using Microsoft.CodeAnalysis.Diagnostics; | ||
using System.Runtime.CompilerServices; | ||
using TUnit.Assertions.AssertConditions.Interfaces; | ||
using TUnit.Assertions.AssertionBuilders; | ||
|
||
namespace CodeOfChaos.Testing.TUnit; | ||
|
||
// --------------------------------------------------------------------------------------------------------------------- | ||
// Code | ||
// --------------------------------------------------------------------------------------------------------------------- | ||
// ReSharper disable once InconsistentNaming | ||
public static class TUnitExtensionsCompilationWithAnalyzers { | ||
public static InvokableValueAssertionBuilder<CompilationWithAnalyzers> ContainsDiagnostic(this IValueSource<CompilationWithAnalyzers> valueSource, string expectedId, [CallerArgumentExpression(nameof(expectedId))] string doNotPopulateThisValue1 = "") { | ||
return valueSource.RegisterAssertion( | ||
assertCondition: new ContainsDiagnosticAssertCondition<CompilationWithAnalyzers>( | ||
async static compilation => await compilation.GetAllDiagnosticsAsync(), | ||
expectedId | ||
), | ||
argumentExpressions: [doNotPopulateThisValue1] | ||
); | ||
} | ||
|
||
public static InvokableValueAssertionBuilder<CompilationWithAnalyzers> DoesNotContainDiagnostic(this IValueSource<CompilationWithAnalyzers> valueSource, string expectedId, [CallerArgumentExpression(nameof(expectedId))] string doNotPopulateThisValue1 = "") { | ||
return valueSource.RegisterAssertion( | ||
assertCondition: new DoesNotContainDiagnosticAssertCondition<CompilationWithAnalyzers>( | ||
async static compilation => await compilation.GetAllDiagnosticsAsync(), | ||
expectedId | ||
), | ||
argumentExpressions: [doNotPopulateThisValue1] | ||
); | ||
} | ||
|
||
public static InvokableValueAssertionBuilder<CompilationWithAnalyzers> ContainsDiagnosticsExclusively(this IValueSource<CompilationWithAnalyzers> valueSource, string[] expectedIds, [CallerArgumentExpression(nameof(expectedIds))] string doNotPopulateThisValue1 = "") { | ||
return valueSource.RegisterAssertion( | ||
assertCondition: new ContainsDiagnosticsExclusivelyAssertCondition<CompilationWithAnalyzers>( | ||
async static compilation => await compilation.GetAllDiagnosticsAsync(), | ||
expectedIds | ||
), | ||
argumentExpressions: [doNotPopulateThisValue1] | ||
); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters