diff --git a/TUnit.Assertions.Tests/Old/DictionaryAssertionTests.cs b/TUnit.Assertions.Tests/Old/DictionaryAssertionTests.cs index 5a9ac0c981..499cf6447f 100644 --- a/TUnit.Assertions.Tests/Old/DictionaryAssertionTests.cs +++ b/TUnit.Assertions.Tests/Old/DictionaryAssertionTests.cs @@ -66,6 +66,18 @@ await TUnitAssert.That(ImmutableDictionary.Empty.Add("Hello", 1)) ); } + // Picks up collection methods via inheritance + [Test] + public async Task HasSingleItem() + { + var dictionary = new Dictionary + { + ["Blah"] = [1] + }; + + await TUnitAssert.That(dictionary).HasSingleItem(); + } + public class ReadDictionary : IReadOnlyDictionary { public IEnumerator> GetEnumerator() diff --git a/TUnit.Assertions/Conditions/CollectionAssertions.cs b/TUnit.Assertions/Conditions/CollectionAssertions.cs index 9fa3151d43..e9175e8719 100644 --- a/TUnit.Assertions/Conditions/CollectionAssertions.cs +++ b/TUnit.Assertions/Conditions/CollectionAssertions.cs @@ -11,15 +11,16 @@ namespace TUnit.Assertions.Conditions; /// Asserts that a collection/enumerable is empty. /// [AssertionExtension("IsEmpty")] -public class CollectionIsEmptyAssertion : Sources.CollectionAssertionBase +public class CollectionIsEmptyAssertion : Sources.CollectionAssertionBase + where TCollection : IEnumerable { public CollectionIsEmptyAssertion( - AssertionContext> context) + AssertionContext context) : base(context) { } - protected override Task CheckAsync(EvaluationMetadata> metadata) + protected override Task CheckAsync(EvaluationMetadata metadata) { var value = metadata.Value; var exception = metadata.Exception; @@ -82,15 +83,16 @@ protected override Task CheckAsync(EvaluationMetadata [AssertionExtension("IsNotEmpty")] -public class CollectionIsNotEmptyAssertion : Sources.CollectionAssertionBase +public class CollectionIsNotEmptyAssertion : Sources.CollectionAssertionBase + where TCollection : IEnumerable { public CollectionIsNotEmptyAssertion( - AssertionContext> context) + AssertionContext context) : base(context) { } - protected override Task CheckAsync(EvaluationMetadata> metadata) + protected override Task CheckAsync(EvaluationMetadata metadata) { var value = metadata.Value; var exception = metadata.Exception; @@ -129,13 +131,14 @@ protected override Task CheckAsync(EvaluationMetadata [AssertionExtension("Contains")] -public class CollectionContainsAssertion : Sources.CollectionAssertionBase +public class CollectionContainsAssertion : Sources.CollectionAssertionBase + where TCollection : IEnumerable { private readonly TItem _expected; private readonly IEqualityComparer? _comparer; public CollectionContainsAssertion( - AssertionContext> context, + AssertionContext context, TItem expected, IEqualityComparer? comparer = null) : base(context) @@ -144,7 +147,7 @@ public CollectionContainsAssertion( _comparer = comparer; } - protected override Task CheckAsync(EvaluationMetadata> metadata) + protected override Task CheckAsync(EvaluationMetadata metadata) { var value = metadata.Value; var exception = metadata.Exception; @@ -180,13 +183,14 @@ protected override Task CheckAsync(EvaluationMetadata [AssertionExtension("DoesNotContain")] -public class CollectionDoesNotContainAssertion : Sources.CollectionAssertionBase +public class CollectionDoesNotContainAssertion : Sources.CollectionAssertionBase + where TCollection : IEnumerable { private readonly TItem _expected; private readonly IEqualityComparer? _comparer; public CollectionDoesNotContainAssertion( - AssertionContext> context, + AssertionContext context, TItem expected, IEqualityComparer? comparer = null) : base(context) @@ -195,7 +199,7 @@ public CollectionDoesNotContainAssertion( _comparer = comparer; } - protected override Task CheckAsync(EvaluationMetadata> metadata) + protected override Task CheckAsync(EvaluationMetadata metadata) { var value = metadata.Value; var exception = metadata.Exception; @@ -231,13 +235,14 @@ protected override Task CheckAsync(EvaluationMetadata [AssertionExtension("DoesNotContain")] -public class CollectionDoesNotContainPredicateAssertion : Sources.CollectionAssertionBase +public class CollectionDoesNotContainPredicateAssertion : Sources.CollectionAssertionBase + where TCollection : IEnumerable { private readonly Func _predicate; private readonly string _predicateDescription; public CollectionDoesNotContainPredicateAssertion( - AssertionContext> context, + AssertionContext context, Func predicate, string predicateDescription) : base(context) @@ -246,7 +251,7 @@ public CollectionDoesNotContainPredicateAssertion( _predicateDescription = predicateDescription; } - protected override Task CheckAsync(EvaluationMetadata> metadata) + protected override Task CheckAsync(EvaluationMetadata metadata) { var value = metadata.Value; var exception = metadata.Exception; @@ -280,19 +285,20 @@ protected override Task CheckAsync(EvaluationMetadata [AssertionExtension("HasCount")] -public class CollectionCountAssertion : Sources.CollectionAssertionBase +public class CollectionCountAssertion : Sources.CollectionAssertionBase + where TCollection : IEnumerable { private readonly int _expectedCount; public CollectionCountAssertion( - AssertionContext> context, + AssertionContext context, int expectedCount) : base(context) { _expectedCount = expectedCount; } - protected override Task CheckAsync(EvaluationMetadata> metadata) + protected override Task CheckAsync(EvaluationMetadata metadata) { var value = metadata.Value; var exception = metadata.Exception; @@ -345,11 +351,12 @@ protected override Task CheckAsync(EvaluationMetadata /// Helper for All().Satisfy() pattern - allows custom assertions on all collection items. /// -public class CollectionAllSatisfyHelper +public class CollectionAllSatisfyHelper + where TCollection : IEnumerable { - private readonly AssertionContext> _context; + private readonly AssertionContext _context; - public CollectionAllSatisfyHelper(AssertionContext> context) + public CollectionAllSatisfyHelper(AssertionContext context) { _context = context; } @@ -358,38 +365,39 @@ public CollectionAllSatisfyHelper(AssertionContext> context) /// Asserts that all items satisfy the given assertion. /// Example: .All().Satisfy(item => item.IsNotNull()) /// - public CollectionAllSatisfyAssertion Satisfy( + public CollectionAllSatisfyAssertion Satisfy( Func, Assertion?> assertion, [CallerArgumentExpression(nameof(assertion))] string? expression = null) { _context.ExpressionBuilder.Append($".Satisfy({expression})"); - return new CollectionAllSatisfyAssertion(_context, assertion, expression ?? "assertion"); + return new CollectionAllSatisfyAssertion(_context, assertion, expression ?? "assertion"); } /// /// Asserts that all items, when mapped, satisfy the given assertion. /// Example: .All().Satisfy(model => model.Value, assert => assert.IsNotNull()) /// - public CollectionAllSatisfyMappedAssertion Satisfy( + public CollectionAllSatisfyMappedAssertion Satisfy( Func mapper, Func, Assertion?> assertion, [CallerArgumentExpression(nameof(mapper))] string? mapperExpression = null, [CallerArgumentExpression(nameof(assertion))] string? assertionExpression = null) { _context.ExpressionBuilder.Append($".Satisfy({mapperExpression}, {assertionExpression})"); - return new CollectionAllSatisfyMappedAssertion( + return new CollectionAllSatisfyMappedAssertion( _context, mapper, assertion, mapperExpression ?? "mapper", assertionExpression ?? "assertion"); } } [AssertionExtension("All")] -public class CollectionAllAssertion : Sources.CollectionAssertionBase +public class CollectionAllAssertion : Sources.CollectionAssertionBase + where TCollection : IEnumerable { private readonly Func _predicate; private readonly string _predicateDescription; public CollectionAllAssertion( - AssertionContext> context, + AssertionContext context, Func predicate, string predicateDescription) : base(context) @@ -398,7 +406,7 @@ public CollectionAllAssertion( _predicateDescription = predicateDescription; } - protected override Task CheckAsync(EvaluationMetadata> metadata) + protected override Task CheckAsync(EvaluationMetadata metadata) { var value = metadata.Value; var exception = metadata.Exception; @@ -435,13 +443,14 @@ protected override Task CheckAsync(EvaluationMetadata [AssertionExtension("Any")] -public class CollectionAnyAssertion : Sources.CollectionAssertionBase +public class CollectionAnyAssertion : Sources.CollectionAssertionBase + where TCollection : IEnumerable { private readonly Func _predicate; private readonly string _predicateDescription; public CollectionAnyAssertion( - AssertionContext> context, + AssertionContext context, Func predicate, string predicateDescription) : base(context) @@ -450,7 +459,7 @@ public CollectionAnyAssertion( _predicateDescription = predicateDescription; } - protected override Task CheckAsync(EvaluationMetadata> metadata) + protected override Task CheckAsync(EvaluationMetadata metadata) { var value = metadata.Value; var exception = metadata.Exception; @@ -485,17 +494,18 @@ protected override Task CheckAsync(EvaluationMetadata [AssertionExtension("HasSingleItem")] -public class HasSingleItemAssertion : Sources.CollectionAssertionBase +public class HasSingleItemAssertion : Sources.CollectionAssertionBase + where TCollection : IEnumerable { private TItem? _singleItem; public HasSingleItemAssertion( - AssertionContext> context) + AssertionContext context) : base(context) { } - protected override Task CheckAsync(EvaluationMetadata> metadata) + protected override Task CheckAsync(EvaluationMetadata metadata) { var value = metadata.Value; var exception = metadata.Exception; @@ -558,20 +568,21 @@ private async Task ExecuteAndReturnItemAsync() /// Inherits from CollectionAssertionBase to enable chaining of collection methods. /// [AssertionExtension("Contains")] -public class CollectionContainsPredicateAssertion : Sources.CollectionAssertionBase +public class CollectionContainsPredicateAssertion : Sources.CollectionAssertionBase + where TCollection : IEnumerable { private readonly Func _predicate; private TItem? _foundItem; public CollectionContainsPredicateAssertion( - AssertionContext> context, + AssertionContext context, Func predicate) : base(context) { _predicate = predicate ?? throw new ArgumentNullException(nameof(predicate)); } - protected override Task CheckAsync(EvaluationMetadata> metadata) + protected override Task CheckAsync(EvaluationMetadata metadata) { var value = metadata.Value; var exception = metadata.Exception; @@ -621,13 +632,14 @@ private async Task ExecuteAndReturnItemAsync() /// Asserts that all items in the collection satisfy a custom assertion. /// Inherits from CollectionAssertionBase to enable chaining of collection methods. /// -public class CollectionAllSatisfyAssertion : Sources.CollectionAssertionBase +public class CollectionAllSatisfyAssertion : Sources.CollectionAssertionBase + where TCollection : IEnumerable { private readonly Func, Assertion?> _assertion; private readonly string _assertionDescription; public CollectionAllSatisfyAssertion( - AssertionContext> context, + AssertionContext context, Func, Assertion?> assertion, string assertionDescription) : base(context) @@ -636,7 +648,7 @@ public CollectionAllSatisfyAssertion( _assertionDescription = assertionDescription; } - protected override async Task CheckAsync(EvaluationMetadata> metadata) + protected override async Task CheckAsync(EvaluationMetadata metadata) { var value = metadata.Value; var exception = metadata.Exception; @@ -680,7 +692,8 @@ protected override async Task CheckAsync(EvaluationMetadata -public class CollectionAllSatisfyMappedAssertion : Sources.CollectionAssertionBase +public class CollectionAllSatisfyMappedAssertion : Sources.CollectionAssertionBase + where TCollection : IEnumerable { private readonly Func _mapper; private readonly Func, Assertion?> _assertion; @@ -688,7 +701,7 @@ public class CollectionAllSatisfyMappedAssertion : Sources.Colle private readonly string _assertionDescription; public CollectionAllSatisfyMappedAssertion( - AssertionContext> context, + AssertionContext context, Func mapper, Func, Assertion?> assertion, string mapperDescription, @@ -701,7 +714,7 @@ public CollectionAllSatisfyMappedAssertion( _assertionDescription = assertionDescription; } - protected override async Task CheckAsync(EvaluationMetadata> metadata) + protected override async Task CheckAsync(EvaluationMetadata metadata) { var value = metadata.Value; var exception = metadata.Exception; @@ -748,15 +761,16 @@ protected override async Task CheckAsync(EvaluationMetadata [AssertionExtension("IsInOrder")] -public class CollectionIsInOrderAssertion : Sources.CollectionAssertionBase +public class CollectionIsInOrderAssertion : Sources.CollectionAssertionBase + where TCollection : IEnumerable { public CollectionIsInOrderAssertion( - AssertionContext> context) + AssertionContext context) : base(context) { } - protected override Task CheckAsync(EvaluationMetadata> metadata) + protected override Task CheckAsync(EvaluationMetadata metadata) { var value = metadata.Value; var exception = metadata.Exception; @@ -803,15 +817,16 @@ protected override Task CheckAsync(EvaluationMetadata [AssertionExtension("IsInDescendingOrder")] -public class CollectionIsInDescendingOrderAssertion : Sources.CollectionAssertionBase +public class CollectionIsInDescendingOrderAssertion : Sources.CollectionAssertionBase + where TCollection : IEnumerable { public CollectionIsInDescendingOrderAssertion( - AssertionContext> context) + AssertionContext context) : base(context) { } - protected override Task CheckAsync(EvaluationMetadata> metadata) + protected override Task CheckAsync(EvaluationMetadata metadata) { var value = metadata.Value; var exception = metadata.Exception; @@ -857,13 +872,14 @@ protected override Task CheckAsync(EvaluationMetadata -public class CollectionIsOrderedByAssertion : Sources.CollectionAssertionBase +public class CollectionIsOrderedByAssertion : Sources.CollectionAssertionBase + where TCollection : IEnumerable { private readonly Func _keySelector; private readonly IComparer? _comparer; public CollectionIsOrderedByAssertion( - AssertionContext> context, + AssertionContext context, Func keySelector, IComparer? comparer = null) : base(context) @@ -872,7 +888,7 @@ public CollectionIsOrderedByAssertion( _comparer = comparer; } - protected override Task CheckAsync(EvaluationMetadata> metadata) + protected override Task CheckAsync(EvaluationMetadata metadata) { var value = metadata.Value; var exception = metadata.Exception; @@ -918,13 +934,14 @@ protected override Task CheckAsync(EvaluationMetadata -public class CollectionIsOrderedByDescendingAssertion : Sources.CollectionAssertionBase +public class CollectionIsOrderedByDescendingAssertion : Sources.CollectionAssertionBase + where TCollection : IEnumerable { private readonly Func _keySelector; private readonly IComparer? _comparer; public CollectionIsOrderedByDescendingAssertion( - AssertionContext> context, + AssertionContext context, Func keySelector, IComparer? comparer = null) : base(context) @@ -933,7 +950,7 @@ public CollectionIsOrderedByDescendingAssertion( _comparer = comparer; } - protected override Task CheckAsync(EvaluationMetadata> metadata) + protected override Task CheckAsync(EvaluationMetadata metadata) { var value = metadata.Value; var exception = metadata.Exception; diff --git a/TUnit.Assertions/Conditions/CollectionComparerBasedAssertion.cs b/TUnit.Assertions/Conditions/CollectionComparerBasedAssertion.cs index 34d98f1167..5a2f78fec1 100644 --- a/TUnit.Assertions/Conditions/CollectionComparerBasedAssertion.cs +++ b/TUnit.Assertions/Conditions/CollectionComparerBasedAssertion.cs @@ -8,12 +8,14 @@ namespace TUnit.Assertions.Conditions; /// Base class for collection assertions that support custom equality comparers. /// Inherits from CollectionAssertionBase to ensure And/Or continuations preserve collection type awareness. /// +/// The concrete collection type /// The type of items being compared -public abstract class CollectionComparerBasedAssertion : CollectionAssertionBase +public abstract class CollectionComparerBasedAssertion : CollectionAssertionBase + where TCollection : IEnumerable { private IEqualityComparer? _comparer; - protected CollectionComparerBasedAssertion(AssertionContext> context) + protected CollectionComparerBasedAssertion(AssertionContext context) : base(context) { } diff --git a/TUnit.Assertions/Conditions/CollectionCountValueAssertion.cs b/TUnit.Assertions/Conditions/CollectionCountValueAssertion.cs index 3fc3498cb1..2b1c5a9670 100644 --- a/TUnit.Assertions/Conditions/CollectionCountValueAssertion.cs +++ b/TUnit.Assertions/Conditions/CollectionCountValueAssertion.cs @@ -7,17 +7,18 @@ namespace TUnit.Assertions.Conditions; /// Assertion that evaluates the count of a collection and provides numeric assertions on that count. /// Implements IAssertionSource<int> to enable all numeric assertion methods. /// -public class CollectionCountValueAssertion : Sources.ValueAssertion +public class CollectionCountValueAssertion : Sources.ValueAssertion + where TCollection : IEnumerable { public CollectionCountValueAssertion( - AssertionContext> collectionContext, + AssertionContext collectionContext, Func? predicate) : base(CreateIntContext(collectionContext, predicate)) { } private static AssertionContext CreateIntContext( - AssertionContext> collectionContext, + AssertionContext collectionContext, Func? predicate) { return collectionContext.Map(collection => diff --git a/TUnit.Assertions/Conditions/IsEquivalentToAssertion.cs b/TUnit.Assertions/Conditions/IsEquivalentToAssertion.cs index 1ea55434c3..ec82f1e13f 100644 --- a/TUnit.Assertions/Conditions/IsEquivalentToAssertion.cs +++ b/TUnit.Assertions/Conditions/IsEquivalentToAssertion.cs @@ -15,13 +15,14 @@ namespace TUnit.Assertions.Conditions; /// [AssertionExtension("IsEquivalentTo")] [RequiresDynamicCode("Collection equivalency uses structural comparison for complex objects, which requires reflection and is not compatible with AOT")] -public class IsEquivalentToAssertion : CollectionComparerBasedAssertion +public class IsEquivalentToAssertion : CollectionComparerBasedAssertion + where TCollection : IEnumerable { private readonly IEnumerable _expected; private readonly CollectionOrdering _ordering; public IsEquivalentToAssertion( - AssertionContext> context, + AssertionContext context, IEnumerable expected, CollectionOrdering ordering = CollectionOrdering.Any) : base(context) @@ -31,7 +32,7 @@ public IsEquivalentToAssertion( } public IsEquivalentToAssertion( - AssertionContext> context, + AssertionContext context, IEnumerable expected, IEqualityComparer comparer, CollectionOrdering ordering = CollectionOrdering.Any) @@ -42,14 +43,14 @@ public IsEquivalentToAssertion( SetComparer(comparer); } - public IsEquivalentToAssertion Using(IEqualityComparer comparer) + public IsEquivalentToAssertion Using(IEqualityComparer comparer) { SetComparer(comparer); return this; } [UnconditionalSuppressMessage("AOT", "IL3050", Justification = "Collection equivalency uses structural comparison which requires reflection")] - protected override Task CheckAsync(EvaluationMetadata> metadata) + protected override Task CheckAsync(EvaluationMetadata metadata) { var value = metadata.Value; var exception = metadata.Exception; diff --git a/TUnit.Assertions/Conditions/NotEquivalentToAssertion.cs b/TUnit.Assertions/Conditions/NotEquivalentToAssertion.cs index e10e1ca2af..66444cef0d 100644 --- a/TUnit.Assertions/Conditions/NotEquivalentToAssertion.cs +++ b/TUnit.Assertions/Conditions/NotEquivalentToAssertion.cs @@ -14,13 +14,14 @@ namespace TUnit.Assertions.Conditions; /// [AssertionExtension("IsNotEquivalentTo")] [RequiresDynamicCode("Collection equivalency uses structural comparison for complex objects, which requires reflection and is not compatible with AOT")] -public class NotEquivalentToAssertion : CollectionComparerBasedAssertion +public class NotEquivalentToAssertion : CollectionComparerBasedAssertion + where TCollection : IEnumerable { private readonly IEnumerable _notExpected; private readonly CollectionOrdering _ordering; public NotEquivalentToAssertion( - AssertionContext> context, + AssertionContext context, IEnumerable notExpected, CollectionOrdering ordering = CollectionOrdering.Any) : base(context) @@ -29,14 +30,14 @@ public NotEquivalentToAssertion( _ordering = ordering; } - public NotEquivalentToAssertion Using(IEqualityComparer comparer) + public NotEquivalentToAssertion Using(IEqualityComparer comparer) { SetComparer(comparer); return this; } [UnconditionalSuppressMessage("AOT", "IL3050", Justification = "Collection equivalency uses structural comparison which requires reflection")] - protected override Task CheckAsync(EvaluationMetadata> metadata) + protected override Task CheckAsync(EvaluationMetadata metadata) { var value = metadata.Value; var exception = metadata.Exception; diff --git a/TUnit.Assertions/Conditions/Wrappers/CountWrapper.cs b/TUnit.Assertions/Conditions/Wrappers/CountWrapper.cs index b00328c823..82001dcb70 100644 --- a/TUnit.Assertions/Conditions/Wrappers/CountWrapper.cs +++ b/TUnit.Assertions/Conditions/Wrappers/CountWrapper.cs @@ -10,26 +10,27 @@ namespace TUnit.Assertions.Conditions.Wrappers; /// Wrapper for collection count assertions that provides .EqualTo() method. /// Example: await Assert.That(list).Count().EqualTo(5); /// -public class CountWrapper : IAssertionSource> +public class CountWrapper : IAssertionSource + where TCollection : IEnumerable { - private readonly AssertionContext> _context; + private readonly AssertionContext _context; - public CountWrapper(AssertionContext> context) + public CountWrapper(AssertionContext context) { _context = context; } - AssertionContext> IAssertionSource>.Context => _context; + AssertionContext IAssertionSource.Context => _context; /// /// Asserts that the collection count is equal to the expected count. /// - public CollectionCountAssertion EqualTo( + public CollectionCountAssertion EqualTo( int expectedCount, [CallerArgumentExpression(nameof(expectedCount))] string? expression = null) { _context.ExpressionBuilder.Append($".EqualTo({expression})"); - return new CollectionCountAssertion(_context, expectedCount); + return new CollectionCountAssertion(_context, expectedCount); } /// @@ -191,10 +192,10 @@ public BetweenAssertion Between( /// /// Asserts that the collection count is zero (empty collection). /// - public CollectionCountAssertion Zero() + public CollectionCountAssertion Zero() { _context.ExpressionBuilder.Append(".Zero()"); - return new CollectionCountAssertion(_context, 0); + return new CollectionCountAssertion(_context, 0); } /// diff --git a/TUnit.Assertions/Core/CollectionContinuations.cs b/TUnit.Assertions/Core/CollectionContinuations.cs index c8022eb8fc..2dca92392c 100644 --- a/TUnit.Assertions/Core/CollectionContinuations.cs +++ b/TUnit.Assertions/Core/CollectionContinuations.cs @@ -4,24 +4,26 @@ namespace TUnit.Assertions.Core; /// -/// And continuation for collection assertions that preserves item type. +/// And continuation for collection assertions that preserves collection type and item type. /// Inherits from CollectionAssertionBase to automatically expose all collection methods. /// -public class CollectionAndContinuation : CollectionAssertionBase +public class CollectionAndContinuation : CollectionAssertionBase + where TCollection : IEnumerable { - internal CollectionAndContinuation(AssertionContext> context, Assertion> previousAssertion) + internal CollectionAndContinuation(AssertionContext context, Assertion previousAssertion) : base(context, previousAssertion, ".And", CombinerType.And) { } } /// -/// Or continuation for collection assertions that preserves item type. +/// Or continuation for collection assertions that preserves collection type and item type. /// Inherits from CollectionAssertionBase to automatically expose all collection methods. /// -public class CollectionOrContinuation : CollectionAssertionBase +public class CollectionOrContinuation : CollectionAssertionBase + where TCollection : IEnumerable { - internal CollectionOrContinuation(AssertionContext> context, Assertion> previousAssertion) + internal CollectionOrContinuation(AssertionContext context, Assertion previousAssertion) : base(context, previousAssertion, ".Or", CombinerType.Or) { } diff --git a/TUnit.Assertions/Sources/CollectionAssertion.cs b/TUnit.Assertions/Sources/CollectionAssertion.cs index 2b00182b74..25b1861d19 100644 --- a/TUnit.Assertions/Sources/CollectionAssertion.cs +++ b/TUnit.Assertions/Sources/CollectionAssertion.cs @@ -10,7 +10,7 @@ namespace TUnit.Assertions.Sources; /// Inherits from CollectionAssertionBase to get all collection-specific instance methods (Contains, IsInOrder, etc.) /// that persist through And/Or continuations. /// -public class CollectionAssertion : CollectionAssertionBase +public class CollectionAssertion : CollectionAssertionBase, TItem> { public CollectionAssertion(IEnumerable value, string? expression) : base(new AssertionContext>(value, CreateExpressionBuilder(expression))) diff --git a/TUnit.Assertions/Sources/CollectionAssertionBase.cs b/TUnit.Assertions/Sources/CollectionAssertionBase.cs index 4c6cecc4ca..a67a5878ee 100644 --- a/TUnit.Assertions/Sources/CollectionAssertionBase.cs +++ b/TUnit.Assertions/Sources/CollectionAssertionBase.cs @@ -8,18 +8,20 @@ namespace TUnit.Assertions.Sources; /// /// Base class for all collection assertions that preserves type through And/Or chains. -/// Implements IAssertionSource<IEnumerable<TItem>> to enable all collection and value extension methods. +/// Implements IAssertionSource<TCollection> to enable all collection and value extension methods. /// All collection-specific operations (Contains, IsInOrder, etc.) are provided as instance methods. /// +/// The concrete collection type (e.g., IEnumerable<T>, IReadOnlyDictionary<K,V>) /// The type of items in the collection -public abstract class CollectionAssertionBase : Assertion>, IAssertionSource> +public abstract class CollectionAssertionBase : Assertion, IAssertionSource + where TCollection : IEnumerable { /// /// Explicit implementation of IAssertionSource.Context to expose the context publicly. /// - AssertionContext> IAssertionSource>.Context => Context; + AssertionContext IAssertionSource.Context => Context; - protected CollectionAssertionBase(AssertionContext> context) + protected CollectionAssertionBase(AssertionContext context) : base(context) { } @@ -30,8 +32,8 @@ protected CollectionAssertionBase(AssertionContext> context) /// Private protected means accessible only to derived classes within the same assembly. /// private protected CollectionAssertionBase( - AssertionContext> context, - Assertion> previousAssertion, + AssertionContext context, + Assertion previousAssertion, string combinerExpression, CombinerType combinerType) : base(context) @@ -47,10 +49,10 @@ private protected CollectionAssertionBase( /// This instance method allows single type parameter usage without needing to specify the source type. /// Example: await Assert.That(readOnlyList).IsTypeOf<List<double>>(); /// - public TypeOfAssertion, TExpected> IsTypeOf() + public TypeOfAssertion IsTypeOf() { Context.ExpressionBuilder.Append($".IsTypeOf<{typeof(TExpected).Name}>()"); - return new TypeOfAssertion, TExpected>(Context); + return new TypeOfAssertion(Context); } /// @@ -58,12 +60,12 @@ public TypeOfAssertion, TExpected> IsTypeOf() /// This instance method enables calling Contains with proper type inference. /// Example: await Assert.That(list).Contains("value"); /// - public CollectionContainsAssertion Contains( + public CollectionContainsAssertion Contains( TItem expected, [CallerArgumentExpression(nameof(expected))] string? expression = null) { Context.ExpressionBuilder.Append($".Contains({expression})"); - return new CollectionContainsAssertion(Context, expected); + return new CollectionContainsAssertion(Context, expected); } /// @@ -71,12 +73,12 @@ public CollectionContainsAssertion Contains( /// This instance method enables calling Contains with proper type inference. /// Example: await Assert.That(list).Contains(x => x > 5); /// - public CollectionContainsPredicateAssertion Contains( + public CollectionContainsPredicateAssertion Contains( Func predicate, [CallerArgumentExpression(nameof(predicate))] string? expression = null) { Context.ExpressionBuilder.Append($".Contains({expression})"); - return new CollectionContainsPredicateAssertion(Context, predicate); + return new CollectionContainsPredicateAssertion(Context, predicate); } /// @@ -84,12 +86,12 @@ public CollectionContainsPredicateAssertion Contains( /// This instance method enables calling HasCount with proper type inference. /// Example: await Assert.That(list).HasCount(5); /// - public CollectionCountAssertion HasCount( + public CollectionCountAssertion HasCount( int expectedCount, [CallerArgumentExpression(nameof(expectedCount))] string? expression = null) { Context.ExpressionBuilder.Append($".HasCount({expression})"); - return new CollectionCountAssertion(Context, expectedCount); + return new CollectionCountAssertion(Context, expectedCount); } /// @@ -97,10 +99,10 @@ public CollectionCountAssertion HasCount( /// This enables the pattern: .HasCount().GreaterThan(5) /// Example: await Assert.That(list).HasCount().EqualTo(5); /// - public CountWrapper HasCount() + public CountWrapper HasCount() { Context.ExpressionBuilder.Append(".HasCount()"); - return new CountWrapper(Context); + return new CountWrapper(Context); } /// @@ -108,10 +110,10 @@ public CountWrapper HasCount() /// This enables fluent assertions on the count itself. /// Example: await Assert.That(list).Count().IsGreaterThan(5); /// - public CollectionCountValueAssertion Count() + public CollectionCountValueAssertion Count() { Context.ExpressionBuilder.Append(".Count()"); - return new CollectionCountValueAssertion(Context, null); + return new CollectionCountValueAssertion(Context, null); } /// @@ -119,12 +121,12 @@ public CollectionCountValueAssertion Count() /// This enables fluent assertions on filtered counts. /// Example: await Assert.That(list).Count(x => x > 10).IsEqualTo(3); /// - public CollectionCountValueAssertion Count( + public CollectionCountValueAssertion Count( Func predicate, [CallerArgumentExpression(nameof(predicate))] string? expression = null) { Context.ExpressionBuilder.Append($".Count({expression})"); - return new CollectionCountValueAssertion(Context, predicate); + return new CollectionCountValueAssertion(Context, predicate); } /// @@ -132,12 +134,12 @@ public CollectionCountValueAssertion Count( /// This instance method enables calling IsOrderedBy with proper type inference. /// Example: await Assert.That(list).IsOrderedBy(x => x.Name); /// - public CollectionIsOrderedByAssertion IsOrderedBy( + public CollectionIsOrderedByAssertion IsOrderedBy( Func keySelector, [CallerArgumentExpression(nameof(keySelector))] string? expression = null) { Context.ExpressionBuilder.Append($".IsOrderedBy({expression})"); - return new CollectionIsOrderedByAssertion(Context, keySelector); + return new CollectionIsOrderedByAssertion(Context, keySelector); } /// @@ -145,14 +147,14 @@ public CollectionIsOrderedByAssertion IsOrderedBy( /// This instance method enables calling IsOrderedBy with proper type inference. /// Example: await Assert.That(list).IsOrderedBy(x => x.Name, StringComparer.OrdinalIgnoreCase); /// - public CollectionIsOrderedByAssertion IsOrderedBy( + public CollectionIsOrderedByAssertion IsOrderedBy( Func keySelector, IComparer? comparer, [CallerArgumentExpression(nameof(keySelector))] string? selectorExpression = null, [CallerArgumentExpression(nameof(comparer))] string? comparerExpression = null) { Context.ExpressionBuilder.Append($".IsOrderedBy({selectorExpression}, {comparerExpression})"); - return new CollectionIsOrderedByAssertion(Context, keySelector, comparer); + return new CollectionIsOrderedByAssertion(Context, keySelector, comparer); } /// @@ -160,12 +162,12 @@ public CollectionIsOrderedByAssertion IsOrderedBy( /// This instance method enables calling IsOrderedByDescending with proper type inference. /// Example: await Assert.That(list).IsOrderedByDescending(x => x.Age); /// - public CollectionIsOrderedByDescendingAssertion IsOrderedByDescending( + public CollectionIsOrderedByDescendingAssertion IsOrderedByDescending( Func keySelector, [CallerArgumentExpression(nameof(keySelector))] string? expression = null) { Context.ExpressionBuilder.Append($".IsOrderedByDescending({expression})"); - return new CollectionIsOrderedByDescendingAssertion(Context, keySelector); + return new CollectionIsOrderedByDescendingAssertion(Context, keySelector); } /// @@ -173,14 +175,14 @@ public CollectionIsOrderedByDescendingAssertion IsOrderedByDescendi /// This instance method enables calling IsOrderedByDescending with proper type inference. /// Example: await Assert.That(list).IsOrderedByDescending(x => x.Name, StringComparer.OrdinalIgnoreCase); /// - public CollectionIsOrderedByDescendingAssertion IsOrderedByDescending( + public CollectionIsOrderedByDescendingAssertion IsOrderedByDescending( Func keySelector, IComparer? comparer, [CallerArgumentExpression(nameof(keySelector))] string? selectorExpression = null, [CallerArgumentExpression(nameof(comparer))] string? comparerExpression = null) { Context.ExpressionBuilder.Append($".IsOrderedByDescending({selectorExpression}, {comparerExpression})"); - return new CollectionIsOrderedByDescendingAssertion(Context, keySelector, comparer); + return new CollectionIsOrderedByDescendingAssertion(Context, keySelector, comparer); } /// @@ -188,10 +190,10 @@ public CollectionIsOrderedByDescendingAssertion IsOrderedByDescendi /// This instance method enables calling IsEmpty with proper type inference. /// Example: await Assert.That(list).IsEmpty(); /// - public CollectionIsEmptyAssertion IsEmpty() + public CollectionIsEmptyAssertion IsEmpty() { Context.ExpressionBuilder.Append(".IsEmpty()"); - return new CollectionIsEmptyAssertion(Context); + return new CollectionIsEmptyAssertion(Context); } /// @@ -199,10 +201,10 @@ public CollectionIsEmptyAssertion IsEmpty() /// This instance method enables calling IsNotEmpty with proper type inference. /// Example: await Assert.That(list).IsNotEmpty(); /// - public CollectionIsNotEmptyAssertion IsNotEmpty() + public CollectionIsNotEmptyAssertion IsNotEmpty() { Context.ExpressionBuilder.Append(".IsNotEmpty()"); - return new CollectionIsNotEmptyAssertion(Context); + return new CollectionIsNotEmptyAssertion(Context); } /// @@ -210,10 +212,10 @@ public CollectionIsNotEmptyAssertion IsNotEmpty() /// This instance method enables calling HasSingleItem with proper type inference. /// Example: await Assert.That(list).HasSingleItem(); /// - public HasSingleItemAssertion HasSingleItem() + public HasSingleItemAssertion HasSingleItem() { Context.ExpressionBuilder.Append(".HasSingleItem()"); - return new HasSingleItemAssertion(Context); + return new HasSingleItemAssertion(Context); } /// @@ -221,12 +223,12 @@ public HasSingleItemAssertion HasSingleItem() /// This instance method enables calling DoesNotContain with proper type inference. /// Example: await Assert.That(list).DoesNotContain("value"); /// - public CollectionDoesNotContainAssertion DoesNotContain( + public CollectionDoesNotContainAssertion DoesNotContain( TItem expected, [CallerArgumentExpression(nameof(expected))] string? expression = null) { Context.ExpressionBuilder.Append($".DoesNotContain({expression})"); - return new CollectionDoesNotContainAssertion(Context, expected); + return new CollectionDoesNotContainAssertion(Context, expected); } /// @@ -234,12 +236,12 @@ public CollectionDoesNotContainAssertion DoesNotContain( /// This instance method enables calling DoesNotContain with proper type inference. /// Example: await Assert.That(list).DoesNotContain(x => x > 10); /// - public CollectionDoesNotContainPredicateAssertion DoesNotContain( + public CollectionDoesNotContainPredicateAssertion DoesNotContain( Func predicate, [CallerArgumentExpression(nameof(predicate))] string? expression = null) { Context.ExpressionBuilder.Append($".DoesNotContain({expression})"); - return new CollectionDoesNotContainPredicateAssertion(Context, predicate, expression ?? "predicate"); + return new CollectionDoesNotContainPredicateAssertion(Context, predicate, expression ?? "predicate"); } /// @@ -247,12 +249,12 @@ public CollectionDoesNotContainPredicateAssertion DoesNotContain( /// This instance method enables calling All with proper type inference. /// Example: await Assert.That(list).All(x => x > 0); /// - public CollectionAllAssertion All( + public CollectionAllAssertion All( Func predicate, [CallerArgumentExpression(nameof(predicate))] string? expression = null) { Context.ExpressionBuilder.Append($".All({expression})"); - return new CollectionAllAssertion(Context, predicate, expression ?? "predicate"); + return new CollectionAllAssertion(Context, predicate, expression ?? "predicate"); } /// @@ -260,10 +262,10 @@ public CollectionAllAssertion All( /// This instance method enables calling All().Satisfy() with proper type inference. /// Example: await Assert.That(list).All().Satisfy(item => item.IsNotNull()); /// - public CollectionAllSatisfyHelper All() + public CollectionAllSatisfyHelper All() { Context.ExpressionBuilder.Append(".All()"); - return new CollectionAllSatisfyHelper(Context); + return new CollectionAllSatisfyHelper(Context); } /// @@ -271,12 +273,12 @@ public CollectionAllSatisfyHelper All() /// This instance method enables calling Any with proper type inference. /// Example: await Assert.That(list).Any(x => x > 10); /// - public CollectionAnyAssertion Any( + public CollectionAnyAssertion Any( Func predicate, [CallerArgumentExpression(nameof(predicate))] string? expression = null) { Context.ExpressionBuilder.Append($".Any({expression})"); - return new CollectionAnyAssertion(Context, predicate, expression ?? "predicate"); + return new CollectionAnyAssertion(Context, predicate, expression ?? "predicate"); } /// @@ -284,12 +286,12 @@ public CollectionAnyAssertion Any( /// This instance method enables calling ContainsOnly with proper type inference. /// Example: await Assert.That(list).ContainsOnly(x => x > 0); /// - public CollectionAllAssertion ContainsOnly( + public CollectionAllAssertion ContainsOnly( Func predicate, [CallerArgumentExpression(nameof(predicate))] string? expression = null) { Context.ExpressionBuilder.Append($".ContainsOnly({expression})"); - return new CollectionAllAssertion(Context, predicate, expression ?? "predicate"); + return new CollectionAllAssertion(Context, predicate, expression ?? "predicate"); } /// @@ -298,10 +300,10 @@ public CollectionAllAssertion ContainsOnly( /// Uses runtime comparison via Comparer<TItem>.Default. /// Example: await Assert.That(list).IsInOrder(); /// - public CollectionIsInOrderAssertion IsInOrder() + public CollectionIsInOrderAssertion IsInOrder() { Context.ExpressionBuilder.Append(".IsInOrder()"); - return new CollectionIsInOrderAssertion(Context); + return new CollectionIsInOrderAssertion(Context); } /// @@ -310,22 +312,22 @@ public CollectionIsInOrderAssertion IsInOrder() /// Uses runtime comparison via Comparer<TItem>.Default. /// Example: await Assert.That(list).IsInDescendingOrder(); /// - public CollectionIsInDescendingOrderAssertion IsInDescendingOrder() + public CollectionIsInDescendingOrderAssertion IsInDescendingOrder() { Context.ExpressionBuilder.Append(".IsInDescendingOrder()"); - return new CollectionIsInDescendingOrderAssertion(Context); + return new CollectionIsInDescendingOrderAssertion(Context); } /// /// Returns an And continuation that preserves collection type and item type. /// Overrides the base Assertion.And to return a collection-specific continuation. /// - public new CollectionAndContinuation And + public new CollectionAndContinuation And { get { - ThrowIfMixingCombiner>>(); - return new CollectionAndContinuation(Context, InternalWrappedExecution ?? this); + ThrowIfMixingCombiner>(); + return new CollectionAndContinuation(Context, InternalWrappedExecution ?? this); } } @@ -333,12 +335,12 @@ public CollectionIsInDescendingOrderAssertion IsInDescendingOrder() /// Returns an Or continuation that preserves collection type and item type. /// Overrides the base Assertion.Or to return a collection-specific continuation. /// - public new CollectionOrContinuation Or + public new CollectionOrContinuation Or { get { - ThrowIfMixingCombiner>>(); - return new CollectionOrContinuation(Context, InternalWrappedExecution ?? this); + ThrowIfMixingCombiner>(); + return new CollectionOrContinuation(Context, InternalWrappedExecution ?? this); } } } diff --git a/TUnit.Assertions/Sources/DictionaryAssertionBase.cs b/TUnit.Assertions/Sources/DictionaryAssertionBase.cs index f40be0c5c8..b5077d1b43 100644 --- a/TUnit.Assertions/Sources/DictionaryAssertionBase.cs +++ b/TUnit.Assertions/Sources/DictionaryAssertionBase.cs @@ -7,20 +7,15 @@ namespace TUnit.Assertions.Sources; /// /// Base class for dictionary assertions that preserves type through And/Or chains. -/// Implements IAssertionSource<TDictionary> to enable all collection and dictionary extension methods. -/// Since dictionaries are collections of KeyValuePair items, collection assertions also work on dictionaries. +/// Inherits from CollectionAssertionBase to automatically get all collection methods (HasSingleItem, IsInOrder, etc.) +/// since dictionaries are collections of KeyValuePair items. /// /// The dictionary type (e.g., Dictionary, IReadOnlyDictionary) /// The dictionary key type /// The dictionary value type -public abstract class DictionaryAssertionBase : Assertion, IAssertionSource +public abstract class DictionaryAssertionBase : CollectionAssertionBase> where TDictionary : IReadOnlyDictionary { - /// - /// Explicit implementation of IAssertionSource.Context to expose the context publicly. - /// - AssertionContext IAssertionSource.Context => Context; - protected DictionaryAssertionBase(AssertionContext context) : base(context) { @@ -36,10 +31,8 @@ private protected DictionaryAssertionBase( Assertion previousAssertion, string combinerExpression, CombinerType combinerType) - : base(context) + : base(context, previousAssertion, combinerExpression, combinerType) { - context.ExpressionBuilder.Append(combinerExpression); - context.SetPendingLink(previousAssertion, combinerType); } protected override string GetExpectation() => "dictionary assertion"; @@ -85,115 +78,6 @@ public DictionaryDoesNotContainKeyAssertion DoesNotCo return new DictionaryDoesNotContainKeyAssertion(Context, expectedKey); } - /// - /// Asserts that the dictionary is empty (has no key-value pairs). - /// This instance method enables calling IsEmpty with proper type inference. - /// Example: await Assert.That(dictionary).IsEmpty(); - /// - public CollectionIsEmptyAssertion> IsEmpty() - { - Context.ExpressionBuilder.Append(".IsEmpty()"); - return new CollectionIsEmptyAssertion>(Context.Map>>(dict => dict)); - } - - /// - /// Asserts that the dictionary is not empty (has at least one key-value pair). - /// This instance method enables calling IsNotEmpty with proper type inference. - /// Example: await Assert.That(dictionary).IsNotEmpty(); - /// - public CollectionIsNotEmptyAssertion> IsNotEmpty() - { - Context.ExpressionBuilder.Append(".IsNotEmpty()"); - return new CollectionIsNotEmptyAssertion>(Context.Map>>(dict => dict)); - } - - /// - /// Asserts that the dictionary contains the specified key-value pair. - /// This instance method enables calling Contains with proper type inference. - /// Example: await Assert.That(dictionary).Contains(new KeyValuePair<string, int>("key", 1)); - /// - public CollectionContainsAssertion> Contains( - KeyValuePair expected, - [CallerArgumentExpression(nameof(expected))] string? expression = null) - { - Context.ExpressionBuilder.Append($".Contains({expression})"); - return new CollectionContainsAssertion>(Context.Map>>(dict => dict), expected); - } - - /// - /// Asserts that the dictionary contains a key-value pair matching the predicate. - /// This instance method enables calling Contains with proper type inference. - /// Example: await Assert.That(dictionary).Contains(kvp => kvp.Value > 10); - /// - public CollectionContainsPredicateAssertion> Contains( - Func, bool> predicate, - [CallerArgumentExpression(nameof(predicate))] string? expression = null) - { - Context.ExpressionBuilder.Append($".Contains({expression})"); - return new CollectionContainsPredicateAssertion>(Context.Map>>(dict => dict), predicate); - } - - /// - /// Asserts that all key-value pairs in the dictionary satisfy the predicate. - /// This instance method enables calling All with proper type inference. - /// Example: await Assert.That(dictionary).All(kvp => kvp.Value > 0); - /// - public CollectionAllAssertion> All( - Func, bool> predicate, - [CallerArgumentExpression(nameof(predicate))] string? expression = null) - { - Context.ExpressionBuilder.Append($".All({expression})"); - return new CollectionAllAssertion>(Context.Map>>(dict => dict), predicate, expression ?? "predicate"); - } - - /// - /// Returns a helper for the .All().Satisfy() pattern on dictionaries. - /// This instance method enables calling All().Satisfy() with proper type inference. - /// Example: await Assert.That(dictionary).All().Satisfy(kvp => kvp.Value.IsNotNull()); - /// - public CollectionAllSatisfyHelper> All() - { - Context.ExpressionBuilder.Append(".All()"); - return new CollectionAllSatisfyHelper>(Context.Map>>(dict => dict)); - } - - /// - /// Asserts that at least one key-value pair in the dictionary satisfies the predicate. - /// This instance method enables calling Any with proper type inference. - /// Example: await Assert.That(dictionary).Any(kvp => kvp.Value > 100); - /// - public CollectionAnyAssertion> Any( - Func, bool> predicate, - [CallerArgumentExpression(nameof(predicate))] string? expression = null) - { - Context.ExpressionBuilder.Append($".Any({expression})"); - return new CollectionAnyAssertion>(Context.Map>>(dict => dict), predicate, expression ?? "predicate"); - } - - /// - /// Asserts that the dictionary has the expected number of key-value pairs. - /// This instance method enables calling HasCount with proper type inference. - /// Example: await Assert.That(dictionary).HasCount(5); - /// - public CollectionCountAssertion> HasCount( - int expectedCount, - [CallerArgumentExpression(nameof(expectedCount))] string? expression = null) - { - Context.ExpressionBuilder.Append($".HasCount({expression})"); - return new CollectionCountAssertion>(Context.Map>>(dict => dict), expectedCount); - } - - /// - /// Returns a wrapper for fluent count assertions on dictionaries. - /// This enables the pattern: .HasCount().GreaterThan(5) - /// Example: await Assert.That(dictionary).HasCount().EqualTo(5); - /// - public CountWrapper> HasCount() - { - Context.ExpressionBuilder.Append(".HasCount()"); - return new CountWrapper>(Context.Map>>(dict => dict)); - } - /// /// Returns an And continuation that preserves dictionary type, key type, and value type. /// Overrides the base Assertion.And to return a dictionary-specific continuation. diff --git a/TUnit.PublicAPI/Tests.Assertions_Library_Has_No_API_Changes.DotNet10_0.verified.txt b/TUnit.PublicAPI/Tests.Assertions_Library_Has_No_API_Changes.DotNet10_0.verified.txt index cf53b41e7f..02dcf51778 100644 --- a/TUnit.PublicAPI/Tests.Assertions_Library_Has_No_API_Changes.DotNet10_0.verified.txt +++ b/TUnit.PublicAPI/Tests.Assertions_Library_Has_No_API_Changes.DotNet10_0.verified.txt @@ -367,122 +367,140 @@ namespace .Conditions [.("IsWhiteSpace", ExpectationMessage="be whitespace")] public static class CharAssertionExtensions { } [.("All")] - public class CollectionAllAssertion : . + public class CollectionAllAssertion : . + where TCollection : . { - public CollectionAllAssertion(.<.> context, predicate, string predicateDescription) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public CollectionAllAssertion(. context, predicate, string predicateDescription) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } } - public class CollectionAllSatisfyAssertion : . + public class CollectionAllSatisfyAssertion : . + where TCollection : . { - public CollectionAllSatisfyAssertion(.<.> context, <., .?> assertion, string assertionDescription) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public CollectionAllSatisfyAssertion(. context, <., .?> assertion, string assertionDescription) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } } - public class CollectionAllSatisfyHelper + public class CollectionAllSatisfyHelper + where TCollection : . { - public CollectionAllSatisfyHelper(.<.> context) { } - public . Satisfy(<., .?> assertion, [.("assertion")] string? expression = null) { } - public . Satisfy( mapper, <., .?> assertion, [.("mapper")] string? mapperExpression = null, [.("assertion")] string? assertionExpression = null) { } + public CollectionAllSatisfyHelper(. context) { } + public . Satisfy(<., .?> assertion, [.("assertion")] string? expression = null) { } + public . Satisfy( mapper, <., .?> assertion, [.("mapper")] string? mapperExpression = null, [.("assertion")] string? assertionExpression = null) { } } - public class CollectionAllSatisfyMappedAssertion : . + public class CollectionAllSatisfyMappedAssertion : . + where TCollection : . { - public CollectionAllSatisfyMappedAssertion(.<.> context, mapper, <., .?> assertion, string mapperDescription, string assertionDescription) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public CollectionAllSatisfyMappedAssertion(. context, mapper, <., .?> assertion, string mapperDescription, string assertionDescription) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } } [.("Any")] - public class CollectionAnyAssertion : . + public class CollectionAnyAssertion : . + where TCollection : . { - public CollectionAnyAssertion(.<.> context, predicate, string predicateDescription) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public CollectionAnyAssertion(. context, predicate, string predicateDescription) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } } - public abstract class CollectionComparerBasedAssertion : . + public abstract class CollectionComparerBasedAssertion : . + where TCollection : . { - protected CollectionComparerBasedAssertion(.<.> context) { } + protected CollectionComparerBasedAssertion(. context) { } protected . GetComparer() { } protected bool HasCustomComparer() { } protected void SetComparer(. comparer) { } } [.("Contains")] - public class CollectionContainsAssertion : . + public class CollectionContainsAssertion : . + where TCollection : . { - public CollectionContainsAssertion(.<.> context, TItem expected, .? comparer = null) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public CollectionContainsAssertion(. context, TItem expected, .? comparer = null) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } } [.("Contains")] - public class CollectionContainsPredicateAssertion : . + public class CollectionContainsPredicateAssertion : . + where TCollection : . { - public CollectionContainsPredicateAssertion(.<.> context, predicate) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public CollectionContainsPredicateAssertion(. context, predicate) { } + protected override .<.> CheckAsync(. metadata) { } public . GetAwaiter() { } protected override string GetExpectation() { } } [.("HasCount")] - public class CollectionCountAssertion : . + public class CollectionCountAssertion : . + where TCollection : . { - public CollectionCountAssertion(.<.> context, int expectedCount) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public CollectionCountAssertion(. context, int expectedCount) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } } - public class CollectionCountValueAssertion : . + public class CollectionCountValueAssertion : . + where TCollection : . { - public CollectionCountValueAssertion(.<.> collectionContext, ? predicate) { } + public CollectionCountValueAssertion(. collectionContext, ? predicate) { } } [.("DoesNotContain")] - public class CollectionDoesNotContainAssertion : . + public class CollectionDoesNotContainAssertion : . + where TCollection : . { - public CollectionDoesNotContainAssertion(.<.> context, TItem expected, .? comparer = null) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public CollectionDoesNotContainAssertion(. context, TItem expected, .? comparer = null) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } } [.("DoesNotContain")] - public class CollectionDoesNotContainPredicateAssertion : . + public class CollectionDoesNotContainPredicateAssertion : . + where TCollection : . { - public CollectionDoesNotContainPredicateAssertion(.<.> context, predicate, string predicateDescription) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public CollectionDoesNotContainPredicateAssertion(. context, predicate, string predicateDescription) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } } [.("IsEmpty")] - public class CollectionIsEmptyAssertion : . + public class CollectionIsEmptyAssertion : . + where TCollection : . { - public CollectionIsEmptyAssertion(.<.> context) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public CollectionIsEmptyAssertion(. context) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } } [.("IsInDescendingOrder")] - public class CollectionIsInDescendingOrderAssertion : . + public class CollectionIsInDescendingOrderAssertion : . + where TCollection : . { - public CollectionIsInDescendingOrderAssertion(.<.> context) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public CollectionIsInDescendingOrderAssertion(. context) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } } [.("IsInOrder")] - public class CollectionIsInOrderAssertion : . + public class CollectionIsInOrderAssertion : . + where TCollection : . { - public CollectionIsInOrderAssertion(.<.> context) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public CollectionIsInOrderAssertion(. context) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } } [.("IsNotEmpty")] - public class CollectionIsNotEmptyAssertion : . + public class CollectionIsNotEmptyAssertion : . + where TCollection : . { - public CollectionIsNotEmptyAssertion(.<.> context) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public CollectionIsNotEmptyAssertion(. context) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } } - public class CollectionIsOrderedByAssertion : . + public class CollectionIsOrderedByAssertion : . + where TCollection : . { - public CollectionIsOrderedByAssertion(.<.> context, keySelector, .? comparer = null) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public CollectionIsOrderedByAssertion(. context, keySelector, .? comparer = null) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } } - public class CollectionIsOrderedByDescendingAssertion : . + public class CollectionIsOrderedByDescendingAssertion : . + where TCollection : . { - public CollectionIsOrderedByDescendingAssertion(.<.> context, keySelector, .? comparer = null) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public CollectionIsOrderedByDescendingAssertion(. context, keySelector, .? comparer = null) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } } public abstract class ComparerBasedAssertion : . @@ -908,10 +926,11 @@ namespace .Conditions protected override string GetExpectation() { } } [.("HasSingleItem")] - public class HasSingleItemAssertion : . + public class HasSingleItemAssertion : . + where TCollection : . { - public HasSingleItemAssertion(.<.> context) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public HasSingleItemAssertion(. context) { } + protected override .<.> CheckAsync(. metadata) { } public . GetAwaiter() { } protected override string GetExpectation() { } } @@ -980,14 +999,15 @@ namespace .Conditions [.("Collection equivalency uses structural comparison for complex objects, which requ" + "ires reflection and is not compatible with AOT")] [.("IsEquivalentTo")] - public class IsEquivalentToAssertion : . + public class IsEquivalentToAssertion : . + where TCollection : . { - public IsEquivalentToAssertion(.<.> context, . expected, . ordering = 0) { } - public IsEquivalentToAssertion(.<.> context, . expected, . comparer, . ordering = 0) { } + public IsEquivalentToAssertion(. context, . expected, . ordering = 0) { } + public IsEquivalentToAssertion(. context, . expected, . comparer, . ordering = 0) { } [.("AOT", "IL3050", Justification="Collection equivalency uses structural comparison which requires reflection")] - protected override .<.> CheckAsync(.<.> metadata) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } - public . Using(. comparer) { } + public . Using(. comparer) { } } [.("IsIn")] public class IsInAssertion : . @@ -1085,13 +1105,14 @@ namespace .Conditions [.("Collection equivalency uses structural comparison for complex objects, which requ" + "ires reflection and is not compatible with AOT")] [.("IsNotEquivalentTo")] - public class NotEquivalentToAssertion : . + public class NotEquivalentToAssertion : . + where TCollection : . { - public NotEquivalentToAssertion(.<.> context, . notExpected, . ordering = 0) { } + public NotEquivalentToAssertion(. context, . notExpected, . ordering = 0) { } [.("AOT", "IL3050", Justification="Collection equivalency uses structural comparison which requires reflection")] - protected override .<.> CheckAsync(.<.> metadata) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } - public . Using(. comparer) { } + public . Using(. comparer) { } } public class NotNullAssertion : . { @@ -1528,18 +1549,19 @@ namespace . } namespace . { - public class CountWrapper : ., .<.> + public class CountWrapper : ., . + where TCollection : . { - public CountWrapper(.<.> context) { } + public CountWrapper(. context) { } public . Between(int minimum, int maximum, [.("minimum")] string? minExpression = null, [.("maximum")] string? maxExpression = null) { } - public . EqualTo(int expectedCount, [.("expectedCount")] string? expression = null) { } + public . EqualTo(int expectedCount, [.("expectedCount")] string? expression = null) { } public . GreaterThan(int expected, [.("expected")] string? expression = null) { } public . GreaterThanOrEqualTo(int expected, [.("expected")] string? expression = null) { } public . LessThan(int expected, [.("expected")] string? expression = null) { } public . LessThanOrEqualTo(int expected, [.("expected")] string? expression = null) { } public . NotEqualTo(int expected, [.("expected")] string? expression = null) { } public . Positive() { } - public . Zero() { } + public . Zero() { } } public class LengthWrapper : ., . { @@ -1601,8 +1623,10 @@ namespace .Core And = 1, Or = 2, } - public class CollectionAndContinuation : . { } - public class CollectionOrContinuation : . { } + public class CollectionAndContinuation : . + where TCollection : . { } + public class CollectionOrContinuation : . + where TCollection : . { } public class DictionaryAndContinuation : . where TDictionary : . { } public class DictionaryOrContinuation : . @@ -2030,47 +2054,58 @@ namespace .Extensions } public static class CollectionAllAssertionExtensions { - public static . All(this .<.> source, predicate, string predicateDescription, [.("predicate")] string? predicateExpression = null, [.("predicateDescription")] string? predicateDescriptionExpression = null) { } + public static . All(this . source, predicate, string predicateDescription, [.("predicate")] string? predicateExpression = null, [.("predicateDescription")] string? predicateDescriptionExpression = null) + where TCollection : . { } } public static class CollectionAnyAssertionExtensions { - public static . Any(this .<.> source, predicate, string predicateDescription, [.("predicate")] string? predicateExpression = null, [.("predicateDescription")] string? predicateDescriptionExpression = null) { } + public static . Any(this . source, predicate, string predicateDescription, [.("predicate")] string? predicateExpression = null, [.("predicateDescription")] string? predicateDescriptionExpression = null) + where TCollection : . { } } public static class CollectionContainsAssertionExtensions { - public static . Contains(this .<.> source, TItem expected, .? comparer = null, [.("expected")] string? expectedExpression = null, [.("comparer")] string? comparerExpression = null) { } + public static . Contains(this . source, TItem expected, .? comparer = null, [.("expected")] string? expectedExpression = null, [.("comparer")] string? comparerExpression = null) + where TCollection : . { } } public static class CollectionContainsPredicateAssertionExtensions { - public static . Contains(this .<.> source, predicate, [.("predicate")] string? predicateExpression = null) { } + public static . Contains(this . source, predicate, [.("predicate")] string? predicateExpression = null) + where TCollection : . { } } public static class CollectionCountAssertionExtensions { - public static . HasCount(this .<.> source, int expectedCount, [.("expectedCount")] string? expectedCountExpression = null) { } + public static . HasCount(this . source, int expectedCount, [.("expectedCount")] string? expectedCountExpression = null) + where TCollection : . { } } public static class CollectionDoesNotContainAssertionExtensions { - public static . DoesNotContain(this .<.> source, TItem expected, .? comparer = null, [.("expected")] string? expectedExpression = null, [.("comparer")] string? comparerExpression = null) { } + public static . DoesNotContain(this . source, TItem expected, .? comparer = null, [.("expected")] string? expectedExpression = null, [.("comparer")] string? comparerExpression = null) + where TCollection : . { } } public static class CollectionDoesNotContainPredicateAssertionExtensions { - public static . DoesNotContain(this .<.> source, predicate, string predicateDescription, [.("predicate")] string? predicateExpression = null, [.("predicateDescription")] string? predicateDescriptionExpression = null) { } + public static . DoesNotContain(this . source, predicate, string predicateDescription, [.("predicate")] string? predicateExpression = null, [.("predicateDescription")] string? predicateDescriptionExpression = null) + where TCollection : . { } } public static class CollectionIsEmptyAssertionExtensions { - public static . IsEmpty(this .<.> source) { } + public static . IsEmpty(this . source) + where TCollection : . { } } public static class CollectionIsInDescendingOrderAssertionExtensions { - public static . IsInDescendingOrder(this .<.> source) { } + public static . IsInDescendingOrder(this . source) + where TCollection : . { } } public static class CollectionIsInOrderAssertionExtensions { - public static . IsInOrder(this .<.> source) { } + public static . IsInOrder(this . source) + where TCollection : . { } } public static class CollectionIsNotEmptyAssertionExtensions { - public static . IsNotEmpty(this .<.> source) { } + public static . IsNotEmpty(this . source) + where TCollection : . { } } public static class CultureInfoAssertionExtensions { @@ -2763,7 +2798,8 @@ namespace .Extensions } public static class HasSingleItemAssertionExtensions { - public static . HasSingleItem(this .<.> source) { } + public static . HasSingleItem(this . source) + where TCollection : . { } } public static class HttpStatusCodeAssertionExtensions { @@ -2924,10 +2960,12 @@ namespace .Extensions { [.("Collection equivalency uses structural comparison for complex objects, which requ" + "ires reflection and is not compatible with AOT")] - public static . IsEquivalentTo(this .<.> source, . expected, . ordering = 0, [.("expected")] string? expectedExpression = null, [.("ordering")] string? orderingExpression = null) { } + public static . IsEquivalentTo(this . source, . expected, . ordering = 0, [.("expected")] string? expectedExpression = null, [.("ordering")] string? orderingExpression = null) + where TCollection : . { } [.("Collection equivalency uses structural comparison for complex objects, which requ" + "ires reflection and is not compatible with AOT")] - public static . IsEquivalentTo(this .<.> source, . expected, . comparer, . ordering = 0, [.("expected")] string? expectedExpression = null, [.("comparer")] string? comparerExpression = null, [.("ordering")] string? orderingExpression = null) { } + public static . IsEquivalentTo(this . source, . expected, . comparer, . ordering = 0, [.("expected")] string? expectedExpression = null, [.("comparer")] string? comparerExpression = null, [.("ordering")] string? orderingExpression = null) + where TCollection : . { } } public static class IsInAssertionExtensions { @@ -2990,7 +3028,8 @@ namespace .Extensions { [.("Collection equivalency uses structural comparison for complex objects, which requ" + "ires reflection and is not compatible with AOT")] - public static . IsNotEquivalentTo(this .<.> source, . notExpected, . ordering = 0, [.("notExpected")] string? notExpectedExpression = null, [.("ordering")] string? orderingExpression = null) { } + public static . IsNotEquivalentTo(this . source, . notExpected, . ordering = 0, [.("notExpected")] string? notExpectedExpression = null, [.("ordering")] string? orderingExpression = null) + where TCollection : . { } } public static class NotSameReferenceAssertionExtensions { @@ -3779,36 +3818,37 @@ namespace .Sources public . ThrowsExactly() where TException : { } } - public abstract class CollectionAssertionBase : .<.>, ., .<.> - { - protected CollectionAssertionBase(.<.> context) { } - public new . And { get; } - public new . Or { get; } - public . All() { } - public . All( predicate, [.("predicate")] string? expression = null) { } - public . Any( predicate, [.("predicate")] string? expression = null) { } - public . Contains( predicate, [.("predicate")] string? expression = null) { } - public . Contains(TItem expected, [.("expected")] string? expression = null) { } - public . ContainsOnly( predicate, [.("predicate")] string? expression = null) { } - public . Count() { } - public . Count( predicate, [.("predicate")] string? expression = null) { } - public . DoesNotContain( predicate, [.("predicate")] string? expression = null) { } - public . DoesNotContain(TItem expected, [.("expected")] string? expression = null) { } - protected override string GetExpectation() { } - public ..CountWrapper HasCount() { } - public . HasCount(int expectedCount, [.("expectedCount")] string? expression = null) { } - public . HasSingleItem() { } - public . IsEmpty() { } - public . IsInDescendingOrder() { } - public . IsInOrder() { } - public . IsNotEmpty() { } - public . IsOrderedBy( keySelector, [.("keySelector")] string? expression = null) { } - public . IsOrderedBy( keySelector, .? comparer, [.("keySelector")] string? selectorExpression = null, [.("comparer")] string? comparerExpression = null) { } - public . IsOrderedByDescending( keySelector, [.("keySelector")] string? expression = null) { } - public . IsOrderedByDescending( keySelector, .? comparer, [.("keySelector")] string? selectorExpression = null, [.("comparer")] string? comparerExpression = null) { } - public .<., TExpected> IsTypeOf() { } - } - public class CollectionAssertion : . + public abstract class CollectionAssertionBase : ., ., . + where TCollection : . + { + protected CollectionAssertionBase(. context) { } + public new . And { get; } + public new . Or { get; } + public . All() { } + public . All( predicate, [.("predicate")] string? expression = null) { } + public . Any( predicate, [.("predicate")] string? expression = null) { } + public . Contains( predicate, [.("predicate")] string? expression = null) { } + public . Contains(TItem expected, [.("expected")] string? expression = null) { } + public . ContainsOnly( predicate, [.("predicate")] string? expression = null) { } + public . Count() { } + public . Count( predicate, [.("predicate")] string? expression = null) { } + public . DoesNotContain( predicate, [.("predicate")] string? expression = null) { } + public . DoesNotContain(TItem expected, [.("expected")] string? expression = null) { } + protected override string GetExpectation() { } + public ..CountWrapper HasCount() { } + public . HasCount(int expectedCount, [.("expectedCount")] string? expression = null) { } + public . HasSingleItem() { } + public . IsEmpty() { } + public . IsInDescendingOrder() { } + public . IsInOrder() { } + public . IsNotEmpty() { } + public . IsOrderedBy( keySelector, [.("keySelector")] string? expression = null) { } + public . IsOrderedBy( keySelector, .? comparer, [.("keySelector")] string? selectorExpression = null, [.("comparer")] string? comparerExpression = null) { } + public . IsOrderedByDescending( keySelector, [.("keySelector")] string? expression = null) { } + public . IsOrderedByDescending( keySelector, .? comparer, [.("keySelector")] string? selectorExpression = null, [.("comparer")] string? comparerExpression = null) { } + public . IsTypeOf() { } + } + public class CollectionAssertion : .<., TItem> { public CollectionAssertion(. value, string? expression) { } } @@ -3821,25 +3861,16 @@ namespace .Sources public . ThrowsExactly() where TException : { } } - public abstract class DictionaryAssertionBase : ., ., . + public abstract class DictionaryAssertionBase : .> where TDictionary : . { protected DictionaryAssertionBase(. context) { } public new . And { get; } public new . Or { get; } - public .<.> All() { } - public .<.> All(<., bool> predicate, [.("predicate")] string? expression = null) { } - public .<.> Any(<., bool> predicate, [.("predicate")] string? expression = null) { } - public .<.> Contains(. expected, [.("expected")] string? expression = null) { } - public .<.> Contains(<., bool> predicate, [.("predicate")] string? expression = null) { } public . ContainsKey(TKey expectedKey, [.("expectedKey")] string? expression = null) { } public . ContainsKey(TKey expectedKey, .? comparer, [.("expectedKey")] string? keyExpression = null, [.("comparer")] string? comparerExpression = null) { } public . DoesNotContainKey(TKey expectedKey, [.("expectedKey")] string? expression = null) { } protected override string GetExpectation() { } - public ..CountWrapper<.> HasCount() { } - public .<.> HasCount(int expectedCount, [.("expectedCount")] string? expression = null) { } - public .<.> IsEmpty() { } - public .<.> IsNotEmpty() { } } public class DictionaryAssertion : .<., TKey, TValue> { diff --git a/TUnit.PublicAPI/Tests.Assertions_Library_Has_No_API_Changes.DotNet8_0.verified.txt b/TUnit.PublicAPI/Tests.Assertions_Library_Has_No_API_Changes.DotNet8_0.verified.txt index 81b4f7672e..35f3a409e5 100644 --- a/TUnit.PublicAPI/Tests.Assertions_Library_Has_No_API_Changes.DotNet8_0.verified.txt +++ b/TUnit.PublicAPI/Tests.Assertions_Library_Has_No_API_Changes.DotNet8_0.verified.txt @@ -364,122 +364,140 @@ namespace .Conditions [.("IsWhiteSpace", ExpectationMessage="be whitespace")] public static class CharAssertionExtensions { } [.("All")] - public class CollectionAllAssertion : . + public class CollectionAllAssertion : . + where TCollection : . { - public CollectionAllAssertion(.<.> context, predicate, string predicateDescription) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public CollectionAllAssertion(. context, predicate, string predicateDescription) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } } - public class CollectionAllSatisfyAssertion : . + public class CollectionAllSatisfyAssertion : . + where TCollection : . { - public CollectionAllSatisfyAssertion(.<.> context, <., .?> assertion, string assertionDescription) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public CollectionAllSatisfyAssertion(. context, <., .?> assertion, string assertionDescription) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } } - public class CollectionAllSatisfyHelper + public class CollectionAllSatisfyHelper + where TCollection : . { - public CollectionAllSatisfyHelper(.<.> context) { } - public . Satisfy(<., .?> assertion, [.("assertion")] string? expression = null) { } - public . Satisfy( mapper, <., .?> assertion, [.("mapper")] string? mapperExpression = null, [.("assertion")] string? assertionExpression = null) { } + public CollectionAllSatisfyHelper(. context) { } + public . Satisfy(<., .?> assertion, [.("assertion")] string? expression = null) { } + public . Satisfy( mapper, <., .?> assertion, [.("mapper")] string? mapperExpression = null, [.("assertion")] string? assertionExpression = null) { } } - public class CollectionAllSatisfyMappedAssertion : . + public class CollectionAllSatisfyMappedAssertion : . + where TCollection : . { - public CollectionAllSatisfyMappedAssertion(.<.> context, mapper, <., .?> assertion, string mapperDescription, string assertionDescription) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public CollectionAllSatisfyMappedAssertion(. context, mapper, <., .?> assertion, string mapperDescription, string assertionDescription) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } } [.("Any")] - public class CollectionAnyAssertion : . + public class CollectionAnyAssertion : . + where TCollection : . { - public CollectionAnyAssertion(.<.> context, predicate, string predicateDescription) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public CollectionAnyAssertion(. context, predicate, string predicateDescription) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } } - public abstract class CollectionComparerBasedAssertion : . + public abstract class CollectionComparerBasedAssertion : . + where TCollection : . { - protected CollectionComparerBasedAssertion(.<.> context) { } + protected CollectionComparerBasedAssertion(. context) { } protected . GetComparer() { } protected bool HasCustomComparer() { } protected void SetComparer(. comparer) { } } [.("Contains")] - public class CollectionContainsAssertion : . + public class CollectionContainsAssertion : . + where TCollection : . { - public CollectionContainsAssertion(.<.> context, TItem expected, .? comparer = null) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public CollectionContainsAssertion(. context, TItem expected, .? comparer = null) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } } [.("Contains")] - public class CollectionContainsPredicateAssertion : . + public class CollectionContainsPredicateAssertion : . + where TCollection : . { - public CollectionContainsPredicateAssertion(.<.> context, predicate) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public CollectionContainsPredicateAssertion(. context, predicate) { } + protected override .<.> CheckAsync(. metadata) { } public . GetAwaiter() { } protected override string GetExpectation() { } } [.("HasCount")] - public class CollectionCountAssertion : . + public class CollectionCountAssertion : . + where TCollection : . { - public CollectionCountAssertion(.<.> context, int expectedCount) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public CollectionCountAssertion(. context, int expectedCount) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } } - public class CollectionCountValueAssertion : . + public class CollectionCountValueAssertion : . + where TCollection : . { - public CollectionCountValueAssertion(.<.> collectionContext, ? predicate) { } + public CollectionCountValueAssertion(. collectionContext, ? predicate) { } } [.("DoesNotContain")] - public class CollectionDoesNotContainAssertion : . + public class CollectionDoesNotContainAssertion : . + where TCollection : . { - public CollectionDoesNotContainAssertion(.<.> context, TItem expected, .? comparer = null) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public CollectionDoesNotContainAssertion(. context, TItem expected, .? comparer = null) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } } [.("DoesNotContain")] - public class CollectionDoesNotContainPredicateAssertion : . + public class CollectionDoesNotContainPredicateAssertion : . + where TCollection : . { - public CollectionDoesNotContainPredicateAssertion(.<.> context, predicate, string predicateDescription) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public CollectionDoesNotContainPredicateAssertion(. context, predicate, string predicateDescription) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } } [.("IsEmpty")] - public class CollectionIsEmptyAssertion : . + public class CollectionIsEmptyAssertion : . + where TCollection : . { - public CollectionIsEmptyAssertion(.<.> context) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public CollectionIsEmptyAssertion(. context) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } } [.("IsInDescendingOrder")] - public class CollectionIsInDescendingOrderAssertion : . + public class CollectionIsInDescendingOrderAssertion : . + where TCollection : . { - public CollectionIsInDescendingOrderAssertion(.<.> context) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public CollectionIsInDescendingOrderAssertion(. context) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } } [.("IsInOrder")] - public class CollectionIsInOrderAssertion : . + public class CollectionIsInOrderAssertion : . + where TCollection : . { - public CollectionIsInOrderAssertion(.<.> context) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public CollectionIsInOrderAssertion(. context) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } } [.("IsNotEmpty")] - public class CollectionIsNotEmptyAssertion : . + public class CollectionIsNotEmptyAssertion : . + where TCollection : . { - public CollectionIsNotEmptyAssertion(.<.> context) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public CollectionIsNotEmptyAssertion(. context) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } } - public class CollectionIsOrderedByAssertion : . + public class CollectionIsOrderedByAssertion : . + where TCollection : . { - public CollectionIsOrderedByAssertion(.<.> context, keySelector, .? comparer = null) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public CollectionIsOrderedByAssertion(. context, keySelector, .? comparer = null) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } } - public class CollectionIsOrderedByDescendingAssertion : . + public class CollectionIsOrderedByDescendingAssertion : . + where TCollection : . { - public CollectionIsOrderedByDescendingAssertion(.<.> context, keySelector, .? comparer = null) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public CollectionIsOrderedByDescendingAssertion(. context, keySelector, .? comparer = null) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } } public abstract class ComparerBasedAssertion : . @@ -905,10 +923,11 @@ namespace .Conditions protected override string GetExpectation() { } } [.("HasSingleItem")] - public class HasSingleItemAssertion : . + public class HasSingleItemAssertion : . + where TCollection : . { - public HasSingleItemAssertion(.<.> context) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public HasSingleItemAssertion(. context) { } + protected override .<.> CheckAsync(. metadata) { } public . GetAwaiter() { } protected override string GetExpectation() { } } @@ -977,14 +996,15 @@ namespace .Conditions [.("Collection equivalency uses structural comparison for complex objects, which requ" + "ires reflection and is not compatible with AOT")] [.("IsEquivalentTo")] - public class IsEquivalentToAssertion : . + public class IsEquivalentToAssertion : . + where TCollection : . { - public IsEquivalentToAssertion(.<.> context, . expected, . ordering = 0) { } - public IsEquivalentToAssertion(.<.> context, . expected, . comparer, . ordering = 0) { } + public IsEquivalentToAssertion(. context, . expected, . ordering = 0) { } + public IsEquivalentToAssertion(. context, . expected, . comparer, . ordering = 0) { } [.("AOT", "IL3050", Justification="Collection equivalency uses structural comparison which requires reflection")] - protected override .<.> CheckAsync(.<.> metadata) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } - public . Using(. comparer) { } + public . Using(. comparer) { } } [.("IsIn")] public class IsInAssertion : . @@ -1082,13 +1102,14 @@ namespace .Conditions [.("Collection equivalency uses structural comparison for complex objects, which requ" + "ires reflection and is not compatible with AOT")] [.("IsNotEquivalentTo")] - public class NotEquivalentToAssertion : . + public class NotEquivalentToAssertion : . + where TCollection : . { - public NotEquivalentToAssertion(.<.> context, . notExpected, . ordering = 0) { } + public NotEquivalentToAssertion(. context, . notExpected, . ordering = 0) { } [.("AOT", "IL3050", Justification="Collection equivalency uses structural comparison which requires reflection")] - protected override .<.> CheckAsync(.<.> metadata) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } - public . Using(. comparer) { } + public . Using(. comparer) { } } public class NotNullAssertion : . { @@ -1525,18 +1546,19 @@ namespace . } namespace . { - public class CountWrapper : ., .<.> + public class CountWrapper : ., . + where TCollection : . { - public CountWrapper(.<.> context) { } + public CountWrapper(. context) { } public . Between(int minimum, int maximum, [.("minimum")] string? minExpression = null, [.("maximum")] string? maxExpression = null) { } - public . EqualTo(int expectedCount, [.("expectedCount")] string? expression = null) { } + public . EqualTo(int expectedCount, [.("expectedCount")] string? expression = null) { } public . GreaterThan(int expected, [.("expected")] string? expression = null) { } public . GreaterThanOrEqualTo(int expected, [.("expected")] string? expression = null) { } public . LessThan(int expected, [.("expected")] string? expression = null) { } public . LessThanOrEqualTo(int expected, [.("expected")] string? expression = null) { } public . NotEqualTo(int expected, [.("expected")] string? expression = null) { } public . Positive() { } - public . Zero() { } + public . Zero() { } } public class LengthWrapper : ., . { @@ -1598,8 +1620,10 @@ namespace .Core And = 1, Or = 2, } - public class CollectionAndContinuation : . { } - public class CollectionOrContinuation : . { } + public class CollectionAndContinuation : . + where TCollection : . { } + public class CollectionOrContinuation : . + where TCollection : . { } public class DictionaryAndContinuation : . where TDictionary : . { } public class DictionaryOrContinuation : . @@ -2027,47 +2051,58 @@ namespace .Extensions } public static class CollectionAllAssertionExtensions { - public static . All(this .<.> source, predicate, string predicateDescription, [.("predicate")] string? predicateExpression = null, [.("predicateDescription")] string? predicateDescriptionExpression = null) { } + public static . All(this . source, predicate, string predicateDescription, [.("predicate")] string? predicateExpression = null, [.("predicateDescription")] string? predicateDescriptionExpression = null) + where TCollection : . { } } public static class CollectionAnyAssertionExtensions { - public static . Any(this .<.> source, predicate, string predicateDescription, [.("predicate")] string? predicateExpression = null, [.("predicateDescription")] string? predicateDescriptionExpression = null) { } + public static . Any(this . source, predicate, string predicateDescription, [.("predicate")] string? predicateExpression = null, [.("predicateDescription")] string? predicateDescriptionExpression = null) + where TCollection : . { } } public static class CollectionContainsAssertionExtensions { - public static . Contains(this .<.> source, TItem expected, .? comparer = null, [.("expected")] string? expectedExpression = null, [.("comparer")] string? comparerExpression = null) { } + public static . Contains(this . source, TItem expected, .? comparer = null, [.("expected")] string? expectedExpression = null, [.("comparer")] string? comparerExpression = null) + where TCollection : . { } } public static class CollectionContainsPredicateAssertionExtensions { - public static . Contains(this .<.> source, predicate, [.("predicate")] string? predicateExpression = null) { } + public static . Contains(this . source, predicate, [.("predicate")] string? predicateExpression = null) + where TCollection : . { } } public static class CollectionCountAssertionExtensions { - public static . HasCount(this .<.> source, int expectedCount, [.("expectedCount")] string? expectedCountExpression = null) { } + public static . HasCount(this . source, int expectedCount, [.("expectedCount")] string? expectedCountExpression = null) + where TCollection : . { } } public static class CollectionDoesNotContainAssertionExtensions { - public static . DoesNotContain(this .<.> source, TItem expected, .? comparer = null, [.("expected")] string? expectedExpression = null, [.("comparer")] string? comparerExpression = null) { } + public static . DoesNotContain(this . source, TItem expected, .? comparer = null, [.("expected")] string? expectedExpression = null, [.("comparer")] string? comparerExpression = null) + where TCollection : . { } } public static class CollectionDoesNotContainPredicateAssertionExtensions { - public static . DoesNotContain(this .<.> source, predicate, string predicateDescription, [.("predicate")] string? predicateExpression = null, [.("predicateDescription")] string? predicateDescriptionExpression = null) { } + public static . DoesNotContain(this . source, predicate, string predicateDescription, [.("predicate")] string? predicateExpression = null, [.("predicateDescription")] string? predicateDescriptionExpression = null) + where TCollection : . { } } public static class CollectionIsEmptyAssertionExtensions { - public static . IsEmpty(this .<.> source) { } + public static . IsEmpty(this . source) + where TCollection : . { } } public static class CollectionIsInDescendingOrderAssertionExtensions { - public static . IsInDescendingOrder(this .<.> source) { } + public static . IsInDescendingOrder(this . source) + where TCollection : . { } } public static class CollectionIsInOrderAssertionExtensions { - public static . IsInOrder(this .<.> source) { } + public static . IsInOrder(this . source) + where TCollection : . { } } public static class CollectionIsNotEmptyAssertionExtensions { - public static . IsNotEmpty(this .<.> source) { } + public static . IsNotEmpty(this . source) + where TCollection : . { } } public static class CultureInfoAssertionExtensions { @@ -2755,7 +2790,8 @@ namespace .Extensions } public static class HasSingleItemAssertionExtensions { - public static . HasSingleItem(this .<.> source) { } + public static . HasSingleItem(this . source) + where TCollection : . { } } public static class HttpStatusCodeAssertionExtensions { @@ -2915,10 +2951,12 @@ namespace .Extensions { [.("Collection equivalency uses structural comparison for complex objects, which requ" + "ires reflection and is not compatible with AOT")] - public static . IsEquivalentTo(this .<.> source, . expected, . ordering = 0, [.("expected")] string? expectedExpression = null, [.("ordering")] string? orderingExpression = null) { } + public static . IsEquivalentTo(this . source, . expected, . ordering = 0, [.("expected")] string? expectedExpression = null, [.("ordering")] string? orderingExpression = null) + where TCollection : . { } [.("Collection equivalency uses structural comparison for complex objects, which requ" + "ires reflection and is not compatible with AOT")] - public static . IsEquivalentTo(this .<.> source, . expected, . comparer, . ordering = 0, [.("expected")] string? expectedExpression = null, [.("comparer")] string? comparerExpression = null, [.("ordering")] string? orderingExpression = null) { } + public static . IsEquivalentTo(this . source, . expected, . comparer, . ordering = 0, [.("expected")] string? expectedExpression = null, [.("comparer")] string? comparerExpression = null, [.("ordering")] string? orderingExpression = null) + where TCollection : . { } } public static class IsInAssertionExtensions { @@ -2980,7 +3018,8 @@ namespace .Extensions { [.("Collection equivalency uses structural comparison for complex objects, which requ" + "ires reflection and is not compatible with AOT")] - public static . IsNotEquivalentTo(this .<.> source, . notExpected, . ordering = 0, [.("notExpected")] string? notExpectedExpression = null, [.("ordering")] string? orderingExpression = null) { } + public static . IsNotEquivalentTo(this . source, . notExpected, . ordering = 0, [.("notExpected")] string? notExpectedExpression = null, [.("ordering")] string? orderingExpression = null) + where TCollection : . { } } public static class NotSameReferenceAssertionExtensions { @@ -3766,36 +3805,37 @@ namespace .Sources public . ThrowsExactly() where TException : { } } - public abstract class CollectionAssertionBase : .<.>, ., .<.> - { - protected CollectionAssertionBase(.<.> context) { } - public new . And { get; } - public new . Or { get; } - public . All() { } - public . All( predicate, [.("predicate")] string? expression = null) { } - public . Any( predicate, [.("predicate")] string? expression = null) { } - public . Contains( predicate, [.("predicate")] string? expression = null) { } - public . Contains(TItem expected, [.("expected")] string? expression = null) { } - public . ContainsOnly( predicate, [.("predicate")] string? expression = null) { } - public . Count() { } - public . Count( predicate, [.("predicate")] string? expression = null) { } - public . DoesNotContain( predicate, [.("predicate")] string? expression = null) { } - public . DoesNotContain(TItem expected, [.("expected")] string? expression = null) { } - protected override string GetExpectation() { } - public ..CountWrapper HasCount() { } - public . HasCount(int expectedCount, [.("expectedCount")] string? expression = null) { } - public . HasSingleItem() { } - public . IsEmpty() { } - public . IsInDescendingOrder() { } - public . IsInOrder() { } - public . IsNotEmpty() { } - public . IsOrderedBy( keySelector, [.("keySelector")] string? expression = null) { } - public . IsOrderedBy( keySelector, .? comparer, [.("keySelector")] string? selectorExpression = null, [.("comparer")] string? comparerExpression = null) { } - public . IsOrderedByDescending( keySelector, [.("keySelector")] string? expression = null) { } - public . IsOrderedByDescending( keySelector, .? comparer, [.("keySelector")] string? selectorExpression = null, [.("comparer")] string? comparerExpression = null) { } - public .<., TExpected> IsTypeOf() { } - } - public class CollectionAssertion : . + public abstract class CollectionAssertionBase : ., ., . + where TCollection : . + { + protected CollectionAssertionBase(. context) { } + public new . And { get; } + public new . Or { get; } + public . All() { } + public . All( predicate, [.("predicate")] string? expression = null) { } + public . Any( predicate, [.("predicate")] string? expression = null) { } + public . Contains( predicate, [.("predicate")] string? expression = null) { } + public . Contains(TItem expected, [.("expected")] string? expression = null) { } + public . ContainsOnly( predicate, [.("predicate")] string? expression = null) { } + public . Count() { } + public . Count( predicate, [.("predicate")] string? expression = null) { } + public . DoesNotContain( predicate, [.("predicate")] string? expression = null) { } + public . DoesNotContain(TItem expected, [.("expected")] string? expression = null) { } + protected override string GetExpectation() { } + public ..CountWrapper HasCount() { } + public . HasCount(int expectedCount, [.("expectedCount")] string? expression = null) { } + public . HasSingleItem() { } + public . IsEmpty() { } + public . IsInDescendingOrder() { } + public . IsInOrder() { } + public . IsNotEmpty() { } + public . IsOrderedBy( keySelector, [.("keySelector")] string? expression = null) { } + public . IsOrderedBy( keySelector, .? comparer, [.("keySelector")] string? selectorExpression = null, [.("comparer")] string? comparerExpression = null) { } + public . IsOrderedByDescending( keySelector, [.("keySelector")] string? expression = null) { } + public . IsOrderedByDescending( keySelector, .? comparer, [.("keySelector")] string? selectorExpression = null, [.("comparer")] string? comparerExpression = null) { } + public . IsTypeOf() { } + } + public class CollectionAssertion : .<., TItem> { public CollectionAssertion(. value, string? expression) { } } @@ -3808,25 +3848,16 @@ namespace .Sources public . ThrowsExactly() where TException : { } } - public abstract class DictionaryAssertionBase : ., ., . + public abstract class DictionaryAssertionBase : .> where TDictionary : . { protected DictionaryAssertionBase(. context) { } public new . And { get; } public new . Or { get; } - public .<.> All() { } - public .<.> All(<., bool> predicate, [.("predicate")] string? expression = null) { } - public .<.> Any(<., bool> predicate, [.("predicate")] string? expression = null) { } - public .<.> Contains(. expected, [.("expected")] string? expression = null) { } - public .<.> Contains(<., bool> predicate, [.("predicate")] string? expression = null) { } public . ContainsKey(TKey expectedKey, [.("expectedKey")] string? expression = null) { } public . ContainsKey(TKey expectedKey, .? comparer, [.("expectedKey")] string? keyExpression = null, [.("comparer")] string? comparerExpression = null) { } public . DoesNotContainKey(TKey expectedKey, [.("expectedKey")] string? expression = null) { } protected override string GetExpectation() { } - public ..CountWrapper<.> HasCount() { } - public .<.> HasCount(int expectedCount, [.("expectedCount")] string? expression = null) { } - public .<.> IsEmpty() { } - public .<.> IsNotEmpty() { } } public class DictionaryAssertion : .<., TKey, TValue> { diff --git a/TUnit.PublicAPI/Tests.Assertions_Library_Has_No_API_Changes.DotNet9_0.verified.txt b/TUnit.PublicAPI/Tests.Assertions_Library_Has_No_API_Changes.DotNet9_0.verified.txt index 98f26c15ce..d0f8e8b482 100644 --- a/TUnit.PublicAPI/Tests.Assertions_Library_Has_No_API_Changes.DotNet9_0.verified.txt +++ b/TUnit.PublicAPI/Tests.Assertions_Library_Has_No_API_Changes.DotNet9_0.verified.txt @@ -367,122 +367,140 @@ namespace .Conditions [.("IsWhiteSpace", ExpectationMessage="be whitespace")] public static class CharAssertionExtensions { } [.("All")] - public class CollectionAllAssertion : . + public class CollectionAllAssertion : . + where TCollection : . { - public CollectionAllAssertion(.<.> context, predicate, string predicateDescription) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public CollectionAllAssertion(. context, predicate, string predicateDescription) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } } - public class CollectionAllSatisfyAssertion : . + public class CollectionAllSatisfyAssertion : . + where TCollection : . { - public CollectionAllSatisfyAssertion(.<.> context, <., .?> assertion, string assertionDescription) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public CollectionAllSatisfyAssertion(. context, <., .?> assertion, string assertionDescription) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } } - public class CollectionAllSatisfyHelper + public class CollectionAllSatisfyHelper + where TCollection : . { - public CollectionAllSatisfyHelper(.<.> context) { } - public . Satisfy(<., .?> assertion, [.("assertion")] string? expression = null) { } - public . Satisfy( mapper, <., .?> assertion, [.("mapper")] string? mapperExpression = null, [.("assertion")] string? assertionExpression = null) { } + public CollectionAllSatisfyHelper(. context) { } + public . Satisfy(<., .?> assertion, [.("assertion")] string? expression = null) { } + public . Satisfy( mapper, <., .?> assertion, [.("mapper")] string? mapperExpression = null, [.("assertion")] string? assertionExpression = null) { } } - public class CollectionAllSatisfyMappedAssertion : . + public class CollectionAllSatisfyMappedAssertion : . + where TCollection : . { - public CollectionAllSatisfyMappedAssertion(.<.> context, mapper, <., .?> assertion, string mapperDescription, string assertionDescription) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public CollectionAllSatisfyMappedAssertion(. context, mapper, <., .?> assertion, string mapperDescription, string assertionDescription) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } } [.("Any")] - public class CollectionAnyAssertion : . + public class CollectionAnyAssertion : . + where TCollection : . { - public CollectionAnyAssertion(.<.> context, predicate, string predicateDescription) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public CollectionAnyAssertion(. context, predicate, string predicateDescription) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } } - public abstract class CollectionComparerBasedAssertion : . + public abstract class CollectionComparerBasedAssertion : . + where TCollection : . { - protected CollectionComparerBasedAssertion(.<.> context) { } + protected CollectionComparerBasedAssertion(. context) { } protected . GetComparer() { } protected bool HasCustomComparer() { } protected void SetComparer(. comparer) { } } [.("Contains")] - public class CollectionContainsAssertion : . + public class CollectionContainsAssertion : . + where TCollection : . { - public CollectionContainsAssertion(.<.> context, TItem expected, .? comparer = null) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public CollectionContainsAssertion(. context, TItem expected, .? comparer = null) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } } [.("Contains")] - public class CollectionContainsPredicateAssertion : . + public class CollectionContainsPredicateAssertion : . + where TCollection : . { - public CollectionContainsPredicateAssertion(.<.> context, predicate) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public CollectionContainsPredicateAssertion(. context, predicate) { } + protected override .<.> CheckAsync(. metadata) { } public . GetAwaiter() { } protected override string GetExpectation() { } } [.("HasCount")] - public class CollectionCountAssertion : . + public class CollectionCountAssertion : . + where TCollection : . { - public CollectionCountAssertion(.<.> context, int expectedCount) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public CollectionCountAssertion(. context, int expectedCount) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } } - public class CollectionCountValueAssertion : . + public class CollectionCountValueAssertion : . + where TCollection : . { - public CollectionCountValueAssertion(.<.> collectionContext, ? predicate) { } + public CollectionCountValueAssertion(. collectionContext, ? predicate) { } } [.("DoesNotContain")] - public class CollectionDoesNotContainAssertion : . + public class CollectionDoesNotContainAssertion : . + where TCollection : . { - public CollectionDoesNotContainAssertion(.<.> context, TItem expected, .? comparer = null) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public CollectionDoesNotContainAssertion(. context, TItem expected, .? comparer = null) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } } [.("DoesNotContain")] - public class CollectionDoesNotContainPredicateAssertion : . + public class CollectionDoesNotContainPredicateAssertion : . + where TCollection : . { - public CollectionDoesNotContainPredicateAssertion(.<.> context, predicate, string predicateDescription) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public CollectionDoesNotContainPredicateAssertion(. context, predicate, string predicateDescription) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } } [.("IsEmpty")] - public class CollectionIsEmptyAssertion : . + public class CollectionIsEmptyAssertion : . + where TCollection : . { - public CollectionIsEmptyAssertion(.<.> context) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public CollectionIsEmptyAssertion(. context) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } } [.("IsInDescendingOrder")] - public class CollectionIsInDescendingOrderAssertion : . + public class CollectionIsInDescendingOrderAssertion : . + where TCollection : . { - public CollectionIsInDescendingOrderAssertion(.<.> context) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public CollectionIsInDescendingOrderAssertion(. context) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } } [.("IsInOrder")] - public class CollectionIsInOrderAssertion : . + public class CollectionIsInOrderAssertion : . + where TCollection : . { - public CollectionIsInOrderAssertion(.<.> context) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public CollectionIsInOrderAssertion(. context) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } } [.("IsNotEmpty")] - public class CollectionIsNotEmptyAssertion : . + public class CollectionIsNotEmptyAssertion : . + where TCollection : . { - public CollectionIsNotEmptyAssertion(.<.> context) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public CollectionIsNotEmptyAssertion(. context) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } } - public class CollectionIsOrderedByAssertion : . + public class CollectionIsOrderedByAssertion : . + where TCollection : . { - public CollectionIsOrderedByAssertion(.<.> context, keySelector, .? comparer = null) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public CollectionIsOrderedByAssertion(. context, keySelector, .? comparer = null) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } } - public class CollectionIsOrderedByDescendingAssertion : . + public class CollectionIsOrderedByDescendingAssertion : . + where TCollection : . { - public CollectionIsOrderedByDescendingAssertion(.<.> context, keySelector, .? comparer = null) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public CollectionIsOrderedByDescendingAssertion(. context, keySelector, .? comparer = null) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } } public abstract class ComparerBasedAssertion : . @@ -908,10 +926,11 @@ namespace .Conditions protected override string GetExpectation() { } } [.("HasSingleItem")] - public class HasSingleItemAssertion : . + public class HasSingleItemAssertion : . + where TCollection : . { - public HasSingleItemAssertion(.<.> context) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public HasSingleItemAssertion(. context) { } + protected override .<.> CheckAsync(. metadata) { } public . GetAwaiter() { } protected override string GetExpectation() { } } @@ -980,14 +999,15 @@ namespace .Conditions [.("Collection equivalency uses structural comparison for complex objects, which requ" + "ires reflection and is not compatible with AOT")] [.("IsEquivalentTo")] - public class IsEquivalentToAssertion : . + public class IsEquivalentToAssertion : . + where TCollection : . { - public IsEquivalentToAssertion(.<.> context, . expected, . ordering = 0) { } - public IsEquivalentToAssertion(.<.> context, . expected, . comparer, . ordering = 0) { } + public IsEquivalentToAssertion(. context, . expected, . ordering = 0) { } + public IsEquivalentToAssertion(. context, . expected, . comparer, . ordering = 0) { } [.("AOT", "IL3050", Justification="Collection equivalency uses structural comparison which requires reflection")] - protected override .<.> CheckAsync(.<.> metadata) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } - public . Using(. comparer) { } + public . Using(. comparer) { } } [.("IsIn")] public class IsInAssertion : . @@ -1085,13 +1105,14 @@ namespace .Conditions [.("Collection equivalency uses structural comparison for complex objects, which requ" + "ires reflection and is not compatible with AOT")] [.("IsNotEquivalentTo")] - public class NotEquivalentToAssertion : . + public class NotEquivalentToAssertion : . + where TCollection : . { - public NotEquivalentToAssertion(.<.> context, . notExpected, . ordering = 0) { } + public NotEquivalentToAssertion(. context, . notExpected, . ordering = 0) { } [.("AOT", "IL3050", Justification="Collection equivalency uses structural comparison which requires reflection")] - protected override .<.> CheckAsync(.<.> metadata) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } - public . Using(. comparer) { } + public . Using(. comparer) { } } public class NotNullAssertion : . { @@ -1528,18 +1549,19 @@ namespace . } namespace . { - public class CountWrapper : ., .<.> + public class CountWrapper : ., . + where TCollection : . { - public CountWrapper(.<.> context) { } + public CountWrapper(. context) { } public . Between(int minimum, int maximum, [.("minimum")] string? minExpression = null, [.("maximum")] string? maxExpression = null) { } - public . EqualTo(int expectedCount, [.("expectedCount")] string? expression = null) { } + public . EqualTo(int expectedCount, [.("expectedCount")] string? expression = null) { } public . GreaterThan(int expected, [.("expected")] string? expression = null) { } public . GreaterThanOrEqualTo(int expected, [.("expected")] string? expression = null) { } public . LessThan(int expected, [.("expected")] string? expression = null) { } public . LessThanOrEqualTo(int expected, [.("expected")] string? expression = null) { } public . NotEqualTo(int expected, [.("expected")] string? expression = null) { } public . Positive() { } - public . Zero() { } + public . Zero() { } } public class LengthWrapper : ., . { @@ -1601,8 +1623,10 @@ namespace .Core And = 1, Or = 2, } - public class CollectionAndContinuation : . { } - public class CollectionOrContinuation : . { } + public class CollectionAndContinuation : . + where TCollection : . { } + public class CollectionOrContinuation : . + where TCollection : . { } public class DictionaryAndContinuation : . where TDictionary : . { } public class DictionaryOrContinuation : . @@ -2030,47 +2054,58 @@ namespace .Extensions } public static class CollectionAllAssertionExtensions { - public static . All(this .<.> source, predicate, string predicateDescription, [.("predicate")] string? predicateExpression = null, [.("predicateDescription")] string? predicateDescriptionExpression = null) { } + public static . All(this . source, predicate, string predicateDescription, [.("predicate")] string? predicateExpression = null, [.("predicateDescription")] string? predicateDescriptionExpression = null) + where TCollection : . { } } public static class CollectionAnyAssertionExtensions { - public static . Any(this .<.> source, predicate, string predicateDescription, [.("predicate")] string? predicateExpression = null, [.("predicateDescription")] string? predicateDescriptionExpression = null) { } + public static . Any(this . source, predicate, string predicateDescription, [.("predicate")] string? predicateExpression = null, [.("predicateDescription")] string? predicateDescriptionExpression = null) + where TCollection : . { } } public static class CollectionContainsAssertionExtensions { - public static . Contains(this .<.> source, TItem expected, .? comparer = null, [.("expected")] string? expectedExpression = null, [.("comparer")] string? comparerExpression = null) { } + public static . Contains(this . source, TItem expected, .? comparer = null, [.("expected")] string? expectedExpression = null, [.("comparer")] string? comparerExpression = null) + where TCollection : . { } } public static class CollectionContainsPredicateAssertionExtensions { - public static . Contains(this .<.> source, predicate, [.("predicate")] string? predicateExpression = null) { } + public static . Contains(this . source, predicate, [.("predicate")] string? predicateExpression = null) + where TCollection : . { } } public static class CollectionCountAssertionExtensions { - public static . HasCount(this .<.> source, int expectedCount, [.("expectedCount")] string? expectedCountExpression = null) { } + public static . HasCount(this . source, int expectedCount, [.("expectedCount")] string? expectedCountExpression = null) + where TCollection : . { } } public static class CollectionDoesNotContainAssertionExtensions { - public static . DoesNotContain(this .<.> source, TItem expected, .? comparer = null, [.("expected")] string? expectedExpression = null, [.("comparer")] string? comparerExpression = null) { } + public static . DoesNotContain(this . source, TItem expected, .? comparer = null, [.("expected")] string? expectedExpression = null, [.("comparer")] string? comparerExpression = null) + where TCollection : . { } } public static class CollectionDoesNotContainPredicateAssertionExtensions { - public static . DoesNotContain(this .<.> source, predicate, string predicateDescription, [.("predicate")] string? predicateExpression = null, [.("predicateDescription")] string? predicateDescriptionExpression = null) { } + public static . DoesNotContain(this . source, predicate, string predicateDescription, [.("predicate")] string? predicateExpression = null, [.("predicateDescription")] string? predicateDescriptionExpression = null) + where TCollection : . { } } public static class CollectionIsEmptyAssertionExtensions { - public static . IsEmpty(this .<.> source) { } + public static . IsEmpty(this . source) + where TCollection : . { } } public static class CollectionIsInDescendingOrderAssertionExtensions { - public static . IsInDescendingOrder(this .<.> source) { } + public static . IsInDescendingOrder(this . source) + where TCollection : . { } } public static class CollectionIsInOrderAssertionExtensions { - public static . IsInOrder(this .<.> source) { } + public static . IsInOrder(this . source) + where TCollection : . { } } public static class CollectionIsNotEmptyAssertionExtensions { - public static . IsNotEmpty(this .<.> source) { } + public static . IsNotEmpty(this . source) + where TCollection : . { } } public static class CultureInfoAssertionExtensions { @@ -2763,7 +2798,8 @@ namespace .Extensions } public static class HasSingleItemAssertionExtensions { - public static . HasSingleItem(this .<.> source) { } + public static . HasSingleItem(this . source) + where TCollection : . { } } public static class HttpStatusCodeAssertionExtensions { @@ -2924,10 +2960,12 @@ namespace .Extensions { [.("Collection equivalency uses structural comparison for complex objects, which requ" + "ires reflection and is not compatible with AOT")] - public static . IsEquivalentTo(this .<.> source, . expected, . ordering = 0, [.("expected")] string? expectedExpression = null, [.("ordering")] string? orderingExpression = null) { } + public static . IsEquivalentTo(this . source, . expected, . ordering = 0, [.("expected")] string? expectedExpression = null, [.("ordering")] string? orderingExpression = null) + where TCollection : . { } [.("Collection equivalency uses structural comparison for complex objects, which requ" + "ires reflection and is not compatible with AOT")] - public static . IsEquivalentTo(this .<.> source, . expected, . comparer, . ordering = 0, [.("expected")] string? expectedExpression = null, [.("comparer")] string? comparerExpression = null, [.("ordering")] string? orderingExpression = null) { } + public static . IsEquivalentTo(this . source, . expected, . comparer, . ordering = 0, [.("expected")] string? expectedExpression = null, [.("comparer")] string? comparerExpression = null, [.("ordering")] string? orderingExpression = null) + where TCollection : . { } } public static class IsInAssertionExtensions { @@ -2990,7 +3028,8 @@ namespace .Extensions { [.("Collection equivalency uses structural comparison for complex objects, which requ" + "ires reflection and is not compatible with AOT")] - public static . IsNotEquivalentTo(this .<.> source, . notExpected, . ordering = 0, [.("notExpected")] string? notExpectedExpression = null, [.("ordering")] string? orderingExpression = null) { } + public static . IsNotEquivalentTo(this . source, . notExpected, . ordering = 0, [.("notExpected")] string? notExpectedExpression = null, [.("ordering")] string? orderingExpression = null) + where TCollection : . { } } public static class NotSameReferenceAssertionExtensions { @@ -3779,36 +3818,37 @@ namespace .Sources public . ThrowsExactly() where TException : { } } - public abstract class CollectionAssertionBase : .<.>, ., .<.> - { - protected CollectionAssertionBase(.<.> context) { } - public new . And { get; } - public new . Or { get; } - public . All() { } - public . All( predicate, [.("predicate")] string? expression = null) { } - public . Any( predicate, [.("predicate")] string? expression = null) { } - public . Contains( predicate, [.("predicate")] string? expression = null) { } - public . Contains(TItem expected, [.("expected")] string? expression = null) { } - public . ContainsOnly( predicate, [.("predicate")] string? expression = null) { } - public . Count() { } - public . Count( predicate, [.("predicate")] string? expression = null) { } - public . DoesNotContain( predicate, [.("predicate")] string? expression = null) { } - public . DoesNotContain(TItem expected, [.("expected")] string? expression = null) { } - protected override string GetExpectation() { } - public ..CountWrapper HasCount() { } - public . HasCount(int expectedCount, [.("expectedCount")] string? expression = null) { } - public . HasSingleItem() { } - public . IsEmpty() { } - public . IsInDescendingOrder() { } - public . IsInOrder() { } - public . IsNotEmpty() { } - public . IsOrderedBy( keySelector, [.("keySelector")] string? expression = null) { } - public . IsOrderedBy( keySelector, .? comparer, [.("keySelector")] string? selectorExpression = null, [.("comparer")] string? comparerExpression = null) { } - public . IsOrderedByDescending( keySelector, [.("keySelector")] string? expression = null) { } - public . IsOrderedByDescending( keySelector, .? comparer, [.("keySelector")] string? selectorExpression = null, [.("comparer")] string? comparerExpression = null) { } - public .<., TExpected> IsTypeOf() { } - } - public class CollectionAssertion : . + public abstract class CollectionAssertionBase : ., ., . + where TCollection : . + { + protected CollectionAssertionBase(. context) { } + public new . And { get; } + public new . Or { get; } + public . All() { } + public . All( predicate, [.("predicate")] string? expression = null) { } + public . Any( predicate, [.("predicate")] string? expression = null) { } + public . Contains( predicate, [.("predicate")] string? expression = null) { } + public . Contains(TItem expected, [.("expected")] string? expression = null) { } + public . ContainsOnly( predicate, [.("predicate")] string? expression = null) { } + public . Count() { } + public . Count( predicate, [.("predicate")] string? expression = null) { } + public . DoesNotContain( predicate, [.("predicate")] string? expression = null) { } + public . DoesNotContain(TItem expected, [.("expected")] string? expression = null) { } + protected override string GetExpectation() { } + public ..CountWrapper HasCount() { } + public . HasCount(int expectedCount, [.("expectedCount")] string? expression = null) { } + public . HasSingleItem() { } + public . IsEmpty() { } + public . IsInDescendingOrder() { } + public . IsInOrder() { } + public . IsNotEmpty() { } + public . IsOrderedBy( keySelector, [.("keySelector")] string? expression = null) { } + public . IsOrderedBy( keySelector, .? comparer, [.("keySelector")] string? selectorExpression = null, [.("comparer")] string? comparerExpression = null) { } + public . IsOrderedByDescending( keySelector, [.("keySelector")] string? expression = null) { } + public . IsOrderedByDescending( keySelector, .? comparer, [.("keySelector")] string? selectorExpression = null, [.("comparer")] string? comparerExpression = null) { } + public . IsTypeOf() { } + } + public class CollectionAssertion : .<., TItem> { public CollectionAssertion(. value, string? expression) { } } @@ -3821,25 +3861,16 @@ namespace .Sources public . ThrowsExactly() where TException : { } } - public abstract class DictionaryAssertionBase : ., ., . + public abstract class DictionaryAssertionBase : .> where TDictionary : . { protected DictionaryAssertionBase(. context) { } public new . And { get; } public new . Or { get; } - public .<.> All() { } - public .<.> All(<., bool> predicate, [.("predicate")] string? expression = null) { } - public .<.> Any(<., bool> predicate, [.("predicate")] string? expression = null) { } - public .<.> Contains(. expected, [.("expected")] string? expression = null) { } - public .<.> Contains(<., bool> predicate, [.("predicate")] string? expression = null) { } public . ContainsKey(TKey expectedKey, [.("expectedKey")] string? expression = null) { } public . ContainsKey(TKey expectedKey, .? comparer, [.("expectedKey")] string? keyExpression = null, [.("comparer")] string? comparerExpression = null) { } public . DoesNotContainKey(TKey expectedKey, [.("expectedKey")] string? expression = null) { } protected override string GetExpectation() { } - public ..CountWrapper<.> HasCount() { } - public .<.> HasCount(int expectedCount, [.("expectedCount")] string? expression = null) { } - public .<.> IsEmpty() { } - public .<.> IsNotEmpty() { } } public class DictionaryAssertion : .<., TKey, TValue> { diff --git a/TUnit.PublicAPI/Tests.Assertions_Library_Has_No_API_Changes.Net4_7.verified.txt b/TUnit.PublicAPI/Tests.Assertions_Library_Has_No_API_Changes.Net4_7.verified.txt index 96fa125ba7..6f0410a106 100644 --- a/TUnit.PublicAPI/Tests.Assertions_Library_Has_No_API_Changes.Net4_7.verified.txt +++ b/TUnit.PublicAPI/Tests.Assertions_Library_Has_No_API_Changes.Net4_7.verified.txt @@ -362,122 +362,140 @@ namespace .Conditions [.("IsWhiteSpace", ExpectationMessage="be whitespace")] public static class CharAssertionExtensions { } [.("All")] - public class CollectionAllAssertion : . + public class CollectionAllAssertion : . + where TCollection : . { - public CollectionAllAssertion(.<.> context, predicate, string predicateDescription) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public CollectionAllAssertion(. context, predicate, string predicateDescription) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } } - public class CollectionAllSatisfyAssertion : . + public class CollectionAllSatisfyAssertion : . + where TCollection : . { - public CollectionAllSatisfyAssertion(.<.> context, <., .?> assertion, string assertionDescription) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public CollectionAllSatisfyAssertion(. context, <., .?> assertion, string assertionDescription) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } } - public class CollectionAllSatisfyHelper + public class CollectionAllSatisfyHelper + where TCollection : . { - public CollectionAllSatisfyHelper(.<.> context) { } - public . Satisfy(<., .?> assertion, [.("assertion")] string? expression = null) { } - public . Satisfy( mapper, <., .?> assertion, [.("mapper")] string? mapperExpression = null, [.("assertion")] string? assertionExpression = null) { } + public CollectionAllSatisfyHelper(. context) { } + public . Satisfy(<., .?> assertion, [.("assertion")] string? expression = null) { } + public . Satisfy( mapper, <., .?> assertion, [.("mapper")] string? mapperExpression = null, [.("assertion")] string? assertionExpression = null) { } } - public class CollectionAllSatisfyMappedAssertion : . + public class CollectionAllSatisfyMappedAssertion : . + where TCollection : . { - public CollectionAllSatisfyMappedAssertion(.<.> context, mapper, <., .?> assertion, string mapperDescription, string assertionDescription) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public CollectionAllSatisfyMappedAssertion(. context, mapper, <., .?> assertion, string mapperDescription, string assertionDescription) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } } [.("Any")] - public class CollectionAnyAssertion : . + public class CollectionAnyAssertion : . + where TCollection : . { - public CollectionAnyAssertion(.<.> context, predicate, string predicateDescription) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public CollectionAnyAssertion(. context, predicate, string predicateDescription) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } } - public abstract class CollectionComparerBasedAssertion : . + public abstract class CollectionComparerBasedAssertion : . + where TCollection : . { - protected CollectionComparerBasedAssertion(.<.> context) { } + protected CollectionComparerBasedAssertion(. context) { } protected . GetComparer() { } protected bool HasCustomComparer() { } protected void SetComparer(. comparer) { } } [.("Contains")] - public class CollectionContainsAssertion : . + public class CollectionContainsAssertion : . + where TCollection : . { - public CollectionContainsAssertion(.<.> context, TItem expected, .? comparer = null) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public CollectionContainsAssertion(. context, TItem expected, .? comparer = null) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } } [.("Contains")] - public class CollectionContainsPredicateAssertion : . + public class CollectionContainsPredicateAssertion : . + where TCollection : . { - public CollectionContainsPredicateAssertion(.<.> context, predicate) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public CollectionContainsPredicateAssertion(. context, predicate) { } + protected override .<.> CheckAsync(. metadata) { } public . GetAwaiter() { } protected override string GetExpectation() { } } [.("HasCount")] - public class CollectionCountAssertion : . + public class CollectionCountAssertion : . + where TCollection : . { - public CollectionCountAssertion(.<.> context, int expectedCount) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public CollectionCountAssertion(. context, int expectedCount) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } } - public class CollectionCountValueAssertion : . + public class CollectionCountValueAssertion : . + where TCollection : . { - public CollectionCountValueAssertion(.<.> collectionContext, ? predicate) { } + public CollectionCountValueAssertion(. collectionContext, ? predicate) { } } [.("DoesNotContain")] - public class CollectionDoesNotContainAssertion : . + public class CollectionDoesNotContainAssertion : . + where TCollection : . { - public CollectionDoesNotContainAssertion(.<.> context, TItem expected, .? comparer = null) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public CollectionDoesNotContainAssertion(. context, TItem expected, .? comparer = null) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } } [.("DoesNotContain")] - public class CollectionDoesNotContainPredicateAssertion : . + public class CollectionDoesNotContainPredicateAssertion : . + where TCollection : . { - public CollectionDoesNotContainPredicateAssertion(.<.> context, predicate, string predicateDescription) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public CollectionDoesNotContainPredicateAssertion(. context, predicate, string predicateDescription) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } } [.("IsEmpty")] - public class CollectionIsEmptyAssertion : . + public class CollectionIsEmptyAssertion : . + where TCollection : . { - public CollectionIsEmptyAssertion(.<.> context) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public CollectionIsEmptyAssertion(. context) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } } [.("IsInDescendingOrder")] - public class CollectionIsInDescendingOrderAssertion : . + public class CollectionIsInDescendingOrderAssertion : . + where TCollection : . { - public CollectionIsInDescendingOrderAssertion(.<.> context) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public CollectionIsInDescendingOrderAssertion(. context) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } } [.("IsInOrder")] - public class CollectionIsInOrderAssertion : . + public class CollectionIsInOrderAssertion : . + where TCollection : . { - public CollectionIsInOrderAssertion(.<.> context) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public CollectionIsInOrderAssertion(. context) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } } [.("IsNotEmpty")] - public class CollectionIsNotEmptyAssertion : . + public class CollectionIsNotEmptyAssertion : . + where TCollection : . { - public CollectionIsNotEmptyAssertion(.<.> context) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public CollectionIsNotEmptyAssertion(. context) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } } - public class CollectionIsOrderedByAssertion : . + public class CollectionIsOrderedByAssertion : . + where TCollection : . { - public CollectionIsOrderedByAssertion(.<.> context, keySelector, .? comparer = null) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public CollectionIsOrderedByAssertion(. context, keySelector, .? comparer = null) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } } - public class CollectionIsOrderedByDescendingAssertion : . + public class CollectionIsOrderedByDescendingAssertion : . + where TCollection : . { - public CollectionIsOrderedByDescendingAssertion(.<.> context, keySelector, .? comparer = null) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public CollectionIsOrderedByDescendingAssertion(. context, keySelector, .? comparer = null) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } } public abstract class ComparerBasedAssertion : . @@ -864,10 +882,11 @@ namespace .Conditions protected override string GetExpectation() { } } [.("HasSingleItem")] - public class HasSingleItemAssertion : . + public class HasSingleItemAssertion : . + where TCollection : . { - public HasSingleItemAssertion(.<.> context) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public HasSingleItemAssertion(. context) { } + protected override .<.> CheckAsync(. metadata) { } public . GetAwaiter() { } protected override string GetExpectation() { } } @@ -931,13 +950,14 @@ namespace .Conditions public . Using(. comparer) { } } [.("IsEquivalentTo")] - public class IsEquivalentToAssertion : . + public class IsEquivalentToAssertion : . + where TCollection : . { - public IsEquivalentToAssertion(.<.> context, . expected, . ordering = 0) { } - public IsEquivalentToAssertion(.<.> context, . expected, . comparer, . ordering = 0) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public IsEquivalentToAssertion(. context, . expected, . ordering = 0) { } + public IsEquivalentToAssertion(. context, . expected, . comparer, . ordering = 0) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } - public . Using(. comparer) { } + public . Using(. comparer) { } } [.("IsIn")] public class IsInAssertion : . @@ -1031,12 +1051,13 @@ namespace .Conditions public . IgnoringType() { } } [.("IsNotEquivalentTo")] - public class NotEquivalentToAssertion : . + public class NotEquivalentToAssertion : . + where TCollection : . { - public NotEquivalentToAssertion(.<.> context, . notExpected, . ordering = 0) { } - protected override .<.> CheckAsync(.<.> metadata) { } + public NotEquivalentToAssertion(. context, . notExpected, . ordering = 0) { } + protected override .<.> CheckAsync(. metadata) { } protected override string GetExpectation() { } - public . Using(. comparer) { } + public . Using(. comparer) { } } public class NotNullAssertion : . { @@ -1429,18 +1450,19 @@ namespace . } namespace . { - public class CountWrapper : ., .<.> + public class CountWrapper : ., . + where TCollection : . { - public CountWrapper(.<.> context) { } + public CountWrapper(. context) { } public . Between(int minimum, int maximum, [.("minimum")] string? minExpression = null, [.("maximum")] string? maxExpression = null) { } - public . EqualTo(int expectedCount, [.("expectedCount")] string? expression = null) { } + public . EqualTo(int expectedCount, [.("expectedCount")] string? expression = null) { } public . GreaterThan(int expected, [.("expected")] string? expression = null) { } public . GreaterThanOrEqualTo(int expected, [.("expected")] string? expression = null) { } public . LessThan(int expected, [.("expected")] string? expression = null) { } public . LessThanOrEqualTo(int expected, [.("expected")] string? expression = null) { } public . NotEqualTo(int expected, [.("expected")] string? expression = null) { } public . Positive() { } - public . Zero() { } + public . Zero() { } } public class LengthWrapper : ., . { @@ -1502,8 +1524,10 @@ namespace .Core And = 1, Or = 2, } - public class CollectionAndContinuation : . { } - public class CollectionOrContinuation : . { } + public class CollectionAndContinuation : . + where TCollection : . { } + public class CollectionOrContinuation : . + where TCollection : . { } public class DictionaryAndContinuation : . where TDictionary : . { } public class DictionaryOrContinuation : . @@ -1909,47 +1933,58 @@ namespace .Extensions } public static class CollectionAllAssertionExtensions { - public static . All(this .<.> source, predicate, string predicateDescription, [.("predicate")] string? predicateExpression = null, [.("predicateDescription")] string? predicateDescriptionExpression = null) { } + public static . All(this . source, predicate, string predicateDescription, [.("predicate")] string? predicateExpression = null, [.("predicateDescription")] string? predicateDescriptionExpression = null) + where TCollection : . { } } public static class CollectionAnyAssertionExtensions { - public static . Any(this .<.> source, predicate, string predicateDescription, [.("predicate")] string? predicateExpression = null, [.("predicateDescription")] string? predicateDescriptionExpression = null) { } + public static . Any(this . source, predicate, string predicateDescription, [.("predicate")] string? predicateExpression = null, [.("predicateDescription")] string? predicateDescriptionExpression = null) + where TCollection : . { } } public static class CollectionContainsAssertionExtensions { - public static . Contains(this .<.> source, TItem expected, .? comparer = null, [.("expected")] string? expectedExpression = null, [.("comparer")] string? comparerExpression = null) { } + public static . Contains(this . source, TItem expected, .? comparer = null, [.("expected")] string? expectedExpression = null, [.("comparer")] string? comparerExpression = null) + where TCollection : . { } } public static class CollectionContainsPredicateAssertionExtensions { - public static . Contains(this .<.> source, predicate, [.("predicate")] string? predicateExpression = null) { } + public static . Contains(this . source, predicate, [.("predicate")] string? predicateExpression = null) + where TCollection : . { } } public static class CollectionCountAssertionExtensions { - public static . HasCount(this .<.> source, int expectedCount, [.("expectedCount")] string? expectedCountExpression = null) { } + public static . HasCount(this . source, int expectedCount, [.("expectedCount")] string? expectedCountExpression = null) + where TCollection : . { } } public static class CollectionDoesNotContainAssertionExtensions { - public static . DoesNotContain(this .<.> source, TItem expected, .? comparer = null, [.("expected")] string? expectedExpression = null, [.("comparer")] string? comparerExpression = null) { } + public static . DoesNotContain(this . source, TItem expected, .? comparer = null, [.("expected")] string? expectedExpression = null, [.("comparer")] string? comparerExpression = null) + where TCollection : . { } } public static class CollectionDoesNotContainPredicateAssertionExtensions { - public static . DoesNotContain(this .<.> source, predicate, string predicateDescription, [.("predicate")] string? predicateExpression = null, [.("predicateDescription")] string? predicateDescriptionExpression = null) { } + public static . DoesNotContain(this . source, predicate, string predicateDescription, [.("predicate")] string? predicateExpression = null, [.("predicateDescription")] string? predicateDescriptionExpression = null) + where TCollection : . { } } public static class CollectionIsEmptyAssertionExtensions { - public static . IsEmpty(this .<.> source) { } + public static . IsEmpty(this . source) + where TCollection : . { } } public static class CollectionIsInDescendingOrderAssertionExtensions { - public static . IsInDescendingOrder(this .<.> source) { } + public static . IsInDescendingOrder(this . source) + where TCollection : . { } } public static class CollectionIsInOrderAssertionExtensions { - public static . IsInOrder(this .<.> source) { } + public static . IsInOrder(this . source) + where TCollection : . { } } public static class CollectionIsNotEmptyAssertionExtensions { - public static . IsNotEmpty(this .<.> source) { } + public static . IsNotEmpty(this . source) + where TCollection : . { } } public static class CultureInfoAssertionExtensions { @@ -2560,7 +2595,8 @@ namespace .Extensions } public static class HasSingleItemAssertionExtensions { - public static . HasSingleItem(this .<.> source) { } + public static . HasSingleItem(this . source) + where TCollection : . { } } public static class HttpStatusCodeAssertionExtensions { @@ -2705,8 +2741,10 @@ namespace .Extensions } public static class IsEquivalentToAssertionExtensions { - public static . IsEquivalentTo(this .<.> source, . expected, . ordering = 0, [.("expected")] string? expectedExpression = null, [.("ordering")] string? orderingExpression = null) { } - public static . IsEquivalentTo(this .<.> source, . expected, . comparer, . ordering = 0, [.("expected")] string? expectedExpression = null, [.("comparer")] string? comparerExpression = null, [.("ordering")] string? orderingExpression = null) { } + public static . IsEquivalentTo(this . source, . expected, . ordering = 0, [.("expected")] string? expectedExpression = null, [.("ordering")] string? orderingExpression = null) + where TCollection : . { } + public static . IsEquivalentTo(this . source, . expected, . comparer, . ordering = 0, [.("expected")] string? expectedExpression = null, [.("comparer")] string? comparerExpression = null, [.("ordering")] string? orderingExpression = null) + where TCollection : . { } } public static class IsInAssertionExtensions { @@ -2762,7 +2800,8 @@ namespace .Extensions } public static class NotEquivalentToAssertionExtensions { - public static . IsNotEquivalentTo(this .<.> source, . notExpected, . ordering = 0, [.("notExpected")] string? notExpectedExpression = null, [.("ordering")] string? orderingExpression = null) { } + public static . IsNotEquivalentTo(this . source, . notExpected, . ordering = 0, [.("notExpected")] string? notExpectedExpression = null, [.("ordering")] string? orderingExpression = null) + where TCollection : . { } } public static class NotSameReferenceAssertionExtensions { @@ -3436,36 +3475,37 @@ namespace .Sources public . ThrowsExactly() where TException : { } } - public abstract class CollectionAssertionBase : .<.>, ., .<.> - { - protected CollectionAssertionBase(.<.> context) { } - public new . And { get; } - public new . Or { get; } - public . All() { } - public . All( predicate, [.("predicate")] string? expression = null) { } - public . Any( predicate, [.("predicate")] string? expression = null) { } - public . Contains( predicate, [.("predicate")] string? expression = null) { } - public . Contains(TItem expected, [.("expected")] string? expression = null) { } - public . ContainsOnly( predicate, [.("predicate")] string? expression = null) { } - public . Count() { } - public . Count( predicate, [.("predicate")] string? expression = null) { } - public . DoesNotContain( predicate, [.("predicate")] string? expression = null) { } - public . DoesNotContain(TItem expected, [.("expected")] string? expression = null) { } - protected override string GetExpectation() { } - public ..CountWrapper HasCount() { } - public . HasCount(int expectedCount, [.("expectedCount")] string? expression = null) { } - public . HasSingleItem() { } - public . IsEmpty() { } - public . IsInDescendingOrder() { } - public . IsInOrder() { } - public . IsNotEmpty() { } - public . IsOrderedBy( keySelector, [.("keySelector")] string? expression = null) { } - public . IsOrderedBy( keySelector, .? comparer, [.("keySelector")] string? selectorExpression = null, [.("comparer")] string? comparerExpression = null) { } - public . IsOrderedByDescending( keySelector, [.("keySelector")] string? expression = null) { } - public . IsOrderedByDescending( keySelector, .? comparer, [.("keySelector")] string? selectorExpression = null, [.("comparer")] string? comparerExpression = null) { } - public .<., TExpected> IsTypeOf() { } - } - public class CollectionAssertion : . + public abstract class CollectionAssertionBase : ., ., . + where TCollection : . + { + protected CollectionAssertionBase(. context) { } + public new . And { get; } + public new . Or { get; } + public . All() { } + public . All( predicate, [.("predicate")] string? expression = null) { } + public . Any( predicate, [.("predicate")] string? expression = null) { } + public . Contains( predicate, [.("predicate")] string? expression = null) { } + public . Contains(TItem expected, [.("expected")] string? expression = null) { } + public . ContainsOnly( predicate, [.("predicate")] string? expression = null) { } + public . Count() { } + public . Count( predicate, [.("predicate")] string? expression = null) { } + public . DoesNotContain( predicate, [.("predicate")] string? expression = null) { } + public . DoesNotContain(TItem expected, [.("expected")] string? expression = null) { } + protected override string GetExpectation() { } + public ..CountWrapper HasCount() { } + public . HasCount(int expectedCount, [.("expectedCount")] string? expression = null) { } + public . HasSingleItem() { } + public . IsEmpty() { } + public . IsInDescendingOrder() { } + public . IsInOrder() { } + public . IsNotEmpty() { } + public . IsOrderedBy( keySelector, [.("keySelector")] string? expression = null) { } + public . IsOrderedBy( keySelector, .? comparer, [.("keySelector")] string? selectorExpression = null, [.("comparer")] string? comparerExpression = null) { } + public . IsOrderedByDescending( keySelector, [.("keySelector")] string? expression = null) { } + public . IsOrderedByDescending( keySelector, .? comparer, [.("keySelector")] string? selectorExpression = null, [.("comparer")] string? comparerExpression = null) { } + public . IsTypeOf() { } + } + public class CollectionAssertion : .<., TItem> { public CollectionAssertion(. value, string? expression) { } } @@ -3478,25 +3518,16 @@ namespace .Sources public . ThrowsExactly() where TException : { } } - public abstract class DictionaryAssertionBase : ., ., . + public abstract class DictionaryAssertionBase : .> where TDictionary : . { protected DictionaryAssertionBase(. context) { } public new . And { get; } public new . Or { get; } - public .<.> All() { } - public .<.> All(<., bool> predicate, [.("predicate")] string? expression = null) { } - public .<.> Any(<., bool> predicate, [.("predicate")] string? expression = null) { } - public .<.> Contains(. expected, [.("expected")] string? expression = null) { } - public .<.> Contains(<., bool> predicate, [.("predicate")] string? expression = null) { } public . ContainsKey(TKey expectedKey, [.("expectedKey")] string? expression = null) { } public . ContainsKey(TKey expectedKey, .? comparer, [.("expectedKey")] string? keyExpression = null, [.("comparer")] string? comparerExpression = null) { } public . DoesNotContainKey(TKey expectedKey, [.("expectedKey")] string? expression = null) { } protected override string GetExpectation() { } - public ..CountWrapper<.> HasCount() { } - public .<.> HasCount(int expectedCount, [.("expectedCount")] string? expression = null) { } - public .<.> IsEmpty() { } - public .<.> IsNotEmpty() { } } public class DictionaryAssertion : .<., TKey, TValue> {