@@ -211,4 +211,29 @@ public void ParseFollowedByToHexStringShouldRoundtripTheColor(string colorString
211211 {
212212 Assert . That ( ( ) => Color . Parse ( colorString ) . ToHexString ( ) , Is . EqualTo ( colorString ) ) ;
213213 }
214+
215+ [ TestCase ( "rgb(1, 2, 3)" , 1 , 2 , 3 , 1 ) ]
216+ [ TestCase ( "rgb(10%, 20%, 30%)" , 25 , 51 , 76 , 1 ) ]
217+ [ TestCase ( "rgb(\t 1, 2, 3)" , 1 , 2 , 3 , 1 ) ]
218+ [ TestCase ( "rgba(1, 2, 3, 0.5)" , 1 , 2 , 3 , 0.5D ) ]
219+ [ TestCase ( "rgba(10%, 20%, 30%, 0.5)" , 25 , 51 , 76 , 0.5D ) ]
220+ [ TestCase ( "#ff00a0" , 255 , 0 , 160 , 1 ) ]
221+ [ TestCase ( "#01Ff03" , 1 , 255 , 3 , 1 ) ]
222+ [ TestCase ( "#00FF33" , 0 , 255 , 51 , 1 ) ]
223+ [ TestCase ( "#0f3" , 0 , 255 , 51 , 1 ) ]
224+ [ TestCase ( "hsl(120, 100%, 25%)" , 0 , 128 , 0 , 1 ) ]
225+ [ TestCase ( "hsl(100, 0%, 50%)" , 128 , 128 , 128 , 1 ) ]
226+ [ TestCase ( "hsl(0, 100%, 50%)" , 255 , 0 , 0 , 1 ) ]
227+ [ TestCase ( "hsl(120, 100%, 50%)" , 0 , 255 , 0 , 1 ) ]
228+ [ TestCase ( "hsl(240, 100%, 50%)" , 0 , 0 , 255 , 1 ) ]
229+ [ TestCase ( "hsl(0, 0%, 100%)" , 255 , 255 , 255 , 1 ) ]
230+ [ TestCase ( "hsla(120, 100%, 25%, 1)" , 0 , 128 , 0 , 1 ) ]
231+ [ TestCase ( "hsla(100, 0%, 50%, 0.5)" , 128 , 128 , 128 , 0.5 ) ]
232+ [ TestCase ( "green" , 0 , 128 , 0 , 1 ) ]
233+ [ TestCase ( "gray" , 128 , 128 , 128 , 1 ) ]
234+ [ TestCase ( "transparent" , 0 , 0 , 0 , 0 ) ]
235+ public void GetHashCodeShouldReturnTheSameResultForEquivalentColors ( string colorString , byte red , byte green , byte blue , double alpha )
236+ {
237+ Assert . That ( ( ) => Color . Parse ( colorString ) . GetHashCode ( ) , Is . EqualTo ( new Color ( red , green , blue , alpha ) . GetHashCode ( ) ) ) ;
238+ }
214239}
0 commit comments