@@ -96,6 +96,84 @@ public void Comparable_Nulls_Max(int? value, int max, bool expected)
9696 Assert . Equal ( expected , result ) ;
9797 }
9898
99+ [ Theory ]
100+ [ MemberData ( nameof ( Comparable_MinMax_Data ) ) ]
101+ public void Comparable_MinMax < T > ( T value , T min , T max , bool expected )
102+ where T : IComparable < T >
103+ {
104+ // Arrange
105+ // Act
106+ var result = BuildInPredicates . MinMax ( value , min , max ) ;
107+
108+ // Assert
109+ Assert . Equal ( expected , result ) ;
110+ }
111+
112+ [ Theory ]
113+ [ MemberData ( nameof ( Comparable_MinMax_Data ) ) ]
114+ [ InlineData ( null , 0 , 0 , false ) ]
115+ [ InlineData ( null , 0 , 1 , false ) ]
116+ [ InlineData ( null , 1 , 3 , false ) ]
117+ public void Comparable_Nulls_MinMax ( int ? value , int min , int max , bool expected )
118+ {
119+ // Arrange
120+ // Act
121+ var result = BuildInPredicates . MinMax ( value , min , max ) ;
122+
123+ // Assert
124+ Assert . Equal ( expected , result ) ;
125+ }
126+
127+ [ Theory ]
128+ [ InlineData ( null , 0 , false ) ]
129+ [ InlineData ( "" , 0 , true ) ]
130+ [ InlineData ( "a" , 0 , true ) ]
131+ [ InlineData ( "" , 1 , false ) ]
132+ [ InlineData ( "a" , 1 , true ) ]
133+ [ InlineData ( "ab" , 1 , true ) ]
134+ public void String_MinLength ( string ? value , int minLength , bool expected )
135+ {
136+ // Arrange
137+ // Act
138+ var result = BuildInPredicates . MinLength ( value , minLength ) ;
139+
140+ // Assert
141+ Assert . Equal ( expected , result ) ;
142+ }
143+
144+ [ Theory ]
145+ [ InlineData ( null , 0 , true ) ]
146+ [ InlineData ( "" , 0 , true ) ]
147+ [ InlineData ( "a" , 0 , false ) ]
148+ [ InlineData ( "" , 1 , true ) ]
149+ [ InlineData ( "a" , 1 , true ) ]
150+ [ InlineData ( "ab" , 1 , false ) ]
151+ public void String_MaxLength ( string ? value , int maxLength , bool expected )
152+ {
153+ // Arrange
154+ // Act
155+ var result = BuildInPredicates . MaxLength ( value , maxLength ) ;
156+ // Assert
157+ Assert . Equal ( expected , result ) ;
158+ }
159+
160+ [ Theory ]
161+ [ InlineData ( null , 0 , 0 , false ) ]
162+ [ InlineData ( null , 0 , 1 , false ) ]
163+ [ InlineData ( "" , 0 , 0 , true ) ]
164+ [ InlineData ( "" , 0 , 1 , true ) ]
165+ [ InlineData ( "a" , 0 , 0 , false ) ]
166+ [ InlineData ( "a" , 0 , 1 , true ) ]
167+ [ InlineData ( "ab" , 0 , 1 , false ) ]
168+ public void String_Length ( string ? value , int minLength , int maxLength , bool expected )
169+ {
170+ // Arrange
171+ // Act
172+ var result = BuildInPredicates . Length ( value , minLength , maxLength ) ;
173+
174+ // Assert
175+ Assert . Equal ( expected , result ) ;
176+ }
99177
100178 public static IEnumerable < object [ ] > Nullable_Comparable_Data ( )
101179 {
@@ -165,4 +243,13 @@ public static IEnumerable<object[]> Comparable_Data()
165243 yield return [ BigInteger . One , BigInteger . One , 0 ] ;
166244 yield return [ new BigInteger ( 2 ) , BigInteger . One , 1 ] ;
167245 }
246+
247+ public static IEnumerable < object [ ] > Comparable_MinMax_Data ( )
248+ {
249+ yield return [ 0 , 1 , 3 , false ] ;
250+ yield return [ 1 , 1 , 3 , true ] ;
251+ yield return [ 2 , 1 , 3 , true ] ;
252+ yield return [ 3 , 1 , 3 , true ] ;
253+ yield return [ 4 , 1 , 3 , false ] ;
254+ }
168255}
0 commit comments