File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed
src/PresentationCore/System/Windows/Media
tests/UnitTests/PresentationCore.Tests/System/Windows/Media Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -810,6 +810,8 @@ internal static KnownColor ColorStringToKnownColor(string colorString)
810
810
#if ! PBTCOMPILER
811
811
internal static KnownColor ArgbStringToKnownColor ( string argbString )
812
812
{
813
+ ArgumentNullException . ThrowIfNull ( argbString ) ;
814
+
813
815
ReadOnlySpan < char > argbSpan = argbString . AsSpan ( ) . Trim ( ) ;
814
816
815
817
// Use NumberStyles.AllowHexSpecifier instead of NumberStyles.HexNumber because NumberStyles.HexNumber
Original file line number Diff line number Diff line change
1
+ namespace System . Windows . Media ;
2
+
3
+ public class KnownColorsTests
4
+ {
5
+ [ Theory ]
6
+ // Supported values.
7
+ [ InlineData ( KnownColor . AliceBlue , "#FFF0F8FF" ) ]
8
+ [ InlineData ( KnownColor . AliceBlue , " #FFF0F8FF" ) ]
9
+ [ InlineData ( KnownColor . AliceBlue , " #FFF0F8FF " ) ]
10
+ [ InlineData ( KnownColor . AliceBlue , "#FFF0F8FF " ) ]
11
+ // Unsupported values.
12
+ [ InlineData ( KnownColor . UnknownColor , "" ) ]
13
+ [ InlineData ( KnownColor . UnknownColor , " " ) ]
14
+ [ InlineData ( KnownColor . UnknownColor , "#020B37EF" ) ] // Random ARGB that is not a known color.
15
+ [ InlineData ( KnownColor . UnknownColor , "# FFF0F8FF" ) ]
16
+ public void ArgbStringToKnownColor_ReturnsExpected ( object expected , string ? argbString )
17
+ {
18
+ Assert . Equal ( ( KnownColor ) expected , KnownColors . ArgbStringToKnownColor ( argbString ) ) ;
19
+ }
20
+
21
+ [ Fact ]
22
+ public void ArgbStringToKnownColor_NullValue_ThrowsArgumentNullException ( )
23
+ {
24
+ Assert . Throws < ArgumentNullException > ( ( ) => KnownColors . ArgbStringToKnownColor ( argbString : null ) ) ;
25
+ }
26
+ }
You can’t perform that action at this time.
0 commit comments