Skip to content

Commit 084e586

Browse files
authored
fix: update parameters to use IThatSubject in callbacks (#946)
This pull request primarily refactors the codebase to consistently use the `IThatSubject<T>` interface instead of `IThat<T>` for expectation actions across collection and exception assertion APIs. This change improves type safety and standardizes the way expectations are expressed throughout the library. Additionally, a build configuration change restricts the build scope to core components only. ### API Refactoring: Expectation Actions * Updated all collection assertion methods (e.g., `ComplyWith`, `HasItemThat`, `Contains`, `IsEqualTo`, etc.) to accept `Action<IThatSubject<T>>` or `Action<IThatSubject<T?>>` instead of `Action<IThat<T>>` or `Action<IThat<T?>>`. This affects both synchronous (`IEnumerable<T>`) and asynchronous (`IAsyncEnumerable<T>`) collection APIs. * Changed exception assertion methods (e.g., `WithInner`, `WithInnerException`, `Whose`, `Which`, etc.) to require expectation actions using `IThatSubject<T>` instead of `IThat<T>`. * Updated internal classes and constructors to use `IThatSubject<T>` for expectation actions, ensuring consistency throughout the implementation. ### Build Configuration * Changed the build scope in `Build.cs` from `BuildScope.Default` to `BuildScope.CoreOnly`, limiting the build process to core components.
1 parent 3f417e7 commit 084e586

43 files changed

Lines changed: 556 additions & 274 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Pipeline/Build.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ partial class Build : NukeBuild
2020
/// <para />
2121
/// Afterward, you can update the package reference in `Directory.Packages.props` and reset this flag.
2222
/// </summary>
23-
readonly BuildScope BuildScope = BuildScope.Default;
23+
readonly BuildScope BuildScope = BuildScope.CoreOnly;
2424

2525
[Parameter("Github Token")] readonly string GithubToken;
2626
[GitRepository] readonly GitRepository Repository;

Source/aweXpect.Core/Delegates/ThatDelegateThrows.Whose.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public partial class ThatDelegateThrows<TException>
1212
/// </summary>
1313
public AndOrResult<TException, ThatDelegateThrows<TException>> Whose<TMember>(
1414
Func<TException, TMember?> memberSelector,
15-
Action<IThat<TMember?>> expectations,
15+
Action<IThatSubject<TMember?>> expectations,
1616
[CallerArgumentExpression("memberSelector")]
1717
string doNotPopulateThisValue = "")
1818
=> new(ExpectationBuilder.ForMember(

Source/aweXpect.Core/Delegates/ThatDelegateThrows.WithInner.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public partial class ThatDelegateThrows<TException>
1515
/// </summary>
1616
public AndOrResult<TException, ThatDelegateThrows<TException>>
1717
WithInner<TInnerException>(
18-
Action<IThat<TInnerException?>> expectations)
18+
Action<IThatSubject<TInnerException?>> expectations)
1919
where TInnerException : Exception
2020
=> new(ExpectationBuilder
2121
.ForMember<Exception, Exception?>(e => e.InnerException,
@@ -45,7 +45,7 @@ public AndOrResult<TException, ThatDelegateThrows<TException>> WithInner<
4545
/// </summary>
4646
public AndOrResult<TException, ThatDelegateThrows<TException>> WithInner(
4747
Type innerExceptionType,
48-
Action<IThat<Exception?>> expectations)
48+
Action<IThatSubject<Exception?>> expectations)
4949
=> new(ExpectationBuilder
5050
.ForMember<Exception, Exception?>(e => e.InnerException,
5151
" whose ",

Source/aweXpect.Core/Delegates/ThatDelegateThrows.WithInnerException.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public partial class ThatDelegateThrows<TException>
1212
/// satisfies the <paramref name="expectations" />.
1313
/// </summary>
1414
public AndOrResult<TException, ThatDelegateThrows<TException>> WithInnerException(
15-
Action<IThat<Exception?>> expectations)
15+
Action<IThatSubject<Exception?>> expectations)
1616
=> new(ExpectationBuilder
1717
.ForMember(
1818
MemberAccessor<Exception?, Exception?>.FromFunc(

Source/aweXpect.Core/Options/CollectionMatchOptions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,15 +367,15 @@ public sealed class ExpectationItem<TItem>
367367
internal readonly ManualExpectationBuilder<TItem> ItemExpectationBuilder;
368368

369369
/// <inheritdoc cref="ExpectationItem{TItem}" />
370-
public ExpectationItem(Action<IThat<TItem>> expectation,
370+
public ExpectationItem(Action<IThatSubject<TItem?>> expectation,
371371
ExpectationGrammars grammars,
372372
IEvaluationContext context,
373373
CancellationToken cancellationToken)
374374
{
375375
_context = context;
376376
_cancellationToken = cancellationToken;
377377
ItemExpectationBuilder = new ManualExpectationBuilder<TItem>(null, grammars);
378-
expectation.Invoke(new ThatSubject<TItem>(ItemExpectationBuilder));
378+
expectation.Invoke(new ThatSubject<TItem?>(ItemExpectationBuilder));
379379
}
380380

381381
/// <summary>

Source/aweXpect.Core/Results/AndOrWhichResult.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public class AndOrWhichResult<TType, TThat, TSelf>(
3939
public AdditionalAndOrWhichResult
4040
Which<TMember>(
4141
Func<TType, TMember?> memberSelector,
42-
Action<IThat<TMember?>> expectations,
42+
Action<IThatSubject<TMember?>> expectations,
4343
[CallerArgumentExpression("memberSelector")]
4444
string doNotPopulateThisValue = "")
4545
=> new(
@@ -71,7 +71,7 @@ public class AdditionalAndOrWhichResult(
7171
public AdditionalAndOrWhichResult
7272
AndWhich<TMember>(
7373
Func<TType, TMember?> memberSelector,
74-
Action<IThat<TMember?>> expectations,
74+
Action<IThatSubject<TMember?>> expectations,
7575
[CallerArgumentExpression("memberSelector")]
7676
string doNotPopulateThisValue = "")
7777
{

Source/aweXpect.Core/Results/AndOrWhoseResult.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public class AndOrWhoseResult<TType, TThat, TSelf>(
3939
public AdditionalAndOrWhoseResult
4040
Whose<TMember>(
4141
Func<TType, TMember?> memberSelector,
42-
Action<IThat<TMember?>> expectations,
42+
Action<IThatSubject<TMember?>> expectations,
4343
[CallerArgumentExpression("memberSelector")]
4444
string doNotPopulateThisValue = "")
4545
=> new(
@@ -71,7 +71,7 @@ public class AdditionalAndOrWhoseResult(
7171
public AdditionalAndOrWhoseResult
7272
AndWhose<TMember>(
7373
Func<TType, TMember?> memberSelector,
74-
Action<IThat<TMember?>> expectations,
74+
Action<IThatSubject<TMember?>> expectations,
7575
[CallerArgumentExpression("memberSelector")]
7676
string doNotPopulateThisValue = "")
7777
{

Source/aweXpect/That/Collections/ThatAsyncEnumerable.Contains.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ public static CountResult<IAsyncEnumerable<TItem>, IThat<IAsyncEnumerable<TItem>
170170
public static CollectionContainResult<IAsyncEnumerable<TItem>, IThat<IAsyncEnumerable<TItem>?>, TItem>
171171
Contains<TItem>(
172172
this IThat<IAsyncEnumerable<TItem>?> source,
173-
IEnumerable<Action<IThat<TItem?>>> expected,
173+
IEnumerable<Action<IThatSubject<TItem?>>> expected,
174174
[CallerArgumentExpression("expected")]
175175
string doNotPopulateThisValue = "")
176176
{
@@ -336,7 +336,7 @@ public static CountResult<IAsyncEnumerable<TItem>, IThat<IAsyncEnumerable<TItem>
336336
public static CollectionContainResult<IAsyncEnumerable<TItem>, IThat<IAsyncEnumerable<TItem>?>, TItem>
337337
DoesNotContain<TItem>(
338338
this IThat<IAsyncEnumerable<TItem>?> source,
339-
IEnumerable<Action<IThat<TItem?>>> unexpected,
339+
IEnumerable<Action<IThatSubject<TItem?>>> unexpected,
340340
[CallerArgumentExpression("unexpected")]
341341
string doNotPopulateThisValue = "")
342342
{

Source/aweXpect/That/Collections/ThatAsyncEnumerable.Elements.ComplyWith.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public partial class Elements<TItem>
2020
/// …comply with the <paramref name="expectations" />.
2121
/// </summary>
2222
public ObjectEqualityResult<IAsyncEnumerable<TItem>, IThat<IAsyncEnumerable<TItem>?>, TItem>
23-
ComplyWith(Action<IThat<TItem>> expectations)
23+
ComplyWith(Action<IThatSubject<TItem>> expectations)
2424
{
2525
ObjectEqualityOptions<TItem> options = new();
2626
return new ObjectEqualityResult<IAsyncEnumerable<TItem>, IThat<IAsyncEnumerable<TItem>?>, TItem>(
@@ -45,7 +45,7 @@ private sealed class ComplyWithConstraint<TItem>
4545

4646
public ComplyWithConstraint(ExpectationBuilder expectationBuilder, string it, ExpectationGrammars grammars,
4747
EnumerableQuantifier quantifier,
48-
Action<IThat<TItem>> expectations) : base(grammars)
48+
Action<IThatSubject<TItem>> expectations) : base(grammars)
4949
{
5050
_it = it;
5151
_grammars = grammars;

Source/aweXpect/That/Collections/ThatAsyncEnumerable.HasItemThat.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public static partial class ThatAsyncEnumerable
2020
/// Verifies that the collection has an item that complies with the <paramref name="expectations" />…
2121
/// </summary>
2222
public static HasItemResult<IAsyncEnumerable<TItem>?> HasItemThat<TItem>(
23-
this IThat<IAsyncEnumerable<TItem>?> source, Action<IThat<TItem>> expectations)
23+
this IThat<IAsyncEnumerable<TItem>?> source, Action<IThatSubject<TItem>> expectations)
2424
{
2525
CollectionIndexOptions indexOptions = new();
2626
ExpectationBuilder expectationBuilder = source.Get().ExpectationBuilder;
@@ -44,7 +44,7 @@ private sealed class HasItemThatConstraint<TItem> : ConstraintResult.WithValue<I
4444
public HasItemThatConstraint(ExpectationBuilder expectationBuilder,
4545
string it,
4646
ExpectationGrammars grammars,
47-
Action<IThat<TItem>> expectations,
47+
Action<IThatSubject<TItem>> expectations,
4848
CollectionIndexOptions options) : base(grammars)
4949
{
5050
_expectationBuilder = expectationBuilder;

0 commit comments

Comments
 (0)