File size: 1,613 Bytes
8c763fb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
Describe "Hierarchical paths" -Tags "CI" {
    BeforeAll {
        $data = "Hello World"
        Setup -File testFile.txt -Content $data
    }

    It "should work with Join-Path " {
        $testPath = Join-Path $TestDrive testFile.txt
        Get-Content $testPath | Should -BeExactly $data
    }

    It "should work with platform's slashes" {
        $testPath = "$TestDrive$([IO.Path]::DirectorySeparatorChar)testFile.txt"
        Get-Content $testPath | Should -BeExactly $data
    }

    It "should work with forward slashes" {
        $testPath = "$TestDrive/testFile.txt"
        Get-Content $testPath | Should -BeExactly $data
    }

    It "should work with backward slashes" {
        $testPath = "$TestDrive\testFile.txt"
        Get-Content $testPath | Should -BeExactly $data
    }

    It "should work with backward slashes for each separator" {
        $testPath = "$TestDrive\testFile.txt".Replace("/","\")
        Get-Content $testPath | Should -BeExactly $data
    }

    It "should work with forward slashes for each separator" {
        $testPath = "$TestDrive/testFile.txt".Replace("\","/")
        Get-Content $testPath | Should -BeExactly $data
    }

    It "should work even if there are too many forward slashes" {
        $testPath = "$TestDrive//////testFile.txt"
        Get-Content $testPath | Should -BeExactly $data
    }

    It "should work even if there are too many backward slashes" {
        $testPath = "$TestDrive\\\\\\\testFile.txt"
        Get-Content $testPath | Should -BeExactly $data
    }
}