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 @@ -666,6 +666,8 @@ internal static KnownColor ColorStringToKnownColor(string colorString)
666666#if ! PBTCOMPILER
667667 internal static KnownColor ArgbStringToKnownColor ( string argbString )
668668 {
669+ ArgumentNullException . ThrowIfNull ( argbString ) ;
670+
669671 ReadOnlySpan < char > argbSpan = argbString . AsSpan ( ) . Trim ( ) ;
670672
671673 // 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