@@ -5,9 +5,7 @@ namespace System.IO.Abstractions.TestingHelpers.Tests
55{
66 public class MockPathTests
77 {
8- static readonly string TestPath = XFS
9- . ForWin ( "C:\\ test\\ test.bmp" )
10- . ForUnix ( "/test/test.bmp" ) ;
8+ static readonly string TestPath = XFS . Path ( "C:\\ test\\ test.bmp" ) ;
119
1210 private MockPath SetupMockPath ( )
1311 {
@@ -24,10 +22,7 @@ public void ChangeExtension_ExtensionNoPeriod_PeriodAdded()
2422 var result = mockPath . ChangeExtension ( TestPath , "doc" ) ;
2523
2624 //Assert
27- Assert . AreEqual ( XFS
28- . ForWin ( "C:\\ test\\ test.doc" )
29- . ForUnix ( "/test/test.doc" )
30- , result ) ;
25+ Assert . AreEqual ( XFS . Path ( "C:\\ test\\ test.doc" ) , result ) ;
3126 }
3227
3328 [ Test ]
@@ -37,16 +32,10 @@ public void Combine_SentTwoPaths_Combines()
3732 var mockPath = new MockPath ( new MockFileSystem ( ) ) ;
3833
3934 //Act
40- var result = mockPath . Combine ( XFS
41- . ForWin ( "C:\\ test" )
42- . ForUnix ( "/test" )
43- , "test.bmp" ) ;
35+ var result = mockPath . Combine ( XFS . Path ( "C:\\ test" ) , "test.bmp" ) ;
4436
4537 //Assert
46- Assert . AreEqual ( XFS
47- . ForWin ( "C:\\ test\\ test.bmp" )
48- . ForUnix ( "/test/test.bmp" )
49- , result ) ;
38+ Assert . AreEqual ( XFS . Path ( "C:\\ test\\ test.bmp" ) , result ) ;
5039 }
5140
5241 [ Test ]
@@ -59,10 +48,7 @@ public void GetDirectoryName_SentPath_ReturnsDirectory()
5948 var result = mockPath . GetDirectoryName ( TestPath ) ;
6049
6150 //Assert
62- Assert . AreEqual ( XFS
63- . ForWin ( "C:\\ test" )
64- . ForUnix ( "/test" )
65- , result ) ;
51+ Assert . AreEqual ( XFS . Path ( "C:\\ test" ) , result ) ;
6652 }
6753
6854 [ Test ]
@@ -121,13 +107,13 @@ public static IEnumerable<string[]> GetFullPath_RelativePaths_Cases
121107 {
122108 get
123109 {
124- yield return new [ ] { XFS . ForWin ( @"c:\a" ) . ForUnix ( "/a" ) , "b" , XFS . ForWin ( @"c:\a\b" ) . ForUnix ( "/a/ b") } ;
125- yield return new [ ] { XFS . ForWin ( @"c:\a\b" ) . ForUnix ( "/a/b" ) , "c" , XFS . ForWin ( @"c:\a\b\c" ) . ForUnix ( "/a/b/ c") } ;
126- yield return new [ ] { XFS . ForWin ( @"c:\a\b" ) . ForUnix ( "/a/b" ) , XFS . ForWin ( @"c\" ) . ForUnix ( "c/" ) , XFS . ForWin ( @"c:\a\b\c\" ) . ForUnix ( "/a/b/c/ ") } ;
127- yield return new [ ] { XFS . ForWin ( @"c:\a\b" ) . ForUnix ( "/a/b" ) , XFS . ForWin ( @"..\c" ) . ForUnix ( "../c" ) , XFS . ForWin ( @"c:\a\c" ) . ForUnix ( "/a/ c") } ;
128- yield return new [ ] { XFS . ForWin ( @"c:\a\b\c" ) . ForUnix ( "/a/b/c" ) , XFS . ForWin ( @"..\c\..\" ) . ForUnix ( "../c/../" ) , XFS . ForWin ( @"c:\a\b\" ) . ForUnix ( "/a/b/ ") } ;
129- yield return new [ ] { XFS . ForWin ( @"c:\a\b\c" ) . ForUnix ( "/a/b/c" ) , XFS . ForWin ( @"..\..\..\..\..\d" ) . ForUnix ( "../../../../../d" ) , XFS . ForWin ( @"c:\d" ) . ForUnix ( "/ d") } ;
130- yield return new [ ] { XFS . ForWin ( @"c:\a\b\c" ) . ForUnix ( "/a/b/c" ) , XFS . ForWin ( @"..\..\..\..\..\d\" ) . ForUnix ( "../../../../../d/" ) , XFS . ForWin ( @"c:\d\" ) . ForUnix ( "/d/ ") } ;
110+ yield return new [ ] { XFS . Path ( @"c:\a" ) , "b" , XFS . Path ( @"c:\a\b" ) } ;
111+ yield return new [ ] { XFS . Path ( @"c:\a\b" ) , "c" , XFS . Path ( @"c:\a\b\c" ) } ;
112+ yield return new [ ] { XFS . Path ( @"c:\a\b" ) , XFS . Path ( @"c\" ) , XFS . Path ( @"c:\a\b\c\" ) } ;
113+ yield return new [ ] { XFS . Path ( @"c:\a\b" ) , XFS . Path ( @"..\c" ) , XFS . Path ( @"c:\a\c" ) } ;
114+ yield return new [ ] { XFS . Path ( @"c:\a\b\c" ) , XFS . Path ( @"..\c\..\" ) , XFS . Path ( @"c:\a\b\" ) } ;
115+ yield return new [ ] { XFS . Path ( @"c:\a\b\c" ) , XFS . Path ( @"..\..\..\..\..\d" ) , XFS . Path ( @"c:\d" ) } ;
116+ yield return new [ ] { XFS . Path ( @"c:\a\b\c" ) , XFS . Path ( @"..\..\..\..\..\d\" ) , XFS . Path ( @"c:\d\" ) } ;
131117 }
132118 }
133119
@@ -150,11 +136,11 @@ public static IEnumerable<string[]> GetFullPath_RootedPathWithRelativeSegments_C
150136 {
151137 get
152138 {
153- yield return new [ ] { XFS . ForWin ( @"c:\a\b\..\c" ) . ForUnix ( "/a/b/../c" ) , XFS . ForWin ( @"c:\a\c" ) . ForUnix ( "/a/ c") } ;
154- yield return new [ ] { XFS . ForWin ( @"c:\a\b\.\.\..\.\c" ) . ForUnix ( "/a/b/././.././c" ) , XFS . ForWin ( @"c:\a\c" ) . ForUnix ( "/a/ c") } ;
155- yield return new [ ] { XFS . ForWin ( @"c:\a\b\.\c" ) . ForUnix ( "/a/b/./c" ) , XFS . ForWin ( @"c:\a\b\c" ) . ForUnix ( "/a/b/ c") } ;
156- yield return new [ ] { XFS . ForWin ( @"c:\a\b\.\.\.\.\c" ) . ForUnix ( "/a/b/././././c" ) , XFS . ForWin ( @"c:\a\b\c" ) . ForUnix ( "/a/b/ c") } ;
157- yield return new [ ] { XFS . ForWin ( @"c:\a\..\..\c" ) . ForUnix ( "/a/../../c" ) , XFS . ForWin ( @"c:\c" ) . ForUnix ( "/ c") } ;
139+ yield return new [ ] { XFS . Path ( @"c:\a\b\..\c" ) , XFS . Path ( @"c:\a\c" ) } ;
140+ yield return new [ ] { XFS . Path ( @"c:\a\b\.\.\..\.\c" ) , XFS . Path ( @"c:\a\c" ) } ;
141+ yield return new [ ] { XFS . Path ( @"c:\a\b\.\c" ) , XFS . Path ( @"c:\a\b\c" ) } ;
142+ yield return new [ ] { XFS . Path ( @"c:\a\b\.\.\.\.\c" ) , XFS . Path ( @"c:\a\b\c" ) } ;
143+ yield return new [ ] { XFS . Path ( @"c:\a\..\..\c" ) , XFS . Path ( @"c:\c" ) } ;
158144 }
159145 }
160146
@@ -176,14 +162,14 @@ public static IEnumerable<string[]> GetFullPath_AbsolutePaths_Cases
176162 {
177163 get
178164 {
179- yield return new [ ] { XFS . ForWin ( @"c:\a" ) . ForUnix ( "/a" ) , XFS . ForWin ( @"/b" ) . ForUnix ( @"/b" ) , XFS . ForWin ( @"c:\b" ) . ForUnix ( "/ b") } ;
180- yield return new [ ] { XFS . ForWin ( @"c:\a" ) . ForUnix ( "/a" ) , XFS . ForWin ( @"/b\" ) . ForUnix ( @"/b/" ) , XFS . ForWin ( @"c:\b\" ) . ForUnix ( "/b/ ") } ;
181- yield return new [ ] { XFS . ForWin ( @"c:\a" ) . ForUnix ( "/a" ) , XFS . ForWin ( @"\b" ) . ForUnix ( @"/b" ) , XFS . ForWin ( @"c:\b" ) . ForUnix ( "/ b") } ;
182- yield return new [ ] { XFS . ForWin ( @"c:\a" ) . ForUnix ( "/a" ) , XFS . ForWin ( @"\b\..c" ) . ForUnix ( @"/b/../c" ) , XFS . ForWin ( @"c:\c" ) . ForUnix ( "/ c") } ;
183- yield return new [ ] { XFS . ForWin ( @"z:\a" ) . ForUnix ( "/a" ) , XFS . ForWin ( @"\b\..c" ) . ForUnix ( @"/b/../c" ) , XFS . ForWin ( @"z:\c" ) . ForUnix ( "/ c") } ;
184- yield return new [ ] { XFS . ForWin ( @"z:\a" ) . ForUnix ( "/a" ) , XFS . ForWin ( @"\\computer\share\c" ) . ForUnix ( @"//computer/share/c" ) , XFS . ForWin ( @"\\computer\share\c" ) . ForUnix ( "//computer/share/ c") } ;
185- yield return new [ ] { XFS . ForWin ( @"z:\a" ) . ForUnix ( "/a" ) , XFS . ForWin ( @"\\computer\share\c\..\d" ) . ForUnix ( @"//computer/share/c/../d" ) , XFS . ForWin ( @"\\computer\share\d" ) . ForUnix ( "//computer/share/ d") } ;
186- yield return new [ ] { XFS . ForWin ( @"z:\a" ) . ForUnix ( "/a" ) , XFS . ForWin ( @"\\computer\share\c\..\..\d" ) . ForUnix ( @"//computer/share/c/../../d" ) , XFS . ForWin ( @"\\computer\share\d" ) . ForUnix ( "//computer/share/ d") } ;
165+ yield return new [ ] { XFS . Path ( @"c:\a" ) , XFS . Path ( @"/b" ) , XFS . Path ( @"c:\b" ) } ;
166+ yield return new [ ] { XFS . Path ( @"c:\a" ) , XFS . Path ( @"/b\" ) , XFS . Path ( @"c:\b\" ) } ;
167+ yield return new [ ] { XFS . Path ( @"c:\a" ) , XFS . Path ( @"\b" ) , XFS . Path ( @"c:\b" ) } ;
168+ yield return new [ ] { XFS . Path ( @"c:\a" ) , XFS . Path ( @"\b\..\ c" ) , XFS . Path ( @"c:\c" ) } ;
169+ yield return new [ ] { XFS . Path ( @"z:\a" ) , XFS . Path ( @"\b\..\ c" ) , XFS . Path ( @"z:\c" ) } ;
170+ yield return new [ ] { XFS . Path ( @"z:\a" ) , XFS . Path ( @"\\computer\share\c" ) , XFS . Path ( @"\\computer\share\c" ) } ;
171+ yield return new [ ] { XFS . Path ( @"z:\a" ) , XFS . Path ( @"\\computer\share\c\..\d" ) , XFS . Path ( @"\\computer\share\d" ) } ;
172+ yield return new [ ] { XFS . Path ( @"z:\a" ) , XFS . Path ( @"\\computer\share\c\..\..\d" ) , XFS . Path ( @"\\computer\share\d" ) } ;
187173 }
188174 }
189175
@@ -210,7 +196,7 @@ public void GetFullPath_InvalidUNCPaths_ShouldThrowArgumentException()
210196 var mockPath = new MockPath ( mockFileSystem ) ;
211197
212198 //Act
213- TestDelegate action = ( ) => mockPath . GetFullPath ( XFS . ForWin ( @"\\shareZ" ) . ForUnix ( @"// shareZ") ) ;
199+ TestDelegate action = ( ) => mockPath . GetFullPath ( XFS . Path ( @"\\shareZ" ) ) ;
214200
215201 //Assert
216202 Assert . Throws < ArgumentException > ( action ) ;
@@ -280,10 +266,7 @@ public void GetPathRoot_SendInPath_ReturnsRoot()
280266 var result = mockPath . GetPathRoot ( TestPath ) ;
281267
282268 //Assert
283- Assert . AreEqual ( XFS
284- . ForWin ( "C:\\ " )
285- . ForUnix ( "/" )
286- , result ) ;
269+ Assert . AreEqual ( XFS . Path ( "C:\\ " ) , result ) ;
287270 }
288271
289272 [ Test ]
@@ -365,4 +348,4 @@ public void IsPathRooted_PathSentIn_DeterminesPathExists()
365348 Assert . AreEqual ( true , result ) ;
366349 }
367350 }
368- }
351+ }
0 commit comments