@@ -10,35 +10,57 @@ public class RidTests
10
10
{
11
11
public static IEnumerable < object [ ] > ValidRIDData ( )
12
12
{
13
- yield return new object [ ] { "win10-x64" , new RID ( ) { BaseRID = "win" , OmitVersionDelimiter = true , Version = new RuntimeVersion ( "10" ) , Architecture = "x64" } } ;
14
- yield return new object [ ] { "win10" , new RID ( ) { BaseRID = "win" , OmitVersionDelimiter = true , Version = new RuntimeVersion ( "10" ) } } ;
15
- yield return new object [ ] { "linux" , new RID ( ) { BaseRID = "linux" } } ;
16
- yield return new object [ ] { "linux-x64" , new RID ( ) { BaseRID = "linux" , Architecture = "x64" } } ;
17
- yield return new object [ ] { "linux-x64" , new RID ( ) { BaseRID = "linux" , Architecture = "x64" } } ;
18
- yield return new object [ ] { "debian.10-x64" , new RID ( ) { BaseRID = "debian" , Version = new RuntimeVersion ( "10" ) , Architecture = "x64" } } ;
19
- yield return new object [ ] { "linuxmint.19.2-x64" , new RID ( ) { BaseRID = "linuxmint" , Version = new RuntimeVersion ( "19.2" ) , Architecture = "x64" } } ;
20
- yield return new object [ ] { "ubuntu.14.04-x64" , new RID ( ) { BaseRID = "ubuntu" , Version = new RuntimeVersion ( "14.04" ) , Architecture = "x64" } } ;
21
- yield return new object [ ] { "foo-bar.42-arm" , new RID ( ) { BaseRID = "foo-bar" , Version = new RuntimeVersion ( "42" ) , Architecture = "arm" } } ;
22
- yield return new object [ ] { "foo-bar-arm" , new RID ( ) { BaseRID = "foo" , Architecture = "bar" , Qualifier = "arm" } } ; // demonstrates ambiguity, avoid using `-` in base
23
- yield return new object [ ] { "linux-musl-x64" , new RID ( ) { BaseRID = "linux" , Architecture = "musl" , Qualifier = "x64" } } ; // yes, we already have ambiguous RIDs
13
+ yield return new object [ ] { "win10-x64" , new RID ( ) { BaseRID = "win" , OmitVersionDelimiter = true , Version = new RuntimeVersion ( "10" ) , Architecture = "x64" } , null } ;
14
+ yield return new object [ ] { "win10" , new RID ( ) { BaseRID = "win" , OmitVersionDelimiter = true , Version = new RuntimeVersion ( "10" ) } , null } ;
15
+ yield return new object [ ] { "linux" , new RID ( ) { BaseRID = "linux" } , null } ;
16
+ yield return new object [ ] { "linux-x64" , new RID ( ) { BaseRID = "linux" , Architecture = "x64" } , null } ;
17
+ yield return new object [ ] { "linux-x64" , new RID ( ) { BaseRID = "linux" , Architecture = "x64" } , null } ;
18
+ yield return new object [ ] { "debian.10-x64" , new RID ( ) { BaseRID = "debian" , Version = new RuntimeVersion ( "10" ) , Architecture = "x64" } , null } ;
19
+ yield return new object [ ] { "linuxmint.19.2-x64" , new RID ( ) { BaseRID = "linuxmint" , Version = new RuntimeVersion ( "19.2" ) , Architecture = "x64" } , null } ;
20
+ yield return new object [ ] { "ubuntu.14.04-x64" , new RID ( ) { BaseRID = "ubuntu" , Version = new RuntimeVersion ( "14.04" ) , Architecture = "x64" } , null } ;
21
+ yield return new object [ ] { "foo-bar.42-arm" , new RID ( ) { BaseRID = "foo-bar" , Version = new RuntimeVersion ( "42" ) , Architecture = "arm" } , null } ;
22
+ yield return new object [ ] { "foo-bar-arm" , new RID ( ) { BaseRID = "foo" , Architecture = "bar" , Qualifier = "arm" } , // demonstrates ambiguity, avoid using `-` in base
23
+ new RID ( ) { BaseRID = "foo-bar" , Architecture = "arm" } } ;
24
+ yield return new object [ ] { "linux-musl-x64" , new RID ( ) { BaseRID = "linux" , Architecture = "musl" , Qualifier = "x64" } , // yes, we already have ambiguous RIDs
25
+ new RID ( ) { BaseRID = "linux-musl" , Architecture = "x64" } } ;
24
26
}
25
27
26
28
[ Theory ]
27
29
[ MemberData ( nameof ( ValidRIDData ) ) ]
28
- internal void ParseCorrectly ( string input , RID expected )
30
+ internal void ParseCorrectly ( string input , RID expected , RID ? expectedNoQualifier )
29
31
{
30
- RID actual = RID . Parse ( input ) ;
32
+ _ = expectedNoQualifier ; // unused
33
+
34
+ RID actual = RID . Parse ( input , noQualifier : false ) ;
31
35
32
36
Assert . Equal ( expected , actual ) ;
33
37
}
34
38
35
39
[ Theory ]
36
40
[ MemberData ( nameof ( ValidRIDData ) ) ]
37
- internal void ToStringAsExpected ( string expected , RID rid )
41
+ internal void ParseCorrectlyNoQualifier ( string input , RID expected , RID ? expectedNoQualifier )
42
+ {
43
+ expectedNoQualifier ??= expected ;
44
+
45
+ RID actual = RID . Parse ( input , noQualifier : true ) ;
46
+
47
+ Assert . Equal ( expectedNoQualifier , actual ) ;
48
+ }
49
+
50
+ [ Theory ]
51
+ [ MemberData ( nameof ( ValidRIDData ) ) ]
52
+ internal void ToStringAsExpected ( string expected , RID rid , RID ? expectedNoQualifierRid )
38
53
{
39
54
string actual = rid . ToString ( ) ;
40
55
41
56
Assert . Equal ( expected , actual ) ;
57
+
58
+ if ( expectedNoQualifierRid is not null )
59
+ {
60
+ actual = expectedNoQualifierRid . ToString ( ) ;
61
+
62
+ Assert . Equal ( expected , actual ) ;
63
+ }
42
64
}
43
65
}
44
66
}
0 commit comments