@@ -27,6 +27,33 @@ public void TryJoin_2Paths_BufferTooLittle_ShouldReturnFalse(
27
27
charsWritten . Should ( ) . Be ( 0 ) ;
28
28
}
29
29
30
+ [ SkippableTheory ]
31
+ [ InlineAutoData ( "/foo/" , "/bar/" , "/foo//bar/" ) ]
32
+ [ InlineAutoData ( "foo/" , "/bar" , "foo//bar" ) ]
33
+ [ InlineAutoData ( "foo/" , "bar" , "foo/bar" ) ]
34
+ [ InlineAutoData ( "foo" , "/bar" , "foo/bar" ) ]
35
+ [ InlineAutoData ( "foo" , "bar" , "foo/bar" ) ]
36
+ [ InlineAutoData ( "/foo" , "bar/" , "/foo/bar/" ) ]
37
+ public void TryJoin_2Paths_ShouldReturnExpectedResult (
38
+ string path1 , string path2 , string expectedResult )
39
+ {
40
+ path1 = path1 . Replace ( '/' , FileSystem . Path . DirectorySeparatorChar ) ;
41
+ path2 = path2 . Replace ( '/' , FileSystem . Path . DirectorySeparatorChar ) ;
42
+ expectedResult = expectedResult . Replace ( '/' , FileSystem . Path . DirectorySeparatorChar ) ;
43
+ char [ ] buffer = new char [ expectedResult . Length ] ;
44
+ Span < char > destination = new ( buffer ) ;
45
+
46
+ bool result = FileSystem . Path . TryJoin (
47
+ path1 . AsSpan ( ) ,
48
+ path2 . AsSpan ( ) ,
49
+ destination ,
50
+ out int charsWritten ) ;
51
+
52
+ result . Should ( ) . BeTrue ( ) ;
53
+ charsWritten . Should ( ) . Be ( expectedResult . Length ) ;
54
+ destination . Slice ( 0 , charsWritten ) . ToString ( ) . Should ( ) . Be ( expectedResult ) ;
55
+ }
56
+
30
57
[ SkippableTheory ]
31
58
[ AutoData ]
32
59
public void TryJoin_2Paths_ShouldReturnPathsCombinedByDirectorySeparatorChar (
@@ -72,6 +99,36 @@ public void TryJoin_3Paths_BufferTooLittle_ShouldReturnFalse(
72
99
charsWritten . Should ( ) . Be ( 0 ) ;
73
100
}
74
101
102
+ [ SkippableTheory ]
103
+ [ InlineAutoData ( "/foo/" , "/bar/" , "/baz/" , "/foo//bar//baz/" ) ]
104
+ [ InlineAutoData ( "foo/" , "/bar/" , "/baz" , "foo//bar//baz" ) ]
105
+ [ InlineAutoData ( "foo/" , "bar" , "/baz" , "foo/bar/baz" ) ]
106
+ [ InlineAutoData ( "foo" , "/bar" , "/baz" , "foo/bar/baz" ) ]
107
+ [ InlineAutoData ( "foo" , "/bar/" , "baz" , "foo/bar/baz" ) ]
108
+ [ InlineAutoData ( "foo" , "bar" , "baz" , "foo/bar/baz" ) ]
109
+ [ InlineAutoData ( "/foo" , "bar" , "baz/" , "/foo/bar/baz/" ) ]
110
+ public void TryJoin_3Paths_ShouldReturnExpectedResult (
111
+ string path1 , string path2 , string path3 , string expectedResult )
112
+ {
113
+ path1 = path1 . Replace ( '/' , FileSystem . Path . DirectorySeparatorChar ) ;
114
+ path2 = path2 . Replace ( '/' , FileSystem . Path . DirectorySeparatorChar ) ;
115
+ path3 = path3 . Replace ( '/' , FileSystem . Path . DirectorySeparatorChar ) ;
116
+ expectedResult = expectedResult . Replace ( '/' , FileSystem . Path . DirectorySeparatorChar ) ;
117
+ char [ ] buffer = new char [ expectedResult . Length ] ;
118
+ Span < char > destination = new ( buffer ) ;
119
+
120
+ bool result = FileSystem . Path . TryJoin (
121
+ path1 . AsSpan ( ) ,
122
+ path2 . AsSpan ( ) ,
123
+ path3 . AsSpan ( ) ,
124
+ destination ,
125
+ out int charsWritten ) ;
126
+
127
+ result . Should ( ) . BeTrue ( ) ;
128
+ charsWritten . Should ( ) . Be ( expectedResult . Length ) ;
129
+ destination . Slice ( 0 , charsWritten ) . ToString ( ) . Should ( ) . Be ( expectedResult ) ;
130
+ }
131
+
75
132
[ SkippableTheory ]
76
133
[ AutoData ]
77
134
public void TryJoin_3Paths_ShouldReturnPathsCombinedByDirectorySeparatorChar (
0 commit comments