-
-
Notifications
You must be signed in to change notification settings - Fork 0
feat: support async Because reason
#880
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| using System; | ||
| using System.Threading.Tasks; | ||
| using aweXpect.Core.Constraints; | ||
|
|
||
| namespace aweXpect.Core.Helpers; | ||
|
|
||
| internal struct AsyncBecauseReason(Task<string> reason) : IBecauseReason | ||
| { | ||
| private string? _message; | ||
|
|
||
| private static string CreateMessage(string reason) | ||
| { | ||
| const string prefix = "because"; | ||
| string message = reason.Trim(); | ||
|
|
||
| return !message.StartsWith(prefix, StringComparison.OrdinalIgnoreCase) | ||
| ? $", {prefix} {message}" | ||
| : $", {message}"; | ||
| } | ||
|
|
||
| #if NET8_0_OR_GREATER | ||
| public async ValueTask<ConstraintResult> | ||
| #else | ||
| public async Task<ConstraintResult> | ||
| #endif | ||
| ApplyTo(ConstraintResult result) | ||
| { | ||
| if (_message is null) | ||
| { | ||
| _message = CreateMessage(await reason.ConfigureAwait(false)); | ||
| } | ||
|
|
||
| string message = _message; | ||
| return result.AppendExpectationText(e => e.Append(message)); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| using System.Threading.Tasks; | ||
| using aweXpect.Core.Constraints; | ||
|
|
||
| namespace aweXpect.Core.Helpers; | ||
|
|
||
| internal interface IBecauseReason | ||
| { | ||
|
|
||
| #if NET8_0_OR_GREATER | ||
| public ValueTask<ConstraintResult> | ||
| #else | ||
| public Task<ConstraintResult> | ||
| #endif | ||
| ApplyTo(ConstraintResult result); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,7 +10,6 @@ public sealed class ApiAcceptance | |
| /// Execute this test to update the expected public API to the current API surface. | ||
| /// </summary> | ||
| [TestCase] | ||
| [Explicit] | ||
| public async Task AcceptApiChanges() | ||
|
||
| { | ||
| string[] assemblyNames = | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove unnecessary blank line inside the interface definition.