PsDaVinci.tests.ps1

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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# Copyright (c) STÜBER SYSTEMS GmbH. All rights reserved.
# Licensed under the MIT License.

BeforeAll {
    # Get the path of our module
    $modulePath = $PSCommandPath.Replace('.tests.ps1','.psm1')
    # Import the module for testing
    Import-Module $modulePath -Force
}

Describe -name "Tests" {
    Context "Module interface" {
        It "Module should export 4 commands in alphabetical order." {
            $commands = Get-Command -Module PsDaVinci
            $commands.Count | Should -BeExactly 4
            $commands[0].Name | Should -Be "Initialize-DaVinciExport"
            $commands[1].Name | Should -Be "Initialize-DaVinciImport"
            $commands[2].Name | Should -Be "Start-DaVinciExport"
            $commands[3].Name | Should -Be "Start-DaVinciImport"
        }
    }
    Context "GetFullConfigPath" {
        It "[.\config] should return [.\config.json]" {
            InModuleScope PsDaVinci {
                $fileName = GetFullConfigPath .\config
                $fileName | Should -Be '.\config.json'
            }
        }
        It "[.\config.json] should return [.\config.json]" {
            InModuleScope PsDaVinci {
                $fileName = GetFullConfigPath .\config.json
                $fileName | Should -Be '.\config.json'
            }
        }
        It "[.\config.txt] should return [.\config.txt]" {
            InModuleScope PsDaVinci {
                $fileName = GetFullConfigPath .\config.txt
                $fileName | Should -Be '.\config.txt'
            }
        }
        It "[config] should return [($location)\config.json]" {
            InModuleScope PsDaVinci {
                $location = Get-Location
                $fileName = GetFullConfigPath config
                $fileName | Should -Be "$($location)\config.json"
            }
        }
        It "[config.json] should return [($location)\config.json]" {
            InModuleScope PsDaVinci {
                $location = Get-Location
                $fileName = GetFullConfigPath config.json
                $fileName | Should -Be "$($location)\config.json"
            }
        }
        It "[config.txt] should return [($location)\config.txt]" {
            InModuleScope PsDaVinci {
                $location = Get-Location
                $fileName = GetFullConfigPath config.txt
                $fileName | Should -Be "$($location)\config.txt"
            }
        }
    }
}