@@ -117,6 +117,61 @@ public ShouldAssertion<IReadOnlyDictionary<TKey, TValue>> AnyValue(
117117 var inner = ApplyBecause ( new DictionaryAnyValueAssertion < IReadOnlyDictionary < TKey , TValue > , TKey , TValue > ( Context , predicate ) ) ;
118118 return new ShouldAssertion < IReadOnlyDictionary < TKey , TValue > > ( Context , inner ) ;
119119 }
120+
121+ // The count/size methods below are hand-written because the source DictionaryAssertion shadows the
122+ // inherited collection methods (IsEmpty, HasSingleItem, ...) with dictionary-typed `public new`
123+ // overloads whose abstract return type the Should generator can't construct. Without these the
124+ // generated Be/Have counterparts would silently disappear from the dictionary Should surface.
125+
126+ public ShouldAssertion < IReadOnlyDictionary < TKey , TValue > > BeEmpty ( )
127+ {
128+ Context . ExpressionBuilder . Append ( ".BeEmpty()" ) ;
129+ var inner = ApplyBecause ( new CollectionIsEmptyAssertion < IReadOnlyDictionary < TKey , TValue > , KeyValuePair < TKey , TValue > > ( Context ) ) ;
130+ return new ShouldAssertion < IReadOnlyDictionary < TKey , TValue > > ( Context , inner ) ;
131+ }
132+
133+ public ShouldAssertion < IReadOnlyDictionary < TKey , TValue > > NotBeEmpty ( )
134+ {
135+ Context . ExpressionBuilder . Append ( ".NotBeEmpty()" ) ;
136+ var inner = ApplyBecause ( new CollectionIsNotEmptyAssertion < IReadOnlyDictionary < TKey , TValue > , KeyValuePair < TKey , TValue > > ( Context ) ) ;
137+ return new ShouldAssertion < IReadOnlyDictionary < TKey , TValue > > ( Context , inner ) ;
138+ }
139+
140+ public ShouldAssertion < IReadOnlyDictionary < TKey , TValue > > HaveSingleItem ( )
141+ {
142+ Context . ExpressionBuilder . Append ( ".HaveSingleItem()" ) ;
143+ var inner = ApplyBecause ( new HasSingleItemAssertion < IReadOnlyDictionary < TKey , TValue > , KeyValuePair < TKey , TValue > > ( Context ) ) ;
144+ return new ShouldAssertion < IReadOnlyDictionary < TKey , TValue > > ( Context , inner ) ;
145+ }
146+
147+ public ShouldAssertion < IReadOnlyDictionary < TKey , TValue > > HaveAtLeast (
148+ int minCount ,
149+ [ CallerArgumentExpression ( nameof ( minCount ) ) ] string ? expression = null )
150+ {
151+ Context . ExpressionBuilder . Append ( ".HaveAtLeast(" ) . Append ( expression ) . Append ( ')' ) ;
152+ var inner = ApplyBecause ( new CollectionHasAtLeastAssertion < IReadOnlyDictionary < TKey , TValue > , KeyValuePair < TKey , TValue > > ( Context , minCount ) ) ;
153+ return new ShouldAssertion < IReadOnlyDictionary < TKey , TValue > > ( Context , inner ) ;
154+ }
155+
156+ public ShouldAssertion < IReadOnlyDictionary < TKey , TValue > > HaveAtMost (
157+ int maxCount ,
158+ [ CallerArgumentExpression ( nameof ( maxCount ) ) ] string ? expression = null )
159+ {
160+ Context . ExpressionBuilder . Append ( ".HaveAtMost(" ) . Append ( expression ) . Append ( ')' ) ;
161+ var inner = ApplyBecause ( new CollectionHasAtMostAssertion < IReadOnlyDictionary < TKey , TValue > , KeyValuePair < TKey , TValue > > ( Context , maxCount ) ) ;
162+ return new ShouldAssertion < IReadOnlyDictionary < TKey , TValue > > ( Context , inner ) ;
163+ }
164+
165+ public ShouldAssertion < IReadOnlyDictionary < TKey , TValue > > HaveCountBetween (
166+ int min ,
167+ int max ,
168+ [ CallerArgumentExpression ( nameof ( min ) ) ] string ? minExpression = null ,
169+ [ CallerArgumentExpression ( nameof ( max ) ) ] string ? maxExpression = null )
170+ {
171+ Context . ExpressionBuilder . Append ( $ ".HaveCountBetween({ minExpression } , { maxExpression } )") ;
172+ var inner = ApplyBecause ( new CollectionHasCountBetweenAssertion < IReadOnlyDictionary < TKey , TValue > , KeyValuePair < TKey , TValue > > ( Context , min , max ) ) ;
173+ return new ShouldAssertion < IReadOnlyDictionary < TKey , TValue > > ( Context , inner ) ;
174+ }
120175}
121176
122177[ ShouldGeneratePartial ( typeof ( MutableDictionaryAssertion < , > ) ) ]
@@ -228,4 +283,57 @@ public ShouldAssertion<IDictionary<TKey, TValue>> AnyValue(
228283 var inner = ApplyBecause ( new MutableDictionaryAnyValueAssertion < IDictionary < TKey , TValue > , TKey , TValue > ( Context , predicate ) ) ;
229284 return new ShouldAssertion < IDictionary < TKey , TValue > > ( Context , inner ) ;
230285 }
286+
287+ // See ShouldDictionarySource: hand-written because MutableDictionaryAssertion shadows the inherited
288+ // collection methods with dictionary-typed `public new` overloads the Should generator can't construct.
289+
290+ public ShouldAssertion < IDictionary < TKey , TValue > > BeEmpty ( )
291+ {
292+ Context . ExpressionBuilder . Append ( ".BeEmpty()" ) ;
293+ var inner = ApplyBecause ( new CollectionIsEmptyAssertion < IDictionary < TKey , TValue > , KeyValuePair < TKey , TValue > > ( Context ) ) ;
294+ return new ShouldAssertion < IDictionary < TKey , TValue > > ( Context , inner ) ;
295+ }
296+
297+ public ShouldAssertion < IDictionary < TKey , TValue > > NotBeEmpty ( )
298+ {
299+ Context . ExpressionBuilder . Append ( ".NotBeEmpty()" ) ;
300+ var inner = ApplyBecause ( new CollectionIsNotEmptyAssertion < IDictionary < TKey , TValue > , KeyValuePair < TKey , TValue > > ( Context ) ) ;
301+ return new ShouldAssertion < IDictionary < TKey , TValue > > ( Context , inner ) ;
302+ }
303+
304+ public ShouldAssertion < IDictionary < TKey , TValue > > HaveSingleItem ( )
305+ {
306+ Context . ExpressionBuilder . Append ( ".HaveSingleItem()" ) ;
307+ var inner = ApplyBecause ( new HasSingleItemAssertion < IDictionary < TKey , TValue > , KeyValuePair < TKey , TValue > > ( Context ) ) ;
308+ return new ShouldAssertion < IDictionary < TKey , TValue > > ( Context , inner ) ;
309+ }
310+
311+ public ShouldAssertion < IDictionary < TKey , TValue > > HaveAtLeast (
312+ int minCount ,
313+ [ CallerArgumentExpression ( nameof ( minCount ) ) ] string ? expression = null )
314+ {
315+ Context . ExpressionBuilder . Append ( ".HaveAtLeast(" ) . Append ( expression ) . Append ( ')' ) ;
316+ var inner = ApplyBecause ( new CollectionHasAtLeastAssertion < IDictionary < TKey , TValue > , KeyValuePair < TKey , TValue > > ( Context , minCount ) ) ;
317+ return new ShouldAssertion < IDictionary < TKey , TValue > > ( Context , inner ) ;
318+ }
319+
320+ public ShouldAssertion < IDictionary < TKey , TValue > > HaveAtMost (
321+ int maxCount ,
322+ [ CallerArgumentExpression ( nameof ( maxCount ) ) ] string ? expression = null )
323+ {
324+ Context . ExpressionBuilder . Append ( ".HaveAtMost(" ) . Append ( expression ) . Append ( ')' ) ;
325+ var inner = ApplyBecause ( new CollectionHasAtMostAssertion < IDictionary < TKey , TValue > , KeyValuePair < TKey , TValue > > ( Context , maxCount ) ) ;
326+ return new ShouldAssertion < IDictionary < TKey , TValue > > ( Context , inner ) ;
327+ }
328+
329+ public ShouldAssertion < IDictionary < TKey , TValue > > HaveCountBetween (
330+ int min ,
331+ int max ,
332+ [ CallerArgumentExpression ( nameof ( min ) ) ] string ? minExpression = null ,
333+ [ CallerArgumentExpression ( nameof ( max ) ) ] string ? maxExpression = null )
334+ {
335+ Context . ExpressionBuilder . Append ( $ ".HaveCountBetween({ minExpression } , { maxExpression } )") ;
336+ var inner = ApplyBecause ( new CollectionHasCountBetweenAssertion < IDictionary < TKey , TValue > , KeyValuePair < TKey , TValue > > ( Context , min , max ) ) ;
337+ return new ShouldAssertion < IDictionary < TKey , TValue > > ( Context , inner ) ;
338+ }
231339}
0 commit comments