@@ -21,10 +21,14 @@ public void Can_LeftPart_and_LeftPart_char_needle()
21
21
{
22
22
var str = "user:pass@w:rd" ;
23
23
Assert . That ( str . LeftPart ( ':' ) , Is . EqualTo ( "user" ) ) ;
24
+ Assert . That ( str . SplitOnFirst ( ':' ) [ 0 ] , Is . EqualTo ( "user" ) ) ;
24
25
Assert . That ( str . RightPart ( ':' ) , Is . EqualTo ( "pass@w:rd" ) ) ;
26
+ Assert . That ( str . SplitOnFirst ( ':' ) . Last ( ) , Is . EqualTo ( "pass@w:rd" ) ) ;
25
27
26
28
Assert . That ( str . LeftPart ( '|' ) , Is . EqualTo ( "user:pass@w:rd" ) ) ;
27
- Assert . That ( str . RightPart ( '|' ) , Is . Null ) ;
29
+ Assert . That ( str . SplitOnFirst ( '|' ) [ 0 ] , Is . EqualTo ( "user:pass@w:rd" ) ) ;
30
+ Assert . That ( str . RightPart ( '|' ) , Is . EqualTo ( "user:pass@w:rd" ) ) ;
31
+ Assert . That ( str . SplitOnFirst ( '|' ) . Last ( ) , Is . EqualTo ( "user:pass@w:rd" ) ) ;
28
32
}
29
33
30
34
[ Test ]
@@ -40,10 +44,14 @@ public void Can_LeftPart_and_RightPart_string_needle()
40
44
{
41
45
var str = "user::pass@w:rd" ;
42
46
Assert . That ( str . LeftPart ( "::" ) , Is . EqualTo ( "user" ) ) ;
47
+ Assert . That ( str . SplitOnFirst ( "::" ) [ 0 ] , Is . EqualTo ( "user" ) ) ;
43
48
Assert . That ( str . RightPart ( "::" ) , Is . EqualTo ( "pass@w:rd" ) ) ;
49
+ Assert . That ( str . SplitOnFirst ( "::" ) . Last ( ) , Is . EqualTo ( "pass@w:rd" ) ) ;
44
50
45
51
Assert . That ( str . LeftPart ( "||" ) , Is . EqualTo ( "user::pass@w:rd" ) ) ;
46
- Assert . That ( str . RightPart ( "||" ) , Is . Null ) ;
52
+ Assert . That ( str . SplitOnFirst ( "||" ) [ 0 ] , Is . EqualTo ( "user::pass@w:rd" ) ) ;
53
+ Assert . That ( str . RightPart ( "||" ) , Is . EqualTo ( "user::pass@w:rd" ) ) ;
54
+ Assert . That ( str . SplitOnFirst ( "||" ) . Last ( ) , Is . EqualTo ( "user::pass@w:rd" ) ) ;
47
55
}
48
56
49
57
[ Test ]
@@ -59,10 +67,14 @@ public void Can_LastLeftPart_and_LastRightPart_char_needle()
59
67
{
60
68
var str = "user:name:pass@word" ;
61
69
Assert . That ( str . LastLeftPart ( ':' ) , Is . EqualTo ( "user:name" ) ) ;
70
+ Assert . That ( str . SplitOnLast ( ':' ) [ 0 ] , Is . EqualTo ( "user:name" ) ) ;
62
71
Assert . That ( str . LastRightPart ( ':' ) , Is . EqualTo ( "pass@word" ) ) ;
72
+ Assert . That ( str . SplitOnLast ( ':' ) . Last ( ) , Is . EqualTo ( "pass@word" ) ) ;
63
73
64
74
Assert . That ( str . LastLeftPart ( '|' ) , Is . EqualTo ( "user:name:pass@word" ) ) ;
65
- Assert . That ( str . LastRightPart ( '|' ) , Is . Null ) ;
75
+ Assert . That ( str . SplitOnLast ( '|' ) [ 0 ] , Is . EqualTo ( "user:name:pass@word" ) ) ;
76
+ Assert . That ( str . LastRightPart ( '|' ) , Is . EqualTo ( "user:name:pass@word" ) ) ;
77
+ Assert . That ( str . SplitOnLast ( '|' ) . Last ( ) , Is . EqualTo ( "user:name:pass@word" ) ) ;
66
78
}
67
79
68
80
[ Test ]
@@ -78,10 +90,14 @@ public void Can_LastLeftPart_and_LastRightPart_string_needle()
78
90
{
79
91
var str = "user::name::pass@word" ;
80
92
Assert . That ( str . LastLeftPart ( "::" ) , Is . EqualTo ( "user::name" ) ) ;
93
+ Assert . That ( str . SplitOnLast ( "::" ) [ 0 ] , Is . EqualTo ( "user::name" ) ) ;
81
94
Assert . That ( str . LastRightPart ( "::" ) , Is . EqualTo ( "pass@word" ) ) ;
95
+ Assert . That ( str . SplitOnLast ( "::" ) . Last ( ) , Is . EqualTo ( "pass@word" ) ) ;
82
96
83
97
Assert . That ( str . LastLeftPart ( "||" ) , Is . EqualTo ( "user::name::pass@word" ) ) ;
84
- Assert . That ( str . LastRightPart ( "||" ) , Is . Null ) ;
98
+ Assert . That ( str . SplitOnLast ( "||" ) [ 0 ] , Is . EqualTo ( "user::name::pass@word" ) ) ;
99
+ Assert . That ( str . LastRightPart ( "||" ) , Is . EqualTo ( "user::name::pass@word" ) ) ;
100
+ Assert . That ( str . SplitOnLast ( "||" ) . Last ( ) , Is . EqualTo ( "user::name::pass@word" ) ) ;
85
101
}
86
102
87
103
private static readonly char DirSep = Path . DirectorySeparatorChar ;
0 commit comments