@@ -102,6 +102,111 @@ public void GetFullPath_SendInPath_ReturnsFullPath()
102102 Assert . AreEqual ( TestPath , result ) ;
103103 }
104104
105+ [ TestCase ( @"c:\a" , @"b" , @"c:\a\b" ) ]
106+ [ TestCase ( @"c:\a\b" , @"c" , @"c:\a\b\c" ) ]
107+ [ TestCase ( @"c:\a\b" , @"c\" , @"c:\a\b\c\" ) ]
108+ [ TestCase ( @"c:\a\b" , @".\c\" , @"c:\a\b\c\" ) ]
109+ [ TestCase ( @"c:\a\b" , @"..\c" , @"c:\a\c" ) ]
110+ [ TestCase ( @"c:\a\b\c" , @"..\c\..\" , @"c:\a\b\" ) ]
111+ [ TestCase ( @"c:\a\b\c" , @"..\..\..\..\..\d" , @"c:\d" ) ]
112+ [ TestCase ( @"c:\a\b\c\" , @"..\..\..\..\..\d\" , @"c:\d\" ) ]
113+ public void GetFullPath_RelativePaths_ShouldReturnTheAbsolutePathWithCurrentDirectory ( string currentDir , string relativePath , string expectedResult )
114+ {
115+ //Arrange
116+ var mockFileSystem = new MockFileSystem ( ) ;
117+ mockFileSystem . Directory . SetCurrentDirectory ( currentDir ) ;
118+ var mockPath = new MockPath ( mockFileSystem ) ;
119+
120+ //Act
121+ var actualResult = mockPath . GetFullPath ( relativePath ) ;
122+
123+ //Assert
124+ Assert . AreEqual ( expectedResult , actualResult ) ;
125+ }
126+
127+ [ TestCase ( @"c:\a\b\..\c" , @"c:\a\c" ) ]
128+ [ TestCase ( @"c:\a\b\.\.\..\.\c" , @"c:\a\c" ) ]
129+ [ TestCase ( @"c:\a\b\.\c" , @"c:\a\b\c" ) ]
130+ [ TestCase ( @"c:\a\b\.\.\.\.\c" , @"c:\a\b\c" ) ]
131+ [ TestCase ( @"c:\a\..\..\c" , @"c:\c" ) ]
132+ public void GetFullPath_RootedPathWithRelativeSegments_ShouldReturnAnRootedAbsolutePath ( string rootedPath , string expectedResult )
133+ {
134+ //Arrange
135+ var mockFileSystem = new MockFileSystem ( ) ;
136+ var mockPath = new MockPath ( mockFileSystem ) ;
137+
138+ //Act
139+ var actualResult = mockPath . GetFullPath ( rootedPath ) ;
140+
141+ //Assert
142+ Assert . AreEqual ( expectedResult , actualResult ) ;
143+ }
144+
145+ [ TestCase ( @"c:\a" , @"/b" , @"c:\b" ) ]
146+ [ TestCase ( @"c:\a" , @"/b\" , @"c:\b\" ) ]
147+ [ TestCase ( @"c:\a" , @"\b" , @"c:\b" ) ]
148+ [ TestCase ( @"c:\a" , @"\b\..\c" , @"c:\c" ) ]
149+ [ TestCase ( @"z:\a" , @"\b\..\c" , @"z:\c" ) ]
150+ [ TestCase ( @"z:\a" , @"\b\..\c" , @"z:\c" ) ]
151+ [ TestCase ( @"z:\a" , @"\\computer\share\c" , @"\\computer\share\c" ) ]
152+ [ TestCase ( @"z:\a" , @"\\computer\share\c\..\d" , @"\\computer\share\d" ) ]
153+ [ TestCase ( @"z:\a" , @"\\computer\share\c\..\..\d" , @"\\computer\share\d" ) ]
154+ public void GetFullPath_AbsolutePaths_ShouldReturnThePathWithTheRoot_Or_Unc ( string currentDir , string absolutePath , string expectedResult )
155+ {
156+ //Arrange
157+ var mockFileSystem = new MockFileSystem ( ) ;
158+ mockFileSystem . Directory . SetCurrentDirectory ( currentDir ) ;
159+ var mockPath = new MockPath ( mockFileSystem ) ;
160+
161+ //Act
162+ var actualResult = mockPath . GetFullPath ( absolutePath ) ;
163+
164+ //Assert
165+ Assert . AreEqual ( expectedResult , actualResult ) ;
166+ }
167+
168+ [ Test ]
169+ public void GetFullPath_InvalidUNCPaths_ShouldThrowArgumentException ( )
170+ {
171+ //Arrange
172+ var mockFileSystem = new MockFileSystem ( ) ;
173+ var mockPath = new MockPath ( mockFileSystem ) ;
174+
175+ //Act
176+ TestDelegate action = ( ) => mockPath . GetFullPath ( @"\\shareZ" ) ;
177+
178+ //Assert
179+ Assert . Throws < ArgumentException > ( action ) ;
180+ }
181+
182+ [ Test ]
183+ public void GetFullPath_NullValue_ShouldThrowArgumentNullException ( )
184+ {
185+ //Arrange
186+ var mockFileSystem = new MockFileSystem ( ) ;
187+ var mockPath = new MockPath ( mockFileSystem ) ;
188+
189+ //Act
190+ TestDelegate action = ( ) => mockPath . GetFullPath ( null ) ;
191+
192+ //Assert
193+ Assert . Throws < ArgumentNullException > ( action ) ;
194+ }
195+
196+ [ Test ]
197+ public void GetFullPath_EmptyValue_ShouldThrowArgumentException ( )
198+ {
199+ //Arrange
200+ var mockFileSystem = new MockFileSystem ( ) ;
201+ var mockPath = new MockPath ( mockFileSystem ) ;
202+
203+ //Act
204+ TestDelegate action = ( ) => mockPath . GetFullPath ( string . Empty ) ;
205+
206+ //Assert
207+ Assert . Throws < ArgumentException > ( action ) ;
208+ }
209+
105210 [ Test ]
106211 public void GetInvalidFileNameChars_Called_ReturnsChars ( )
107212 {
@@ -151,7 +256,7 @@ public void GetRandomFileName_Called_ReturnsStringLengthGreaterThanZero()
151256 var result = mockPath . GetRandomFileName ( ) ;
152257
153258 //Assert
154- Assert . IsTrue ( result . Length > 0 ) ;
259+ Assert . IsTrue ( result . Length > 0 ) ;
155260 }
156261
157262 [ Test ]
0 commit comments