@@ -141,6 +141,52 @@ public static IThat<decimal> Should(this IExpectSubject<decimal> subject)
141141 public static IThat < decimal ? > Should ( this IExpectSubject < decimal ? > subject )
142142 => subject . Should ( _ => { } ) ;
143143
144+ private readonly struct GenericArrayConstraint < T > (
145+ T ? [ ] expected ,
146+ Func < T ? [ ] , string > expectation ,
147+ Func < T , T ? [ ] , bool > condition ,
148+ Func < T , T ? [ ] , string > failureMessageFactory )
149+ : IValueConstraint < T >
150+ where T : struct
151+ {
152+ public ConstraintResult IsMetBy ( T actual )
153+ {
154+ if ( condition ( actual , expected ) )
155+ {
156+ return new ConstraintResult . Success < T > ( actual , ToString ( ) ) ;
157+ }
158+
159+ return new ConstraintResult . Failure ( ToString ( ) ,
160+ failureMessageFactory ( actual , expected ) ) ;
161+ }
162+
163+ public override string ToString ( )
164+ => expectation ( expected ) ;
165+ }
166+
167+ private readonly struct GenericArrayConstraint2 < T > (
168+ T [ ] expected ,
169+ Func < T [ ] , string > expectation ,
170+ Func < T , T [ ] , bool > condition ,
171+ Func < T , T [ ] , string > failureMessageFactory )
172+ : IValueConstraint < T >
173+ where T : struct
174+ {
175+ public ConstraintResult IsMetBy ( T actual )
176+ {
177+ if ( condition ( actual , expected ) )
178+ {
179+ return new ConstraintResult . Success < T > ( actual , ToString ( ) ) ;
180+ }
181+
182+ return new ConstraintResult . Failure ( ToString ( ) ,
183+ failureMessageFactory ( actual , expected ) ) ;
184+ }
185+
186+ public override string ToString ( )
187+ => expectation ( expected ) ;
188+ }
189+
144190 private readonly struct GenericConstraint < T > (
145191 T ? expected ,
146192 Func < T ? , string > expectation ,
@@ -186,4 +232,50 @@ public ConstraintResult IsMetBy(T? actual)
186232 public override string ToString ( )
187233 => expectation ( expected ) ;
188234 }
235+
236+ private readonly struct NullableGenericArrayConstraint < T > (
237+ T ? [ ] expected ,
238+ Func < T ? [ ] , string > expectation ,
239+ Func < T ? , T ? [ ] , bool > condition ,
240+ Func < T ? , T ? [ ] , string > failureMessageFactory )
241+ : IValueConstraint < T ? >
242+ where T : struct
243+ {
244+ public ConstraintResult IsMetBy ( T ? actual )
245+ {
246+ if ( condition ( actual , expected ) )
247+ {
248+ return new ConstraintResult . Success < T ? > ( actual , ToString ( ) ) ;
249+ }
250+
251+ return new ConstraintResult . Failure ( ToString ( ) ,
252+ failureMessageFactory ( actual , expected ) ) ;
253+ }
254+
255+ public override string ToString ( )
256+ => expectation ( expected ) ;
257+ }
258+
259+ private readonly struct NullableGenericArrayConstraint2 < T > (
260+ T [ ] expected ,
261+ Func < T [ ] , string > expectation ,
262+ Func < T ? , T [ ] , bool > condition ,
263+ Func < T ? , T [ ] , string > failureMessageFactory )
264+ : IValueConstraint < T ? >
265+ where T : struct
266+ {
267+ public ConstraintResult IsMetBy ( T ? actual )
268+ {
269+ if ( condition ( actual , expected ) )
270+ {
271+ return new ConstraintResult . Success < T ? > ( actual , ToString ( ) ) ;
272+ }
273+
274+ return new ConstraintResult . Failure ( ToString ( ) ,
275+ failureMessageFactory ( actual , expected ) ) ;
276+ }
277+
278+ public override string ToString ( )
279+ => expectation ( expected ) ;
280+ }
189281}
0 commit comments